本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax.GetTrailingTrivia方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDeclarationSyntax.GetTrailingTrivia方法的具体用法?C# PropertyDeclarationSyntax.GetTrailingTrivia怎么用?C# PropertyDeclarationSyntax.GetTrailingTrivia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax
的用法示例。
在下文中一共展示了PropertyDeclarationSyntax.GetTrailingTrivia方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNewProperty
static PropertyDeclarationSyntax CreateNewProperty(PropertyDeclarationSyntax property)
{
// create new auto property
var accessorDeclList = new SyntaxList<AccessorDeclarationSyntax>().Add(SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration).WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken))).Add(SyntaxFactory.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration).WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)));
var newProperty = property.WithAccessorList(SyntaxFactory.AccessorList(accessorDeclList)).WithTrailingTrivia(property.GetTrailingTrivia()).WithAdditionalAnnotations(Formatter.Annotation);
return newProperty;
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:7,代码来源:ReplacePropertyWithBackingFieldWithAutoPropertyCodeRefactoringProvider.cs
示例2: IncorrectSigSuppDiagAsync
private async Task<Document> IncorrectSigSuppDiagAsync(Document document, PropertyDeclarationSyntax declaration, CancellationToken c)
{
SyntaxGenerator generator = SyntaxGenerator.GetGenerator(document);
var type = generator.IdentifierName("ImmutableArray<DiagnosticDescriptor>");
var getAccessorStatements = new SyntaxList<SyntaxNode>();
foreach (var accessor in declaration.AccessorList.Accessors)
{
if (accessor.IsKind(SyntaxKind.GetAccessorDeclaration))
{
getAccessorStatements = accessor.Body.Statements;
break;
}
}
var newPropertyDecl = generator.PropertyDeclaration("SupportedDiagnostics", type, accessibility: Accessibility.Public, modifiers: DeclarationModifiers.Override, getAccessorStatements: getAccessorStatements).WithLeadingTrivia(declaration.GetLeadingTrivia()).WithTrailingTrivia(declaration.GetTrailingTrivia());
newPropertyDecl = newPropertyDecl.RemoveNode((newPropertyDecl as PropertyDeclarationSyntax).AccessorList.Accessors[1], 0);
return await ReplaceNode(declaration, newPropertyDecl, document);
}
示例3: CreateNewProperty
static PropertyDeclarationSyntax CreateNewProperty(PropertyDeclarationSyntax property)
{
var getter = property.AccessorList.Accessors.FirstOrDefault (a => a.IsKind (SyntaxKind.GetAccessorDeclaration));
var setter = property.AccessorList.Accessors.FirstOrDefault (a => a.IsKind (SyntaxKind.SetAccessorDeclaration));
// create new auto property
var accessorDeclList = new SyntaxList<AccessorDeclarationSyntax>().Add(SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration).WithModifiers (getter.Modifiers).WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)))
.Add(SyntaxFactory.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration).WithModifiers (setter.Modifiers).WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)));
var newProperty = property.WithAccessorList(SyntaxFactory.AccessorList(accessorDeclList)).WithTrailingTrivia(property.GetTrailingTrivia()).WithAdditionalAnnotations(Formatter.Annotation);
return newProperty;
}
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:11,代码来源:ReplacePropertyWithBackingFieldWithAutoPropertyCodeRefactoringProvider.cs