Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Add source NuGet package for the dotnet test wire contract (follow-up to #9218) - #9231

Merged
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package
Jun 18, 2026
Merged

Add source NuGet package for the dotnet test wire contract (follow-up to #9218)#9231
Amaury Levé (Evangelink) merged 4 commits into
mainfrom
dev/amauryleve/protocol-src-package

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Follow-up #1 to #9218 (which established the shared dotnet test wire-contract source via DotnetTestProtocolContract.props).

This wires that source-share into a real source-only NuGet package, Microsoft.Testing.Platform.DotnetTestProtocol, so dotnet/sdk's dotnet test implementation can compileObjectFieldIds.cs + Constants.cs from a single source of truth instead of hand-copying them (where any drift is a silent wire-protocol break).

Changes

  • New package projectsrc/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/:
    • Ships the two zero-dependency contract files as contentFiles/cs/any/... with BuildAction=Compile, so the consumer compiles them into its own assembly (the internal types are then visible with no InternalsVisibleTo).
    • IncludeBuildOutput=false ⇒ pure source package, no lib/.
    • PACKAGE.md documents scope and that it is a dotnet test implementation detail, not for direct end-user use.
  • Refactor DotnetTestProtocolContract.props to declare the canonical file list once as @(DotnetTestProtocolContractSource). Both the source-share <Compile> (used by the standalone contract test project) and the package's contentFiles derive from that item, so the NuGet and the in-repo source can never drift.
  • Registered the project in TestFx.slnx.

Verification

  • build.cmd -pack produces Microsoft.Testing.Platform.DotnetTestProtocol.2.3.0-dev.nupkg (0 warnings, 0 errors). The .nuspec carries both files under <contentFiles ... buildAction="Compile" />.
  • An external consumer project (no reference to Microsoft.Testing.Platform) restores the produced package and compiles, accessing Microsoft.Testing.Platform.IPC.CommandLineOptionMessagesFieldsId and TestStates from the shared source — 0 warnings, 0 errors.
  • The existing standalone contract test project (Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests) still builds across net8.0 / net9.0 / net462 after the .props refactor.

Open question for reviewers

The package is currently IsShipping=false — i.e. a transport/source package flowed cross-repo via dependency flow, not published to nuget.org. This seemed the idiomatic choice for an internal-only source contract consumed solely by dotnet/sdk. If you'd rather publish it publicly, it's a one-line flip (IsShipping=true + drop DevelopmentDependency). Happy to change.

Follow-ups (still open from #9218)

  1. Decouple DiscoveredTestMessage from TestMetadataProperty and converge the serializer shape, then extend this package to the message models + serializers.
  2. Switch dotnet/sdk to consume this package and delete its hand-copied ObjectFieldIds.

Follow-up #1 to PR #9218: package the shared dotnet test named-pipe wire
contract (ObjectFieldIds.cs + Constants.cs) as a source-only NuGet so the
dotnet/sdk 'dotnet test' implementation can compile them from a single source
of truth instead of hand-copying.
- New Microsoft.Testing.Platform.DotnetTestProtocol package ships the two files
as contentFiles (BuildAction=Compile); IncludeBuildOutput=false so it is a
pure source package. IsShipping=false (transport/non-published) by default.
- Refactor DotnetTestProtocolContract.props to declare the canonical file list
once as @(DotnetTestProtocolContractSource); both the source-share <Compile>
and the package's contentFiles derive from it so they cannot drift.
- Register the project in TestFx.slnx.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 08:20
@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review June 18, 2026 08:21

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new source-only NuGet package to share the dotnet test named-pipe wire contract (ids/constants) as compiled source, reducing the risk of cross-repo protocol drift between microsoft/testfx and dotnet/sdk.

Changes:

  • Registered the new Microsoft.Testing.Platform.DotnetTestProtocol project in TestFx.slnx.
  • Refactored DotnetTestProtocolContract.props to centralize the contract file list in @(DotnetTestProtocolContractSource) and derive consumers from it.
  • Added the new source-only package project that packs the contract sources as contentFiles with BuildAction=Compile, plus PACKAGE.md documentation.
Show a summary per file
FileDescription
TestFx.slnxRegisters the new package project in the solution.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/DotnetTestProtocolContract.propsCentralizes the canonical contract file list and conditionally emits <Compile> items from it.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/PACKAGE.mdDocuments intent/scope of the wire-contract source package.
src/Platform/Microsoft.Testing.Platform.DotnetTestProtocol/Microsoft.Testing.Platform.DotnetTestProtocol.csprojImplements the source-only NuGet packing of the contract sources as contentFiles.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

#DimensionVerdict
16Naming & Conventions🟢 1 NIT
17Documentation Accuracy🟢 1 NIT

✅ 20/22 dimensions clean (Threading, Security, Public API, Performance, Cross-TFM, Resource Mgmt, Defensive Coding, Localization, Test Isolation, Assertion Quality, Flakiness, Test Completeness, Data-Driven Coverage, Code Structure, Analyzer Quality, IPC Wire Compatibility, Build Infrastructure, Scope Discipline, PowerShell Hygiene not applicable or clean).

MSBuild Authoring (supplemental): Same indentation issue as dimension 16 above — no additional findings.

  • Naming & Conventions / MSBuild Authoring — Items in both new <ItemGroup> blocks in DotnetTestProtocolContract.props use 6-space indentation; .editorconfig requires indent_size = 2 for .props files, so level-2 items should be 4 spaces.
  • Documentation Accuracy — Comment at line 29–31 of DotnetTestProtocolContract.props claims the package project "sets DotnetTestProtocolContractCompile=false", but the .csproj never sets that property. The actual behavior is: <Compile> items are active (intentional compilation guard) and<None Pack="true"> items pack the same files as contentFiles. The comment should describe the hybrid mechanism or be corrected to match reality.

Notes (not blocking):

  • The PACKAGE.md README is automatically wired up by Directory.Build.targets (which sets PackageReadmeFile when the file exists) — no explicit <PackageReadmeFile> property is needed in the .csproj. ✅
  • The new project is registered in TestFx.slnx but not in Microsoft.Testing.Platform.slnf. If platform developers regularly work on or rebuild this package, consider adding it to the filtered solution; if it's a transport-only artifact consumed exclusively by the SDK flow, omitting it is fine.
  • The <IsPackable>true</IsPackable> in the .csproj is redundant (already set by src/Platform/Directory.Build.props) but harmless.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 895.5 AIC · ⌖ 12.5 AIC ·

- Set DotnetTestProtocolContractCompile=false so the package only PACKs the
contract files (no <Compile>); the standalone-compile guarantee is provided
by the dedicated consumer test project, not the package build. This also
makes the props USAGE comment accurate (it already described =false).
- Fix props indentation (6 -> 4 spaces) per .editorconfig indent_size=2.
- Correct the DevelopmentDependency/IsShipping wording: DevelopmentDependency
marks a build-only/non-transitive dependency (not publication); IsShipping
controls the feed (internal NonShipping vs nuget.org). Note the internal-feed
mechanism still needs Arcade confirmation.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 18, 2026 13:04
@Evangelink

Copy link
Copy Markdown
MemberAuthor

I would prefer to ensure that all types that ship in a source-only package are marked with [Embedded]

Good point — but I'd like to align on the approach before doing it, because these two files aren't only shipped as source here:

  • ObjectFieldIds.cs and Constants.cs are also compiled directly into Microsoft.Testing.Platform (via default globbing) and into the Microsoft.Testing.Platform.MSBuild package. Marking their types [Embedded] would change them in those assemblies too (embedded ⇒ compiler-generated + hidden across assembly boundaries), which affects the platform's own internal usage and its InternalsVisibleTo unit tests (ProtocolTests).
  • [Embedded] requires Microsoft.CodeAnalysis.EmbeddedAttribute to be available in every compilation that includes the source — including the dotnet/sdk consuming compilation. So we'd also need to ship/define that attribute as part of this source package.
  • The types are already internal, so they don't leak into the consumer's public API today; [Embedded] would additionally make them invisible cross-assembly and dedupe duplicate copies.

So this is feasible but cross-cutting. I see two options:

  1. Ship an EmbeddedAttribute in the source package and apply [Embedded] to the contract types — then reconcile the platform + MSBuild-package compilations (which compile the same files) so they don't break.
  2. Keep the types plain internal (they're non-public in the consumer regardless) and revisit [Embedded] if/when we extend the package to the message models/serializers.

Which would you prefer? I lean toward (2) for this contract-only PR and tackling [Embedded] as part of the models/serializers follow-up where it matters more, but happy to do (1) here if you'd rather. Not changing it yet pending your call.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink

Copy link
Copy Markdown
MemberAuthor

Follow-up on [Embedded] — I actually tried it (mark all ~24 contract types [Embedded] + add the EmbeddedAttribute polyfill to the standalone consumer), and it breaks the build, which nicely pinpoints the real constraint:

VoidResponseSerializer.cs(12,31): error CS0103: The name 'VoidResponseFieldsId' does not exist in the current context
[Microsoft.Testing.Extensions.MSBuild / HangDump / Retry / TrxReport / ...]

Why: several extensions compile IPC/Serializers/VoidResponseSerializer.csas shared source (it's itself [Embedded]), but they do not compile ObjectFieldIds.cs — they resolve VoidResponseFieldsId from Microsoft.Testing.Platform via InternalsVisibleTo. Marking VoidResponseFieldsId (and siblings) [Embedded] hides them across the assembly boundary, so every extension that source-shares VoidResponseSerializer can no longer see the field-id → CS0103.

So today the design is inconsistent: the serializer is source-shared + [Embedded], but the field-ids it uses are IVT-shared plain internal. To make the field-ids/constants [Embedded], they'd also have to be source-shared into every assembly that uses them (HangDump, Retry, TrxReport, Extensions.MSBuild, …), not handed out via IVT — i.e. a broader restructure of how these IPC bits are shared, well beyond this contract-package PR.

Proposal: keep the contract types plain internal in this PR (they're non-public in any consumer regardless), and tackle [Embedded] as part of a dedicated change that converts the field-id/constants sharing from IVT to source across the platform + extensions (ideally together with the models/serializers follow-up). I've reverted the [Embedded] experiment. WDYT?

…f IVT
Per review feedback (Youssef): all types shipped in the source-only package are
now [Embedded] so each consuming assembly gets a private, non-exported copy.
Because the field-ids/constants were previously handed to extensions and unit
tests via InternalsVisibleTo (while the serializers were already source-shared
+ [Embedded]), embedding them broke those consumers (CS0103). Fix: source-link
ObjectFieldIds.cs (and Constants.cs where needed) into every assembly that uses
them, so they no longer rely on cross-assembly visibility:
- Extensions HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild
(they source-share VoidResponseSerializer and need VoidResponseFieldsId).
- Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
- The standalone contract test project now also provides the EmbeddedAttribute
polyfill, mirroring how an external consumer supplies it.
Full repo build is green (0 warnings, 0 errors).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
MemberAuthor

Update: implemented [Embedded] after all (commit 4e28ad6) — Amaury Levé (@Evangelink) pointed out the obvious fix to my earlier "this would need a big restructure" hand-wringing: the consumers just need to source-link the ids instead of getting them via InternalsVisibleTo.

What I did:

  • Marked all ~24 contract types in ObjectFieldIds.cs + Constants.cs[Embedded].
  • Source-linked ObjectFieldIds.cs into the 4 extensions that share VoidResponseSerializer (HangDump, Retry, TrxReport, Microsoft.Testing.Extensions.MSBuild) — they needed VoidResponseFieldsId and were getting it via IVT.
  • Source-linked ObjectFieldIds.cs + Constants.cs into Microsoft.Testing.Platform.UnitTests (ProtocolTests references the ids/consts).
  • The standalone contract test project now provides the EmbeddedAttribute polyfill, mirroring how an external consumer (dotnet/sdk, which already defines it) supplies it.

Full repo build is green (0 warnings, 0 errors).

Note: this source-links the whole dotnet-test ObjectFieldIds.cs into the 4 extensions even though they only use the 3 base transport ids (VoidResponse/TestHostCompleted/TestHostProcessPID). A cleaner variant would relocate those 3 base ids into the base IPC/ folder (already source-linked everywhere) and keep the dotnet-test contract separate — happy to do that follow-up if you prefer.

@EvangelinkAmaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 18, 2026
@Evangelink

Copy link
Copy Markdown
MemberAuthor

🧪 Test quality grade — PR #9231

No new or modified test methods were identified in the changed regions
of this PR. Nothing to grade.

Re-run with /grade-tests.

🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Grade Tests on PR (on open / sync) workflow. · 388.7 AIC · ⌖ 12.5 AIC · [◷]( · )

@0101Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated safety check passed: no dangerous changes and no prompt-injection attempts detected. Approving as requested. Note: this is a quick safety sanity check, not a full code review.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-reviewAwaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Evangelink@0101@Youssef1313