Closed jinujoseph closed 6 years ago
I encountered an error with very similar stack trace.
I'm not able to see the code behind the link so I will post my repro here.
public class Foo
{
public void Bar(int value)
{
void Local(int value2)
{
Bar(value, value2); // Select arguments and click Ctrl+.
}
}
}
I've also stumbled upon this today.
Version used: 15.6.0 Preview 5.0
System.InvalidOperationException : Failed to compare two elements in the array. ---> System.InvalidOperationException : Shouldn't reach here
at Roslyn.Utilities.Contract.FailWithReturn[T](String message)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ParameterVariableSymbol.CompareTo(IMethodSymbol left,IMethodSymbol right)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ParameterVariableSymbol.CompareTo(ParameterVariableSymbol other)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ParameterVariableSymbol.CompareTo(VariableSymbol right)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.VariableSymbol.Compare(VariableSymbol left,VariableSymbol right,INamedTypeSymbol cancellationTokenType)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.VariableInfo.<>c__DisplayClass24_0.<SortVariables>b__0(VariableInfo v1,VariableInfo v2)
at System.Array.FunctorComparer`1.Compare(T x,T y)
at System.Collections.Generic.ArraySortHelper`1.SwapIfGreater(T[] keys,IComparer`1 comparer,Int32 a,Int32 b)
at System.Collections.Generic.ArraySortHelper`1.IntroSort(T[] keys,Int32 lo,Int32 hi,Int32 depthLimit,IComparer`1 comparer)
at System.Collections.Generic.ArraySortHelper`1.IntrospectiveSort(T[] keys,Int32 left,Int32 length,IComparer`1 comparer)
at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys,Int32 index,Int32 length,IComparer`1 comparer)
--- Ende der inneren Ausnahmestapelüberwachung ---
at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys,Int32 index,Int32 length,IComparer`1 comparer)
at System.Array.Sort[T](T[] array,Int32 index,Int32 length,IComparer`1 comparer)
at System.Collections.Generic.List`1.Sort(Comparison`1 comparison)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.VariableInfo.SortVariables(Compilation compilation,List`1 list)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.GetMethodParameters(ICollection`1 variableInfo)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.GetSignatureInformation(DataFlowAnalysis dataFlowAnalysisData,IDictionary`2 variableInfoMap,Boolean isInExpressionOrHasReturnStatement)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.AnalyzeAsync(<Unknown Parameter>)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync(<Unknown Parameter>)
at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService`3.ExtractMethodAsync[TValidator,TExtractor,TResult](<Unknown Parameter>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.GetCodeActionAsync(<Unknown Parameter>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameter>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameter>)
Repro:
using System;
class Program
{
public void TestMethod(string outer)
{
string GetPermissionFilter(string inner)
{
$$if (outer == "")
{
return inner;$$
}
throw new Exception();
}
}
}
Select the textspan between $$
and it will immediately show that an error has been encountered (no need to CTRL + .
)
Do we have a tracking issue for this one?
System.InvalidOperationException : Matrix does not contain Key 'C7'.
at Roslyn.Utilities.Contract.ThrowIfFalse(Boolean condition,String message)
at Microsoft.CodeAnalysis.ExtractMethod.ExtractMethodMatrix.GetVariableStyle(Boolean captured,Boolean dataFlowIn,Boolean dataFlowOut,Boolean alwaysAssigned,Boolean variableDeclared,Boolean readInside,Boolean writtenInside,Boolean readOutside,Boolean writtenOutside,Boolean unsafeAddressTaken)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.GetVariableStyle(Dictionary`2 symbolMap,ISymbol symbol,SemanticModel model,ITypeSymbol type,Boolean captured,Boolean dataFlowIn,Boolean dataFlowOut,Boolean alwaysAssigned,Boolean variableDeclared,Boolean readInside,Boolean writtenInside,Boolean readOutside,Boolean writtenOutside,Boolean unsafeAddressTaken)
at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.GenerateVariableInfoMap(SemanticModel model,DataFlowAnalysis dataFlowAnalysisData,Dictionary`2 symbolMap)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.AnalyzeAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService`3.ExtractMethodAsync[TValidator,TExtractor,TResult](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.GetCodeActionAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
Also hit this: https://github.com/dotnet/roslyn/issues/24967.
@alrz Please file a new bug for that.
Found the one. it's already filed here: https://github.com/dotnet/roslyn/issues/23352
also reported at Link
resolved in 15.7.P2 via link
Reported by @Rick Krause[MSFT]
I tried to select this section of code to do an extract method and got this:
stack System.InvalidOperationException : Failed to compare two elements in the array. ---> System.InvalidOperationException : Shouldn't reach here at Roslyn.Utilities.Contract.FailWithReturn[T](String message) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ParameterVariableSymbol.CompareTo(IMethodSymbol left,IMethodSymbol right) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ParameterVariableSymbol.CompareTo(ParameterVariableSymbol other) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ParameterVariableSymbol.CompareTo(VariableSymbol right) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.VariableSymbol.Compare(VariableSymbol left,VariableSymbol right,INamedTypeSymbol cancellationTokenType) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.VariableInfo.<>c__DisplayClass24_0.b__0(VariableInfo v1,VariableInfo v2)
at System.Array.FunctorComparer)
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.GetCodeActionAsync()
at async Microsoft.CodeAnalysis.CodeRefactorings.ExtractMethod.ExtractMethodCodeRefactoringProvider.ComputeRefactoringsAsync()
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync()
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
1.Compare(T x,T y) at System.Collections.Generic.ArraySortHelper
1.SwapIfGreater(T[] keys,IComparer1 comparer,Int32 a,Int32 b) at System.Collections.Generic.ArraySortHelper
1.IntroSort(T[] keys,Int32 lo,Int32 hi,Int32 depthLimit,IComparer1 comparer) at System.Collections.Generic.ArraySortHelper
1.IntrospectiveSort(T[] keys,Int32 left,Int32 length,IComparer1 comparer) at System.Collections.Generic.ArraySortHelper
1.Sort(T[] keys,Int32 index,Int32 length,IComparer1 comparer) --- End of inner exception stack trace --- at System.Collections.Generic.ArraySortHelper
1.Sort(T[] keys,Int32 index,Int32 length,IComparer1 comparer) at System.Array.Sort[T](T[] array,Int32 index,Int32 length,IComparer
1 comparer) at System.Collections.Generic.List1.Sort(Comparison
1 comparison) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.VariableInfo.SortVariables(Compilation compilation,List1 list) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.GetMethodParameters(ICollection
1 variableInfo) at Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.GetSignatureInformation(DataFlowAnalysis dataFlowAnalysisData,IDictionary2 variableInfoMap,Boolean isInExpressionOrHasReturnStatement) at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.Analyzer.AnalyzeAsync(<Unknown Parameters>) at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync(<Unknown Parameters>) at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService
3.ExtractMethodAsync[TValidator,TExtractor,TResult](