Skip to content

Update test project to TUnit and regenerate outputs#396

Open
ChrisPulman wants to merge 10 commits intomainfrom
MigrateToTUnit
Open

Update test project to TUnit and regenerate outputs#396
ChrisPulman wants to merge 10 commits intomainfrom
MigrateToTUnit

Conversation

@ChrisPulman
Copy link
Copy Markdown
Member

@ChrisPulman ChrisPulman commented Apr 3, 2026

  • Analyzed CI failures - DependencyProperty, PropertyMetadata, GetValue, SetValue missing from stubs
  • Extend WindowsDesktopStubs in TestCompilationReferences.cs to include DependencyProperty, PropertyMetadata, and GetValue/SetValue on DependencyObject
  • Enable parallel: true in testconfig.json to allow TUnit class-level parallelism
  • Cache CreateSupportReferences() per generator type T in TestHelper<T> — avoids recompiling the attribute-definition support assembly on every test call
  • Cache TestCompilationReferences.CreateDefault() — avoids rescanning all loaded assemblies + file I/O on every test call
  • Replace catch (NullReferenceException) with IsDefaultOrEmpty guard in AttributeDataExtensions.TryGetNamedArgument/GetNamedArgument to avoid silently masking real bugs
  • All 217 tests pass on net9.0 with coverage

Configure test projects and refresh generated/verified files. Adds global.json and testconfig.json, enables dotnet test support, TUnit implicit usings, and sets OutputType to Exe in Directory.Build.props (also links testconfig.json into test outputs). Removes certain NUnit/Verify package version entries from Directory.Packages.props and deletes AssemblyInfo.Parallel.cs. Regenerates many .verified.cs files (OAP/OAPH/REACTIVE/RxGenExt and others), reflecting changes such as renamed generated members, readonly/visibility adjustments to ObservableAsPropertyHelper fields, removal of some JsonInclude attributes, addition of MemberNotNull annotations, and other minor accessor/initializer updates. Also updates the solution file.
Add numerous generated .g.verified.cs test artifacts for source-generator unit tests (DERIVEDLIST, IVIEWFOR, OAPH, REACTIVE, REACTIVECMD, RxCmd/RxGen/Oap extensions, etc.). Update Directory.Packages.props to remove some NuGet entries, bump Microsoft.Extensions.Logging.Debug and System.Formats.Asn1 to 10.0.5, consolidate ReactiveUI.Maui to 23.2.1, and prune several test/reference packages. Also update generated view registrations in ReactiveUI.ReactiveUISourceGeneratorsExtensions and tweak several test project and helper files to match the generated outputs.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the source generator test suite from NUnit to TUnit/Microsoft.Testing.Platform and refreshes the large set of verified generator outputs, while also making a few generator/runtime helpers more resilient (nested-type IViewFor generation, attribute argument parsing, and test-compilation reference resolution).

Changes:

  • Add Microsoft.Testing.Platform configuration (global.json, testconfig.json) and wire it into test builds via Directory.Build.props.
  • Switch the test project to TUnit + Verify.TUnit and refactor the in-memory compilation/test harness and references.
  • Regenerate/expand many .verified.cs artifacts to reflect updated generator outputs (including nested-type IViewFor output and ReactiveCommand variations).

Reviewed changes

Copilot reviewed 91 out of 91 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/testconfig.json Adds MTP configuration (no parallel, code coverage settings).
src/ReactiveUI.SourceGenerators.slnx Includes global.json and testconfig.json in solution items.
src/ReactiveUI.SourceGenerators.Roslyn/ReactiveCommand/ReactiveCommandGenerator.Execute.cs Uses context.Attributes[0] for ReactiveCommand attribute data when collecting method info.
src/ReactiveUI.SourceGenerators.Roslyn/IViewFor/IViewForGenerator.Execute.cs Adds nested-type wrapping support via generated parent declarations/closings.
src/ReactiveUI.SourceGenerators.Roslyn/IViewFor/IViewForGenerator.cs Passes parent type info into source generation for nested types.
src/ReactiveUI.SourceGenerators.Roslyn/Core/Extensions/AttributeDataExtensions.cs Adds null/edge handling for named args, generic type parsing, enums, and typed-constant errors.
src/ReactiveUI.SourceGenerators.Execute/ReactiveUI.SourceGenerators.Execute.csproj Excludes execute project from code coverage.
src/ReactiveUI.SourceGenerators.Execute.Nested3/ReactiveUI.SourceGenerators.Execute.Nested3.csproj Excludes nested execute project from code coverage.
src/ReactiveUI.SourceGenerators.Execute.Nested2/ReactiveUI.SourceGenerators.Execute.Nested2.csproj Excludes nested execute project from code coverage.
src/ReactiveUI.SourceGenerators.Execute.Nested1/ReactiveUI.SourceGenerators.Execute.Nested1.csproj Excludes nested execute project from code coverage.
src/ReactiveUI.SourceGenerators.Execute.Maui/ReactiveUI.SourceGenerators.Execute.Maui.csproj Excludes Maui execute project from code coverage.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ViewForExtTests.cs Updates/extents IViewFor tests (WPF System.Windows usage, namespace structure adjustments).
src/ReactiveUI.SourceGenerator.Tests/UnitTests/TestCompilationReferences.cs Reworks reference discovery to use runtime-loaded assemblies + WindowsDesktop resolution on Windows.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/RxObjExtTests.cs Removes NUnit fixture annotation and adjusts a test input snippet.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/RxGenExtTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/RxCollExtTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/RxCmdExtTests.cs Adds new ReactiveCommand scenarios and updates a method name used for output verification.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveObjectGeneratorTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveGeneratorTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveCollectionGeneratorTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveCMDGeneratorTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveAttributeMisuseCodeFixProviderTests.cs Updates assertions for TUnit style and adds extra provider behavior tests.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/ReactiveAttributeMisuseAnalyzerTests.cs Updates assertions for TUnit style and adds extra analyzer behavior tests.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/PropertyToReactiveFieldCodeFixProviderTests.cs Updates assertions for TUnit style and adds extra provider behavior tests.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/PropertyToReactiveFieldAnalyzerTests.cs Updates assertions for TUnit style and adds extra analyzer behavior tests.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/PropAnalyzerExtTests.cs Converts NUnit asserts to helper methods/throws for the new runner style.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/OAPGeneratorTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/OAPFromObservableGeneratorTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/OapExtTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/IViewForGeneratorTests.cs Updates IViewFor generator tests to include WPF System.Windows input.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/DerivedListExtTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/BindableDerivedListGeneratorTests.cs Removes NUnit fixture annotation.
src/ReactiveUI.SourceGenerator.Tests/UnitTests/AttrMisuseExtTests.cs Converts NUnit asserts to helper methods/throws for the new runner style.
src/ReactiveUI.SourceGenerator.Tests/TestHelper.cs Replaces NuGet-download-based compilation setup with runtime-reference + support-assembly approach; updates diagnostics handling.
src/ReactiveUI.SourceGenerator.Tests/TestBase.cs Removes NUnit OneTimeSetUp/TearDown and simplifies to IDisposable-only base.
src/ReactiveUI.SourceGenerator.Tests/ReactiveUI.SourceGenerators.Tests.csproj Switches from NUnit to TUnit + Verify.TUnit and adjusts implicit usings/output type.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromReactiveCommandWithProtectedAccess#TestNs.TestVM.ReactiveCommands.g.verified.cs Regenerated verified output reflecting access modifier changes.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromReactiveCommandWithPrivateAccess#TestNs.TestVM.ReactiveCommands.g.verified.cs Regenerated verified output reflecting access modifier changes.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromReactiveCommandWithCanExecuteMethod#TestNs.TestVM.ReactiveCommands.g.verified.cs New verified output for CanExecute method scenario.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromReactiveCommandWithCanExecuteMethod#ReactiveUI.SourceGenerators.ReactiveCommandAttribute.g.verified.cs New verified output capturing injected ReactiveCommandAttribute source.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromReactiveCommandsAcrossPartialDeclarations#TestNs.TestVM.ReactiveCommands.g.verified.cs New verified output for split partial declarations scenario.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromReactiveCommandsAcrossPartialDeclarations#ReactiveUI.SourceGenerators.ReactiveCommandAttribute.g.verified.cs New verified output capturing injected ReactiveCommandAttribute source.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromReactiveCommandInGenericClass#TestNs.GenericVM`1.ReactiveCommands.g.verified.cs Updated verified output reflecting renamed command/members.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/RxCmdExtTests.FromMultipleReactiveCommands#TestNs.TestVM.ReactiveCommands.g.verified.cs Updated verified output reflecting access modifier changes.
src/ReactiveUI.SourceGenerator.Tests/REACTIVECMD/ReactiveCMDGeneratorTests.Access#TestNs.TestVM.ReactiveCommands.g.verified.cs Updated verified output reflecting access modifier changes.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.Record#TestNs.RecordView.IViewFor.g.verified.cs New verified output for record view scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.PerReq#TestNs.TestView.IViewFor.g.verified.cs New verified output for per-request registration scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.PerReq#ReactiveUI.ReactiveUISourceGeneratorsExtensions.g.verified.cs Updated registration extension output (per-request registration).
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.Nested#TestNs.ChildView.IViewFor.g.verified.cs New verified output for nested view model type scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.LazySingle#TestNs.TestView.IViewFor.g.verified.cs New verified output for lazy singleton registration scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.LazySingle#ReactiveUI.ReactiveUISourceGeneratorsExtensions.g.verified.cs Updated registration extension output (lazy singleton registration).
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.Interface#TestNs.InterfaceView.IViewFor.g.verified.cs New verified output for interface view model scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.Generic#TestNs.StringItemView.IViewFor.g.verified.cs New verified output for generic view model scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromMultipleIViewForInSameNamespace#TestNs.View3.IViewFor.g.verified.cs New verified output for multi-view scenario (View3).
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromMultipleIViewForInSameNamespace#TestNs.View2.IViewFor.g.verified.cs New verified output for multi-view scenario (View2).
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromMultipleIViewForInSameNamespace#TestNs.View1.IViewFor.g.verified.cs New verified output for multi-view scenario (View1).
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromMultipleIViewForInSameNamespace#ReactiveUI.ReactiveUISourceGeneratorsExtensions.g.verified.cs Updated registration extension output for multi-view scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromIViewForWithViewModelRegistration#TestNs.TestView.IViewFor.g.verified.cs New verified output including view + view model registrations.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromIViewForWithViewModelRegistration#ReactiveUI.ReactiveUISourceGeneratorsExtensions.g.verified.cs Updated registration extension output including view model registration.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromIViewForWithStringViewModelType#TestNs.TestView.IViewFor.g.verified.cs New verified output for string-based view model type scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromIViewForWithReactivePropertiesViewModel#TestNs.ReactivePropertiesView.IViewFor.g.verified.cs New verified output for view model containing reactive properties.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromIViewForWithReactiveCommandsViewModel#TestNs.CommandsView.IViewFor.g.verified.cs New verified output for view model containing reactive commands.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.FromIViewForWithNestedViewClass#TestNs.OuterContainer+MiddleContainer+NestedView.IViewFor.g.verified.cs New verified output validating nested view class wrapping.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.ExtNs#App.Views.ExternalView.IViewFor.g.verified.cs New verified output for external namespace view model reference.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.DiffNs#Views.ProductView.IViewFor.g.verified.cs New verified output for differing view/viewmodel namespaces.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.Constant#TestNs.TestView.IViewFor.g.verified.cs New verified output for constant registration scenario.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.Constant#ReactiveUI.ReactiveUISourceGeneratorsExtensions.g.verified.cs Updated registration extension output (constant registration).
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.AllRegOpts#TestNs.FullView.IViewFor.g.verified.cs New verified output covering all registration options.
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/ViewForExtTests.AllRegOpts#ReactiveUI.ReactiveUISourceGeneratorsExtensions.g.verified.cs Updated registration extension output (views + view models).
src/ReactiveUI.SourceGenerator.Tests/IVIEWFOR/IViewForGeneratorTests.Basic#TestNs.TestViewWpf.IViewFor.g.verified.cs New verified output for basic WPF view scenario.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.TupleType#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for tuple element types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.StructType#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for struct element types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.RecordClass#TestNs.TestVMRecord.BindableDerivedList.g.verified.cs New verified output for record containers.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.NullableElements#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for nullable elements.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.NestedClass#TestNs.OuterVM+InnerVM+DeepInnerVM.BindableDerivedList.g.verified.cs New verified output for deep nested type containers.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.NestedClass#TestNs.OuterVM+InnerVM.BindableDerivedList.g.verified.cs New verified output for nested type containers.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.NestedClass#TestNs.OuterVM.BindableDerivedList.g.verified.cs New verified output for outer container.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.MultipleLists#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for multiple lists in one type.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.InterfaceType#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for interface element types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.GuidType#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for Guid element types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.GenericClass#TestNs.GenericVM`1.BindableDerivedList.g.verified.cs New verified output for generic container types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.EnumType#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for enum element types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.DiffNamespaces#Namespace2.TestVM.BindableDerivedList.g.verified.cs New verified output for multiple namespaces (Namespace2).
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.DiffNamespaces#Namespace1.TestVM.BindableDerivedList.g.verified.cs New verified output for multiple namespaces (Namespace1).
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.DateTimeType#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for DateTime/DateTimeOffset element types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/DerivedListExtTests.ComplexGeneric#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for complex generic element types.
src/ReactiveUI.SourceGenerator.Tests/DERIVEDLIST/BindableDerivedListGeneratorTests.FromReactiveProperties#TestNs.TestVM.BindableDerivedList.g.verified.cs New verified output for derived list + reactive properties scenario.
src/ReactiveUI.SourceGenerator.Tests/AssemblyInfo.Parallel.cs Removes NUnit parallelization assembly-level attributes.
src/global.json Configures dotnet test to use Microsoft.Testing.Platform runner.
src/Directory.Packages.props Removes NUnit/Verify.NUnit-related versions and bumps/aligns selected packages; adds TUnit versions.
src/Directory.Build.props Enables MTP dotnet test support for test projects and links testconfig.json to outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Delete Microsoft.NET.Test.Sdk and System.Formats.Asn1 PackageReference entries from src/ReactiveUI.SourceGenerator.Tests/ReactiveUI.SourceGenerators.Tests.csproj to clean up unused dependencies in the test project.
…or generated WPF output

Agent-Logs-Url: https://github.com/reactiveui/ReactiveUI.SourceGenerators/sessions/07f5ac96-b377-4dce-9e68-25f253f3cbb6

Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>
Copilot AI and others added 2 commits April 4, 2026 02:33
… recompilation overhead

Previously CreateSupportReferences() and TestCompilationReferences.CreateDefault() were called
on every test invocation, doing a full Roslyn compilation + Emit and an assembly scan + file I/O
on each of the 217 tests. Both methods produce identical output for all tests with the same
generator type T, so the results are now cached via static Lazy<> fields.

Result: 217 tests with coverage now complete in ~6s per TFM locally (was ~37s),
expected to reduce CI from ~13 min to ~2-3 min per TFM on Linux and macOS.

Agent-Logs-Url: https://github.com/reactiveui/ReactiveUI.SourceGenerators/sessions/d5d0b260-3c81-4047-bf50-ebbe264480d4

Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

❌ Patch coverage is 36.00000% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.59%. Comparing base (7441aba) to head (a3d01cb).

Files with missing lines Patch % Lines
....Roslyn/Core/Extensions/AttributeDataExtensions.cs 32.43% 19 Missing and 6 partials ⚠️
...ators.Roslyn/IViewFor/IViewForGenerator.Execute.cs 45.45% 6 Missing ⚠️
...rceGenerators.Roslyn/IViewFor/IViewForGenerator.cs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #396      +/-   ##
==========================================
+ Coverage   55.84%   59.59%   +3.75%     
==========================================
  Files          75       75              
  Lines        4063     4084      +21     
  Branches      500      571      +71     
==========================================
+ Hits         2269     2434     +165     
+ Misses       1600     1480     -120     
+ Partials      194      170      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…AttributeDataExtensions

The NamedArguments property returns a default ImmutableArray when attribute data is
incomplete/malformed at analysis time. Guard with .IsDefaultOrEmpty before iterating
rather than swallowing NullReferenceException, which could mask real Roslyn API bugs.

Agent-Logs-Url: https://github.com/reactiveui/ReactiveUI.SourceGenerators/sessions/7c58663a-a9ce-4cfa-a3ff-9a57bc0347a9

Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants