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
publicstaticclassTestClass{publicstaticvoidTest<T>(ITesttester){// crashtester.Test(typeof(IEnumerable<>));// doesn't crashtester.Test(typeof(IEnumerable<string>));}}publicinterfaceITest{voidTest<T>();// doesn't crash if commentedvoidTest(stringtype);voidTest(Typetype,paramsType[]typeArgs);}
Expected behavior
No errors when generic constrain not satisfied
Actual behavior
Proposed code change trigger compilation error
IOperation: Invocation
1> SyntaxNode: tester.Test(typeof(IEnumerable< ... [InvocationExpressionSyntax]@[113..147) (5,8)-(5,42)
1> System.InvalidOperationException: Operation is not valid due to the current state of the object.
1> at Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.Construct(ImmutableArray`1 typeArguments)
1> at Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.MethodSymbol.Microsoft.CodeAnalysis.IMethodSymbol.Construct(ITypeSymbol[] typeArguments)
1> at Microsoft.NetCore.Analyzers.Usage.PreferGenericOverloadsAnalyzer.<>c__DisplayClass6_0.<AnalyzeInvocation>g__IsApplicableGenericOverload|0(IMethodSymbol method)
1> at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
1> at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
1> at Microsoft.NetCore.Analyzers.Usage.PreferGenericOverloadsAnalyzer.AnalyzeInvocation(OperationAnalysisContext context)
1> at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteOperationAction>b__53_0(ValueTuple`2 data)
1> at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)
The text was updated successfully, but these errors were encountered:
Analyzer
Diagnostic ID: CA2263:
Prefer generic overload when type is known
Analyzer source
NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers
Version: 9.0.0-preview.24122.1
Describe the bug
CA2263 crashes for open-generic types
Steps To Reproduce
Expected behavior
No errors when generic constrain not satisfied
Actual behavior
Proposed code change trigger compilation error
The text was updated successfully, but these errors were encountered: