提交 a97815e2 编写于 作者: P Petr Houska

Fix only attributes can cause refactorings crash (#37837).

上级 f42de27b
......@@ -527,6 +527,22 @@ public class Class1
await TestMissingAsync<MethodDeclarationSyntax>(testText);
}
[Fact]
[WorkItem(37837, "https://github.com/dotnet/roslyn/issues/37837")]
public async Task TestEmptyParameter()
{
var testText = @"
using System;
public class Class1
{
static void foo({|result:[Test][||]
|} {
}
}";
await TestAsync<ParameterSyntax>(testText);
}
[Fact]
[WorkItem(37584, "https://github.com/dotnet/roslyn/issues/37584")]
public async Task TestMissingEmptyMember2()
......
......@@ -542,11 +542,22 @@ public bool IsOnHeader<THoleSyntax>(int position, SyntaxNode ownerOfHeader, Synt
protected int GetStartOfNodeExcludingAttributes(SyntaxNode node)
{
var attributeLists = GetAttributeLists(node);
var start = attributeLists.LastOrDefault()?.GetLastToken().GetNextToken().SpanStart ??
node.SpanStart;
var attributeList = GetAttributeLists(node);
if (attributeList.Any())
{
var endOfAttributeLists = attributeList.Last().Span.End;
var afterAttributesToken = node.FindTokenOnRightOfPosition(endOfAttributeLists);
var endOfNode = node.Span.End;
var startOfTokenAfterAttributes = afterAttributesToken.Span.Start;
var startOfNodeWithoutAttributes = endOfNode >= startOfTokenAfterAttributes
? afterAttributesToken.Span.Start
: endOfNode;
return startOfNodeWithoutAttributes;
}
return start;
return node.SpanStart;
}
public abstract SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode node);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册