Bug
CC0043 "ChangeAnyToAll" throws an exception with user created (i.e. non-LINQ) Any() and All() methods with v1.0.3 on VS2015, if they have a params parameter.
This code:
class TypeName
{
private TypeName xs;
void Foo() => xs.All();
public void All(params string[] strings)
{
xs.All();
}
}
Throws the following exception:
Severity Code Description Project File Line Suppression State Detail Description
Warning AD0001 Analyzer 'CodeCracker.CSharp.Refactoring.ChangeAnyToAllAnalyzer' threw an exception of type 'System.ArgumentOutOfRangeException' with message 'Specified argument was out of the range of valid values.
Parameter name: index'. ScratchPad 1 Active Analyzer 'CodeCracker.CSharp.Refactoring.ChangeAnyToAllAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: ScratchPad
SyntaxTree: C:\Projects\ScratchPad\Program.cs
SyntaxNode: xs.All() [InvocationExpressionSyntax]@[399..407) (19,26)-(19,34)
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
at Microsoft.CodeAnalysis.SeparatedSyntaxList`1.get_Item(Int32 index)
at CodeCracker.CSharp.Refactoring.ChangeAnyToAllAnalyzer.IsLambdaWithoutBody(InvocationExpressionSyntax invocation)
at CodeCracker.CSharp.Refactoring.ChangeAnyToAllAnalyzer.GetCorrespondingDiagnostic(SemanticModel semanticModel, InvocationExpressionSyntax invocation)
at CodeCracker.CSharp.Refactoring.ChangeAnyToAllAnalyzer.AnalyzeInvocation(SyntaxNodeAnalysisContext context)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass42_1`1.<ExecuteSyntaxNodeAction>b__1()
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info)
-----
'.
The same exception happens if my method is called Any().
At a guess (haven't checked the source code), CC0043 assumes Any() and All() are LINQ methods, and throws when my user Any() and All() takes unexpected parameters (in this case params.)
Bug
CC0043 "ChangeAnyToAll" throws an exception with user created (i.e. non-LINQ)
Any()andAll()methods with v1.0.3 on VS2015, if they have aparamsparameter.This code:
Throws the following exception:
The same exception happens if my method is called
Any().At a guess (haven't checked the source code), CC0043 assumes
Any()andAll()are LINQ methods, and throws when my userAny()andAll()takes unexpected parameters (in this caseparams.)