提交 0756bdd0 编写于 作者: B Brian Freeman

introduce local variable for parameter list node

上级 0faec5cd
......@@ -48,14 +48,15 @@ private static bool OverridesMetadataSymbol(IMethodSymbol method)
var getMethodDeclaration = getAndSetMethods.GetMethodDeclaration;
var setMethodDeclaration = getAndSetMethods.SetMethodDeclaration;
var finalLeadingTrivia = getAndSetMethods.GetMethodDeclaration.GetLeadingTrivia().ToList();
var paramList = syntaxFacts.GetParameterList(getMethodDeclaration);
//If there is a comment on the same line as the method it is contained in trailing trivia for the parameter list
//If it's there we need to add it to the final comments
//this is to fix issue 42699, https://github.com/dotnet/roslyn/issues/42699
if (getMethodDeclaration.ChildNodes().Any(n => n.RawKind == syntaxFacts.SyntaxKinds.ParameterList && n.GetTrailingTrivia().Any(t => !syntaxFacts.IsWhitespaceOrEndOfLineTrivia(t))))
if (paramList.GetTrailingTrivia().Any(t => !syntaxFacts.IsWhitespaceOrEndOfLineTrivia(t)))
{
//we have a meaningful comment on the parameter list so add it to the trivia list
finalLeadingTrivia.AddRange(getMethodDeclaration.ChildNodes().Where(n => n.RawKind == syntaxFacts.SyntaxKinds.ParameterList).First().GetTrailingTrivia());
finalLeadingTrivia.AddRange(paramList.GetTrailingTrivia());
}
if (setMethodDeclaration == null)
......@@ -70,10 +71,11 @@ private static bool OverridesMetadataSymbol(IMethodSymbol method)
//If there is a comment on the same line as the method it is contained in trailing trivia for the parameter list
//If it's there we need to add it to the final comments
if (setMethodDeclaration.ChildNodes().Any(n => n.RawKind == syntaxFacts.SyntaxKinds.ParameterList && n.GetTrailingTrivia().Any(t => !syntaxFacts.IsWhitespaceOrEndOfLineTrivia(t))))
paramList = syntaxFacts.GetParameterList(setMethodDeclaration);
if (paramList.GetTrailingTrivia().Any(t => !syntaxFacts.IsWhitespaceOrEndOfLineTrivia(t)))
{
//we have a meaningful comment on the parameter list so add it to the trivia list
finalLeadingTrivia.AddRange(setMethodDeclaration.ChildNodes().Where(n => n.RawKind == syntaxFacts.SyntaxKinds.ParameterList).First().GetTrailingTrivia());
finalLeadingTrivia.AddRange(paramList.GetTrailingTrivia());
}
return property.WithLeadingTrivia(finalLeadingTrivia);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册