Core generator snapshot tests emit nullable and constant-assertion warnings

Open Beginner friendly
#7,428 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
testing

Research direction

Start with NuGetDownloader.cs around line 35, where CS8602 reports a possible null dereference, and with AssemblyNamesWithDashesTests.cs around line 23, where TUnitAssertions0005 flags a constant passed to Assert.That(...). Build with dotnet test --project tests/TUnit.Core.SourceGenerator.Tests --framework net10.0 to see both warnings. Done means that build no longer reports either diagnostic, and the tests still pass.

Written by the indexing model from the issue text.

Description

bug P3

Summary

Building the core source generator snapshot tests emits a nullable dereference warning and an assertion-on-constant warning from the test code. These diagnostics add noise to routine test validation; the test project should build without them.

Reproduction

At 7c87a5ec3ca3df50d75834424c56e651d78efade, on macOS arm64 with .NET SDK 10.0.403, run:

dotnet test --project tests/TUnit.Core.SourceGenerator.Tests --framework net10.0

Expected and actual

Expected: no warnings from these test sources.

Actual: NuGetDownloader.cs:35 emits CS8602 (possible null dereference), and AssemblyNamesWithDashesTests.cs:23 emits TUnitAssertions0005 (Assert.That(...) should not use a constant value). Both files have the same relevant code on main at d8badacb13. Other build warnings are tracked separately in #7410, #7412 and #7419.

Please correct these two test-code diagnostics.

Dominant language
C#
Stars
4k
Forks
139
Avg merge
9h 6m
Merged PRs (30d)
282

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thomhurst/TUnit

All issues in thomhurst/TUnit

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.