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
- Update ProgrammaticSuppressionInfoWrapper for Roslyn 4.10 Fixes #1175 — committed to sharwell/roslyn-sdk by sharwell 2 years ago
- [Microsoft.Android.Sdk.Analysis] Add Unit Tests for Code Analyzers (#9492) Context: 715a36af86c68bac623a4174477165bb14b4c371 Context: https://github.com/dotnet/roslyn-sdk/issues/1175 Commit 715a3... — committed to dotnet/android by dellis1972 2 years ago
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:
I can verify that upgrading from
1.1.1to1.1.3-beta1.24423.1has 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).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.