You may encounter the following known issues, which may include workarounds, mitigations, or expected resolution timeframes.
CA2009: Do not call ToImmutableCollection on an ImmutableCollection value
analyzer regressed in .NET 8 preview 1, the regression could cause a build failure if:
warning
level: dotnet_diagnostic.CA2009.severity = warning
(by default it is suggestion
)warning
level (by default it is warning
)<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
ToImmutableArray()
on an array instance, for example:public ImmutableArray<int> Method(int [] arr)
{
return arr.ToImmutableArray();
}
Then the build would fail with an error:
error AD0001: Analyzer 'Microsoft.NetCore.Analyzers.ImmutableCollections.DoNotCallToImmutableCollectionOnAnImmutableCollectionValueAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.ArrayTypeSymbol' to type 'Microsoft.CodeAnalysis.INamedTypeSymbol'.
Resolution
suggestion
or none
: dotnet_diagnostic.CA2009.severity = none
suggestion
or none
: dotnet_diagnostic.CA2009.severity = suggestion
For details about known issues, please refer to the individual repositories:
For details about known issues, please reference to the pinned issue in this repo.