protected static TPropertyDeclaration SetLeadingTrivia <TPropertyDeclaration>( ISyntaxFacts syntaxFacts, GetAndSetMethods getAndSetMethods, TPropertyDeclaration property ) where TPropertyDeclaration : SyntaxNode { var getMethodDeclaration = getAndSetMethods.GetMethodDeclaration; var setMethodDeclaration = getAndSetMethods.SetMethodDeclaration; var finalLeadingTrivia = getAndSetMethods.GetMethodDeclaration .GetLeadingTrivia() .ToList(); //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 AddParamListTriviaIfNeeded(syntaxFacts, getMethodDeclaration, finalLeadingTrivia); if (setMethodDeclaration == null) { return(property.WithLeadingTrivia(finalLeadingTrivia)); } finalLeadingTrivia.AddRange( setMethodDeclaration .GetLeadingTrivia() .SkipWhile(t => syntaxFacts.IsEndOfLineTrivia(t)) .Where(t => !t.IsDirective) ); //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 AddParamListTriviaIfNeeded(syntaxFacts, setMethodDeclaration, finalLeadingTrivia); return(property.WithLeadingTrivia(finalLeadingTrivia)); }
protected static string GetWarning(GetAndSetMethods getAndSetMethods) { if (OverridesMetadataSymbol(getAndSetMethods.GetMethod) || OverridesMetadataSymbol(getAndSetMethods.SetMethod)) { return(FeaturesResources.Warning_Method_overrides_symbol_from_metadata); } return(null); }
protected static TPropertyDeclaration SetLeadingTrivia <TPropertyDeclaration>( ISyntaxFacts syntaxFacts, GetAndSetMethods getAndSetMethods, TPropertyDeclaration property) where TPropertyDeclaration : SyntaxNode { var getMethodDeclaration = getAndSetMethods.GetMethodDeclaration; var setMethodDeclaration = getAndSetMethods.SetMethodDeclaration; if (setMethodDeclaration == null) { return(property.WithLeadingTrivia(getMethodDeclaration.GetLeadingTrivia())); } var finalLeadingTrivia = getAndSetMethods.GetMethodDeclaration.GetLeadingTrivia().ToList(); finalLeadingTrivia.AddRange( setMethodDeclaration.GetLeadingTrivia() .SkipWhile(t => syntaxFacts.IsEndOfLineTrivia(t)) .Where(t => !t.IsDirective)); return(property.WithLeadingTrivia(finalLeadingTrivia)); }