You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CA2009 is crashing when calling ToImmutableArray() on an array creation expression.
Steps To Reproduce
$ cat tests.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AnalysisLevel>latest-all</AnalysisLevel>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
$ cat Program.cs
using System.Collections.Immutable;
var values = new int[0].ToImmutableArray();
Expected behavior
No exception.
Actual behavior
CSC : warning AD0001: Analyzer 'Microsoft.NetCore.Analyzers.ImmutableCollections.DoNotCallToImmutableCollectionOnAnImmutableCollectionValue Analyzer' 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'.'.
The text was updated successfully, but these errors were encountered:
Analyzer
Diagnostic ID: CA2009:
Do not call ToImmutableCollection on an ImmutableCollection value
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 8.0.100-preview.1.23115.2
Describe the bug
CA2009 is crashing when calling
ToImmutableArray()
on an array creation expression.Steps To Reproduce
Expected behavior
No exception.
Actual behavior
CSC : warning AD0001: Analyzer 'Microsoft.NetCore.Analyzers.ImmutableCollections.DoNotCallToImmutableCollectionOnAnImmutableCollectionValue Analyzer' 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'.'.
The text was updated successfully, but these errors were encountered: