From 417a3d31cf92ba8360c28ae28abffb37de1ea268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Mon, 22 Jun 2026 14:00:13 +0200 Subject: [PATCH 1/2] Fix double registration in MSTest.AotReflection.SourceGeneration PoC and make it packable (non-shipping) The PoC analyzer assembly compiled in MSTest.SourceGeneration's ReflectionMetadataGenerator (which is itself [Generator]), so referencing the PoC ran two source generators. Each emitted a [ModuleInitializer] calling ReflectionMetadataHook.Register for the same assembly, registering it twice with the composite provider and doubling discovered test counts (a 2-test project reported 4). The PoC's own RuntimeRegistrationEmitter already emits a complete, richer (5-arg, attribute-carrying) registration plus DynamicDependency rooting, so the shared shipping generator was redundant. Remove the three shared Compile includes (generator, emitter, model) that nothing in the PoC referenced; only one ModuleInitializer is emitted now and a sample reports the correct test count. Also make the project packable as a non-shipping package (IsPackable=true, IsShipping=false) so it can be consumed locally for experimentation; the generator dll is packed under analyzers/dotnet/cs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...Test.AotReflection.SourceGeneration.csproj | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj b/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj index 4f231889e8..f3bbd6a791 100644 --- a/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj +++ b/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj @@ -8,20 +8,22 @@ $(NoWarn);NU5128 true MSTest.AotReflection.SourceGeneration - false - + + true false false + - - PoC source generator that emits the metadata MSTest's IReflectionOperations would normally - produce via runtime reflection (attributes, declared members, instance factories, method - invokers). The eventual goal is to wire this output into the MSTest adapter so it can run - tests under NativeAOT without performing any runtime reflection. Tracked by - https://github.com/microsoft/testfx/issues/1837. - + + + @@ -43,15 +45,11 @@ + - - - - + + + From 2cfbeee929f9e79cb8c0db750c3b6604960611c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Mon, 22 Jun 2026 14:08:10 +0200 Subject: [PATCH 2/2] Address PR review: capitalize NuGet in pack comment Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../MSTest.AotReflection.SourceGeneration.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj b/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj index f3bbd6a791..ff807a24cf 100644 --- a/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj +++ b/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj @@ -48,7 +48,7 @@ This package is experimental and non-shipping; do not take a dependency on it in - +