Skip to content

Analyzer and code-fixer projects emit release-tracking and nullable build warnings #7410

Open

Description

@thomhurst

Summary

Building the test application emits analyzer-release tracking and nullable-reference warnings from the analyzer and code-fixer projects. These warnings obscure new diagnostics during development; a clean build should keep those projects warning-free.

Reproduction

Run dotnet test --project tests/TUnit.TestProject --framework net10.0 --treenode-filter '/*/TUnit.TestProject.Bugs._6554/PartialInjectionFailure*/*' from a clean checkout. Build diagnostics include RS2002 for TUnit0074–TUnit0076 in TUnit.Analyzers, RS2008 for TUNIT0999 in TestMetadataGenerator.cs, CS8604 in BaseMigrationCodeFixProvider.cs:218, CS8600/CS8604 in NUnitExpectedResultRewriter.cs:168/180, and CS8602 in NUnitMigrationCodeFixProvider.cs:334.

Expected and actual

These projects should build without release-tracking or nullable warnings. The listed diagnostics are emitted before the filtered test run.

Environment

SDK 10.0.403, macOS arm64, PR #7391 head 85020f6 (these files are unchanged by that PR). Please correct the release metadata and nullable flows in these projects.

Remaining scope and acceptance criteria

The following warnings reported in the discussion are included in this issue, alongside the original analyzer and migration code-fixer warnings:

  • RS2008 for TM006, TM008 and TM009 in src/TUnit.Mocks.SourceGenerator/Diagnostics.cs, built through both TUnit.Mocks.SourceGenerator.Roslyn47 and TUnit.Mocks.SourceGenerator.Roslyn414.
  • RS1032 in src/TUnit.Analyzers.Internal/CultureSensitiveFormattingAnalyzer.cs, src/TUnit.Mocks.Analyzers/Rules.cs, and src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs.
  • RS2008 from the internal analyzer and assertion source-generator projects.

Acceptance criteria:

  • Correct the release-tracking metadata and diagnostic messages responsible for the reported RS2002, RS2008 and RS1032 warnings, rather than globally suppressing those warnings.
  • Correct the reported nullable flows in src/TUnit.Analyzers.CodeFixers/Base/BaseMigrationCodeFixProvider.cs, NUnitExpectedResultRewriter.cs, and NUnitMigrationCodeFixProvider.cs, preserving migration behavior.
  • Clean builds of the affected projects emit none of the listed warnings. Run the relevant analyzer, code-fixer and generator tests, including tests/TUnit.Mocks.SourceGenerator.Tests on net10.0; review affected snapshots if generated output changes.

Triage at d87516cb9c confirmed the reported nullable code and diagnostic descriptors remain. Original line numbers above are historical; use the named files and diagnostics to locate them. The follow-up warning reports came from SDK 10.0.403 on macOS arm64; this triage did not rerun builds.

Activity

  1. added
    bugSomething isn't working
    P3Low: cleanup, minor enhancement, or rare edge case
    on Nov 2, 2026
  2. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    Also reproduced RS2008 for TM006, TM008 and TM009 in src/TUnit.Mocks.SourceGenerator/Diagnostics.cs while building both src/TUnit.Mocks.SourceGenerator.Roslyn47 and src/TUnit.Mocks.SourceGenerator.Roslyn414 with SDK 10.0.403 on macOS arm64 at 301d94b. Each build succeeds with three warnings. Please include those shared mock-generator diagnostics in the release-tracking fix.

  3. thomhurst commented on Nov 2, 2026

    @thomhurst
    OwnerAuthor

    Building the mock generator tests at PR #7406 also emits RS1032 from src/TUnit.Analyzers.Internal/CultureSensitiveFormattingAnalyzer.cs:37, src/TUnit.Mocks.Analyzers/Rules.cs:30,71, and src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs:46,55, plus RS2008 from the internal and assertion generators. Reproduction: SDK 10.0.403, dotnet test --project tests/TUnit.Mocks.SourceGenerator.Tests --framework net10.0. Please include these existing diagnostic-message and release-tracking warnings in this cleanup.

  4. thomhurst commented on Nov 3, 2026

    @thomhurst
    OwnerAuthor

    Triage against d87516cb9c: the reported nullable flows and diagnostic descriptors remain. Folded both follow-up warning reports into the body and added acceptance criteria so the next implementation covers the full reported scope. No builds were run in this triage.

  5. thomhurst commented on Nov 3, 2026

    @thomhurst
    OwnerAuthor

    Building tests/TUnit.Analyzers.Tests at 309ed46 with SDK 10.0.403 on macOS arm64 also reports CS8602 in src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs:7252. The existing release-tracking and code-fixer warnings reproduce too.

  6. thomhurst commented on Nov 3, 2026

    @thomhurst
    OwnerAuthor

    Additional nullable warning observed while validating #7455 against main a412ddd5a5: src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs, in InferGenericTypesFromArgumentSymbols, dereferences nullable compilation at compilation.GetSpecialType(SpecialType.System_Object) in the null-only type-parameter fallback (CS8602, line 7508 at this PR head). Reproduce with SDK 10.0.403 on macOS arm64 using dotnet test --project tests/TUnit.Core.SourceGenerator.Tests --framework net10.0. This block is unchanged by #7455. Please include this generator nullable flow in the warning cleanup, preserving null-only class inference.

  7. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    A clean targeted build at 592bb959a2 with SDK 10.0.403 on macOS arm64 also emits CS8602 in src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs:7704 and RS2008 for TUNITGEN005 in StaticPropertyInitializationGenerator.cs:23. Reproduce with dotnet test --project tests/TUnit.TestProject --framework net10.0 --treenode-filter '/*/TUnit.TestProject.Bugs._7451/ClassAndMethodParameterInference*/*'. Please include these nullable/release-tracking warnings in this issue.

  8. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    Confirmed the existing nullable and release-tracking warnings while building the TUnit.Core package dependencies for #7533 on main be37704 with SDK 10.0.403 (macOS arm64). dotnet build of a solution filter containing TUnit.Core, its analyzer/source-generator Roslyn variants, and TUnit.Analyzers.CodeFixers succeeded with 24 warnings, including the nullable diagnostics already listed here.

  9. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    The Release/net10.0 targeted TestProject build at 8d0cffe384 also emits CS8602 in src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs:7704, RS2008 for TUNITGEN005 in StaticPropertyInitializationGenerator.cs:23, and RS2002 for TUnitAssertions0016. Reproduction: dotnet test --project tests/TUnit.TestProject --framework net10.0 -c Release --treenode-filter '/*/*/DependsOnTests2/*' --maximum-parallel-tests 4. SDK 10.0.403, macOS arm64. The existing migration code-fixer warnings also remain.

  10. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    The generator snapshot run for #7569 also emitted CS8602 in the unchanged InferTypesFromArgumentsAttribute code in TestMetadataGenerator.cs (line 6958 after the cleanup), and in MethodAssertionGenerator.cs:957. Command: dotnet test --project tests/TUnit.Core.SourceGenerator.Tests --framework net10.0, SDK 10.0.403, macOS arm64. Please include those nullable warnings in this cleanup; all 337 non-skipped tests passed.

  11. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    Confirmed during #7552 validation on main base 885ee5f799, SDK 10.0.403, macOS arm64: a clean targeted build still emits the release-tracking and migration nullable warnings tracked here. It also emits CS8602 at src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs:7374 (possible null dereference). Reproduce with dotnet test --project tests/TUnit.TestProject -f net10.0 --treenode-filter '/*/*/PreservedGenericTupleTests/*' in a clean worktree. Please include that generator nullable flow in the existing warning cleanup.

  12. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    Confirmed RS2008 and RS1032 warnings from src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs while building tests/TUnit.Engine.Tests/TUnit.Engine.Tests.csproj -c Release -f net10.0 at a85bb69 (SDK 10.0.403, macOS arm64). Build succeeded with 281 warnings and zero errors. These diagnostics remain within this issue’s recorded scope.

  13. thomhurst commented on Nov 4, 2026

    @thomhurst
    OwnerAuthor

    Reproduced the existing release-tracking, diagnostic-message and nullable warnings while building the analyzer tests for #7610 on SDK 10.0.403/macOS arm64. This also includes CS8602 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs:957. Command: dotnet test --project tests/TUnit.Analyzers.Tests/TUnit.Analyzers.Tests.csproj --framework net10.0 --treenode-filter "///MethodDataSourceAnalyzerTests/*". The 142 selected tests pass; warning cleanup remains outside #7610.

  14. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    Reproduced RS1032/RS2008/RS2002 release-tracking warnings and nullable warnings while building the net10.0 core generator tests for #7351 on main base 1a40c80; includes TestMetadataGenerator.cs(6648), MethodAssertionGenerator.cs(957), and code-fixer warnings already covered here.

  15. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    Still reproducible on main 555b85d with SDK 10.0.403 on macOS arm64 while building TUnit.UnitTests for net10.0. The build emits RS2008 in the core/internal/assertion generators, RS2002 for TUnitAssertions0014–0016, and the previously reported nullable migration warnings. The targeted discovery ownership tests pass; these existing build diagnostics remain covered by this issue.

  16. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    Reproduced the existing RS2002/RS2008 and migration code-fixer CS8600/CS8602/CS8604 warnings while building the #7388 targeted tests on main 7780a6a with SDK 10.0.403 on macOS arm64. The affected files and diagnostics match the scope already recorded here.

  17. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    Confirmed while validating #7433 on main base b9d47de: the mock source-generator test build reports CS8602 in MethodAssertionGenerator.cs:957, CS8600/CS8604 in NUnitExpectedResultRewriter.cs:168/180, and CS8602 in NUnitMigrationCodeFixProvider.cs:334. These existing nullable warnings remain; the relevant tests pass.

  18. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    Confirmed the existing RS1032/RS2008/RS2002 and nullable build warnings during #7436 validation on main base 45d4a52, SDK 10.0.403, macOS arm64. Reproduction: dotnet test --project tests/TUnit.Mocks.SourceGenerator.Tests --framework net10.0. The warnings remain within the scope already tracked here.

  19. thomhurst commented on Nov 5, 2026

    @thomhurst
    OwnerAuthor

    Reproduced on main 5a18e53 while validating #7462 with dotnet test --project tests/TUnit.Analyzers.Tests --framework net10.0: RS2000/RS2002 release-tracking warnings and CS8600/CS8604/CS8602 nullable warnings in the NUnit migration code fixers remain. Targeted tests pass; expected behavior is a warning-free analyzer/code-fixer build.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low: cleanup, minor enhancement, or rare edge casebugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions