本文整理汇总了C#中Microsoft.CodeAnalysis.Document.GetOption方法的典型用法代码示例。如果您正苦于以下问题:C# Document.GetOption方法的具体用法?C# Document.GetOption怎么用?C# Document.GetOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Document
的用法示例。
在下文中一共展示了Document.GetOption方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnforceAsync
public async Task<Solution> EnforceAsync(Document document)
{
if (document == null) { throw new ArgumentNullException(nameof(document)); }
IReadOnlyList<string> headerComments = document.GetOption(HeaderComments);
string newLineText = document.GetOption(GlobalOptions.NewLineText);
SyntaxTriviaList commentTrivia = this.commentCache.GetOrAdd(
headerComments, c => BuildCommentTrivia(headerComments, newLineText));
SyntaxNode syntaxRoot = await document.GetSyntaxRootAsync();
if (syntaxRoot.HasLeadingTrivia)
{
SyntaxTriviaList leadingTrivia = syntaxRoot.GetLeadingTrivia();
if (!leadingTrivia.IsEquivalentTo(commentTrivia))
{
Log.WriteInformation("{0}: Rewriting non-conforming header comment", document.Name);
syntaxRoot = syntaxRoot.WithLeadingTrivia().WithLeadingTrivia(commentTrivia);
document = document.WithSyntaxRoot(syntaxRoot);
}
}
else if (commentTrivia.Count > 0)
{
Log.WriteInformation("{0}: Adding missing header comment", document.Name);
syntaxRoot = syntaxRoot.WithLeadingTrivia(commentTrivia);
document = document.WithSyntaxRoot(syntaxRoot);
}
return document.Project.Solution;
}
示例2: IsMatchAsync
public async Task<bool> IsMatchAsync(Document document)
{
SemanticModel semanticModel = await document.GetSemanticModelAsync();
var matcher = new AttributeSyntaxMatcher(document.GetOption(AttributeNames), semanticModel);
matcher.Visit(await document.GetSyntaxRootAsync());
return matcher.HasMatch;
}
示例3: EnforceAsync
public async Task<Solution> EnforceAsync(Document document)
{
if (document == null) { throw new ArgumentNullException(nameof(document)); }
SemanticModel semanticModel = await document.GetSemanticModelAsync();
var syntaxRewriter = new ImplicitVariableSyntaxRewriter(
document.GetOption(EnforceForEachStatements), semanticModel);
SyntaxNode oldRoot = await document.GetSyntaxRootAsync();
SyntaxNode newRoot = syntaxRewriter.Visit(oldRoot);
if (oldRoot != newRoot)
{
Log.WriteInformation("{0}: Correcting implicit variable declarations", document.Name);
document = document.WithSyntaxRoot(newRoot);
}
return document.Project.Solution;
}
示例4: UsingTriviaFixer
public UsingTriviaFixer(Document document)
{
this.newLineTrivia = SyntaxFactory.EndOfLine(document.GetOption(GlobalOptions.NewLineText));
}
示例5: EnforceAsync
public Task<Solution> EnforceAsync(Document document)
{
document.GetOption(GlobalOptions.NewLineText).Should().Be(
NewLineText, "Unexpected newLineText global option value");
onComponentExecuted(typeof(TestRule2), document.Name);
return Task.FromResult(document.Project.Solution);
}
示例6: IsMatchAsync
public Task<bool> IsMatchAsync(Document document)
{
document.GetOption(BooleanOption).Should().Be(
TestMatcherBooleanOption, "Unexpected boolean option value");
onComponentExecuted(typeof(TestMatcher), document.Name);
return Task.FromResult(isMatch(document.Name));
}