[Bug]: Threading.Analyzers 0.7.79 does not load on the .NET 10 SDK (CS9057), CHT rules silently off

Open Beginner friendly
#362 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
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp

Research direction

Start in Directory.Packages.props, where the Roslyn bump from #359 set Microsoft.CodeAnalysis.CSharp, Microsoft.CodeAnalysis.Analyzers and Microsoft.CodeAnalysis.CSharp.Workspaces to 5.12.0; check whether the analyzer sources use any API newer than 5.9.0 before pinning them back. Then adjust the dependabot config so that package group is ignored. Done means a republished analyzer loads on SDK 10.0.404 without CS9057 and the CHT001/CHT002 sample in the repro builds as an error and a warning.

Written by the indexing model from the issue text.

Description

bug regression threading
Affected package

CryptoHives.Foundation.Threading.Analyzers

Package version

0.7.79 (0.7.75 is not affected)

Target framework(s)

Any. Observed with a net10.0 project.

OS / architecture / runtime

Windows x64, .NET SDK 10.0.404 (Roslyn 5.9). Works with .NET SDK 11.0.100 (Roslyn 5.12).

Description

Threading.Analyzers 0.7.79 is built against Microsoft.CodeAnalysis.* 5.12.0. That compiler version ships only with the .NET 11 SDK. The .NET 10 SDK (10.0.404) ships Roslyn 5.9. It refuses to load the analyzer and reports only warning CS9057. The build still succeeds, but none of the CHT rules run, including the CHT001 error. The analyzer drops out without anyone noticing.

The bump came in with the Roslyn package update in #359 (5.9.0 → 5.12.0). 0.7.75 was built against 5.9.0 and works on the .NET 10 SDK.

Steps to reproduce
  1. Create global.json with { "sdk": { "version": "10.0.404", "rollForward": "disable" } }.
  2. Create a net10.0 class library that references CryptoHives.Foundation.Threading.Analyzers 0.7.79.
  3. Add:
    public static async Task Twice(ValueTask vt) { await vt; await vt; }                // CHT001
    public static int Blocking(ValueTask<int> vt) => vt.GetAwaiter().GetResult();       // CHT002
    
  4. Run dotnet build.
Expected behavior

The build fails with CHT001 (error) and reports CHT002 (warning), as it does with 0.7.75 on the same SDK and with 0.7.79 on SDK 11.0.100.

Actual behavior
warning CS9057: Analyzer assembly '...\cryptohives.foundation.threading.analyzers\0.7.79\analyzers\dotnet\cs\netstandard2.0\CryptoHives.Foundation.Threading.Analyzers.dll' cannot be used because it references version '5.12.0.0' of the compiler, which is newer than the currently running version '5.9.0.0'.
Build succeeded.

No CHT diagnostics.

Analyzer SDK Result
0.7.79 10.0.404 Build succeeds, CS9057 only, no CHT diagnostics
0.7.75 10.0.404 CHT001 error, CHT002 warning
0.7.79 11.0.100 CHT001 error, CHT002 warning
Additional context

Proposed fix:

  • Pin Microsoft.CodeAnalysis.Analyzers, Microsoft.CodeAnalysis.CSharp and Microsoft.CodeAnalysis.CSharp.Workspaces in Directory.Packages.props to 5.9.0. A lower version would also work if the analyzers use no newer Roslyn API, and it would also cover older .NET 10 SDK bands.
  • Make dependabot ignore that group, so the reference does not follow the newest compiler again.
  • Optionally, add a CI check that builds a CHT001 sample with the oldest supported SDK and expects the error.

Workaround until a fixed release: build with the .NET 11 SDK, or stay on Threading.Analyzers 0.7.75.

Dominant language
C#
Stars
8
Forks
2
Avg merge
1d 12h
Merged PRs (30d)
22

Getting set up

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 CryptoHives/Foundation

All issues in CryptoHives/Foundation

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.