Place caret inside "[]"
````
using System;
class AAttribute : Attribute
{
}
public class TestClass
{
public void Test()
{
void Local<[]> // place caret inside []
}
}
````
System.ArgumentOutOfRangeException : Specified argument was out of the range of valid values.
Parameter name: position
at Microsoft.CodeAnalysis.SyntaxNode.FindTokenCore(Int32 position,Boolean findInsideTrivia)
at Microsoft.CodeAnalysis.Shared.Extensions.SyntaxNodeExtensions.GetInitialToken(SyntaxNode root,Int32 position,Boolean includeSkipped,Boolean includeDirectives,Boolean includeDocumentationComments)
at Microsoft.CodeAnalysis.Shared.Extensions.SyntaxNodeExtensions.FindTokenOnRightOfPosition(SyntaxNode root,Int32 position,Boolean includeSkipped,Boolean includeDirectives,Boolean includeDocumentationComments)
at Microsoft.CodeAnalysis.LanguageServices.AbstractSyntaxFactsService.GetStartOfNodeExcludingAttributes(SyntaxNode node)
at Microsoft.CodeAnalysis.LanguageServices.AbstractSyntaxFactsService.IsOnHeader[THoleSyntax](Int32 position,SyntaxNode ownerOfHeader,SyntaxNodeOrToken lastTokenOrNodeOfHeader,ImmutableArray`1 holes)
at Microsoft.CodeAnalysis.LanguageServices.AbstractSyntaxFactsService.IsOnHeader(Int32 position,SyntaxNode ownerOfHeader,SyntaxNodeOrToken lastTokenOrNodeOfHeader)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxFactsService.IsOnParameterHeader(SyntaxNode root,Int32 position,SyntaxNode& parameter)
at Microsoft.CodeAnalysis.CodeRefactorings.AbstractRefactoringHelpersService`2.<ExtractNodesInHeader>d__7.MoveNext()
at System.Linq.Enumerable.<OfTypeIterator>d__95`1.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Microsoft.CodeAnalysis.CodeRefactorings.AbstractRefactoringHelpersService`2.AddNonHiddenCorrectTypeNodes[TSyntaxNode](IEnumerable`1 nodes,ArrayBuilder`1 resultBuilder,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.CodeRefactorings.AbstractRefactoringHelpersService`2.GetRelevantNodesAsync[TExpressionSyntax,TArgumentSyntax,TSyntaxNode](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringContextExtensions.GetRelevantNodesAsync[TSyntaxNode](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringContextExtensions.TryGetRelevantNodeAsync[TSyntaxNode](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ReplacePropertyWithMethods.AbstractReplacePropertyWithMethodsService`5.GetPropertyDeclarationAsync[TIdentifierNameSyntax,TExpressionSyntax,TCrefSyntax,TStatementSyntax,TPropertySyntax](<Unknown Parameters>)
at async Microsoft.CodeAnalysis.ReplacePropertyWithMethods.ReplacePropertyWithMethodsCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
tagging @petrroll
What version? Some fixes were not backported IIRC. In any case, this time I'm really busy with other stuff (moving, another internship, master thesis) so I most probably won't be available to fix it.
The stacktrace seems to suggest (unless I'm reading it wrong) that it's pre-fix because GetStartOfNodeExcludingAttributes(SyntaxNode node) takes only one arg while current roslyn master version takes two (explicitly takes root which IMHO should mitigate this issue). I also very mildly remember doing a fix of such nature.
The fix I was talking about was probably this one: https://github.com/dotnet/roslyn/pull/38544/files
As I mentioned I'm a bit busy with other stuff and actually don't have any of my devices with VS / Roslyn available so I won't be able to verify it's fixed anytime soon.
Reproducible with the latest Visual Studio release (16.3.9) but not reproducible with VS Preview 16.4.0 preview 4
I was able to reproduce this issue when placing square brackets inside of an incomplete method:
public Task FooAsync( )
^~insert "[[]]" here. (press "[" twice)
There were documented 6 crashes happening at the same time after this, and they're all similar to this one.
Reproduced with VS 16.3.8 & 16.3.9
ReplaceMethodWithPropertyCodeRefactoringProvider
ReplacePropertyWithMethodsCodeRefactoringProvider
CSharpIntroduceUsingStatementCodeRefactoringProvider
CSharpConvertAnonymousTypeToClassCodeRefactoringProvider
CSharpInitializeMemberFromParameterCodeRefactoringProvider
CSharpAddParameterCheckCodeRefactoringProvider
If someone can verify even @hizamakura's repro is fixed can we close it as fixed & not backported?
Verified @hizamakura repro doesn't happen in 16.4. Marked with the milestone.