roslyn-sdk: `Microsoft.CodeAnalysis.Testing.Lightup.ProgrammaticSuppressionInfoWrapper` throws `TypeInitializationException`

Microsoft.CodeAnalysis.Testing.Lightup.ProgrammaticSuppressionInfoWrapper throws TypeInitializationException when there are suppressed diagnostics, from Microsoft.CodeAnalysis version 4.10.0

It tries to make a property accessor of Roslyn’s ProgrammaticSuppressionInfo.Suppressions.

It had a type ImmutableHashSet<(string Id, LocalizableString Justification)> before, https://github.com/dotnet/roslyn/blob/db71ffa0e75bab0e69fad83259469cb471f1edbd/src/Compilers/Core/Portable/Diagnostic/ProgrammaticSuppressionInfo.cs#L15 but it’s been changed to ImmutableArray<Suppression> after this PR https://github.com/dotnet/roslyn/pull/71207 https://github.com/dotnet/roslyn/blob/969c5177a3fe0a13171c561b45b2d808b9659e56/src/Compilers/Core/Portable/Diagnostic/ProgrammaticSuppressionInfo.cs#L16C16-L16C43

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

For those who might’ve been waiting for @sharwell to provide the answer, I found the feed to get pre-release NuGet packages via another source. Add this to your NuGet config:

<configuration>
  <packageSources>
     <add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

I can verify that upgrading from 1.1.1 to 1.1.3-beta1.24423.1 has fixed the security issues.

You should also be aware, if you’re writing suppressors, that they have also fixed the issue where suppressors used to remove the diagnostic from the diagnostics list rather than marking it as suppressed, so you may need to (re-)add expected diagnostics for the analyzer you’re suppressing, marked with .WithIsSuppressed(true) in your tests. This was how it was previously working in Roslyn 3.11, but somewhere in the 4.x tree they broke it, and now it’s back to the original behavior (which is better for testability, IMO).

Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit

This library is obsolete. The final version of this library we published produces build warnings saying the code should migrate to the generic one instead.

@dellis1972 They haven’t released a fixed version. I’m still waiting for information about where their CI packages live, since that appears to be the recommendation based on the fact that they don’t seem to be able to release a fixed version.

Same, would be nice for a new package release for this so I can stop holding back package upgrades.