Closed gsantopaolo closed 1 year ago
This looks like https://github.com/dotnet/roslyn/issues/17165, which should have been fixed already... Did you have any local functions? @agocke were there other symptoms to look for here?
look in as part of https://github.com/dotnet/roslyn/issues/23352
@dpoeschl I'm getting this occasionally with 15.5.7 and I do have a couple local functions. Posting stack trace because I don't think I saw other reports that mention an exception with the "Failed to compare two elements in the array." message. I can't reproduce but it seems to happen during code highlighting inside the local function (or maybe copy to clipboard after highlighting). I see it maybe once a week. Never happened on 15.5.6 or earlier working with the same code.
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)
--- End of inner exception stack trace ---
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 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)
I don't see any prism hits here for these stacks. Closing out as we haven't heard from anyone on this in 5+ years.
While developing C# with 2017 15.4.4 i got an error message never seen before: And here is the stack trace copied from the popup message
_System.InvalidOperationException : Unexpected false
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)
at async Microsoft.CodeAnalysis.ExtractMethod.MethodExtractor.ExtractMethodAsync()
at async Microsoft.CodeAnalysis.ExtractMethod.AbstractExtractMethodService`3.ExtractMethodAsync[TValidator,TExtractor,TResult]()
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)_
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(I was trying to figure out what was causing the issue and at the end I discovered that everything works well on the editor since code is like int the snipped below:
if I uncomment line entity.Usrname user.UserName I got the error on the editor
@davkean asked to add it as a roslyn issue