Make ReflectionFree the default source-gen mode + harden AOT acceptance tests by @Evangelink in #9777 (backport to rel/4.3)#9791
Merged
Evangelink merged 7 commits intoJul 9, 2026
Conversation
MSTestSourceGenMode now defaults to ReflectionFree (was Rooting) in MSTest.TestAdapter.targets. The source generator is only active for Native AOT / trim consumers (PublishAot or a manual MSTest.SourceGeneration reference), and ReflectionFree is a superset of Rooting (materialized attributes + delegate invokers), so it is the safer default for that audience. The SourceGeneration acceptance metadata mode now passes -p:MSTestSourceGenMode=Rooting explicitly so the Rooting path stays covered now that it is no longer the default. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Set MSTestSourceGenMode=ReflectionFree explicitly in the Native AOT acceptance asset (it is also the shipped default now) and correct the stale comments: the asset genuinely runs reflection-free, and warnAsError stays off because MSTest.TestAdapter's native MTP path uses the vstest Microsoft.TestPlatform.ObjectModel TestCase/TestProperty types regardless of source-gen mode, emitting IL20xx/IL30xx outside this repo's control. Enabling warnAsError is blocked on removing that ObjectModel reachability (tracked by microsoft#9769). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Re-add the UTF-8 BOM (utf-8-bom per .editorconfig) to the five .cs files whose BOM was accidentally stripped while editing their leading lines. - Clarify the rooting generator comment: it emits whenever the mode is not ReflectionFree, i.e. both when Rooting is selected and when the property is left unset (IsReflectionFree returns false in both cases). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The CI build (Windows/Linux legs) was already red on main before this PR due to two undeclared internal API surfaces flagged by RS0051: - BaseSerializer.ReadFields / WriteListPayload<T> (added by microsoft#9774) — the file is linked into Microsoft.Testing.Platform and the HangDump, Retry, TrxReport and Extensions.MSBuild extensions, so each project's InternalAPI.Unshipped.txt needs the declarations. - PlatformServicesConfigurationAdapter and its members (from microsoft#9755) in MSTest.TestAdapter, which only surface on the Windows/net462 TFMs the Linux analysis build never compiled. These are unrelated to the source-gen default change but block this PR's pipeline, so they are fixed here in a separate commit. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Complete the microsoft#9755 BridgedConfiguration -> PlatformServicesConfigurationAdapter rename: the old type name still lingered in InternalAPI.Shipped.txt and referenced a type that no longer exists. The new name was already added to InternalAPI.Unshipped.txt; drop the three stale shipped entries so the tracked internal-API surface is accurate. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
These entries referenced symbols not present as public API in these assemblies (BaseSerializer.ReadFields/WriteListPayload and PlatformServicesConfigurationAdapter), causing RS0017 build failures. The original PR microsoft#9777 did not touch any PublicAPI.Unshipped.txt files. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Evangelink
enabled auto-merge (squash)
July 9, 2026 18:00
The backport of microsoft#9777 dropped the change to SourceGenerationNonAotTests.cs. Once ReflectionFree becomes the default source-gen mode, the rooting generator no longer emits '<AssemblyName>.MSTestReflectionMetadata.g.cs'; the reflection-free generator emits 'MSTestReflectionMetadata.Registry.g.cs' (plus SupportTypes/Registration) instead. Match either output with a '*MSTestReflectionMetadata*.g.cs' glob so the smoke test stays independent of the default mode. Mirrors the original PR microsoft#9777. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Evangelink
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #9777 to rel/4.3
/cc @Evangelink