Skip to content

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 into
microsoft:rel/4.3from
nohwnd-bot:backport/9777/to/rel/4.3
Jul 9, 2026
Merged

Make ReflectionFree the default source-gen mode + harden AOT acceptance tests by @Evangelink in #9777 (backport to rel/4.3)#9791
Evangelink merged 7 commits into
microsoft:rel/4.3from
nohwnd-bot:backport/9777/to/rel/4.3

Conversation

@nohwnd-bot

Copy link
Copy Markdown
Contributor

Backport of #9777 to rel/4.3

/cc @Evangelink

Evangelink and others added 6 commits July 9, 2026 16:45
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
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 Evangelink added the state/needs-review Awaiting review from the team. label Jul 9, 2026
@Evangelink
Evangelink merged commit 7a12129 into microsoft:rel/4.3 Jul 9, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants