当前位置: 首页>>代码示例>>C#>>正文


C# Document.GetOption方法代码示例

本文整理汇总了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;
        }
开发者ID:nicholjy,项目名称:stylize,代码行数:30,代码来源:HeaderCommentStyleRule.cs

示例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;
        }
开发者ID:nicholjy,项目名称:stylize,代码行数:9,代码来源:AttributeDocumentMatcher.cs

示例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;
        }
开发者ID:nicholjy,项目名称:stylize,代码行数:19,代码来源:AmbiguousImplicitVariableStyleRule.cs

示例4: UsingTriviaFixer

 public UsingTriviaFixer(Document document)
 {
     this.newLineTrivia = SyntaxFactory.EndOfLine(document.GetOption(GlobalOptions.NewLineText));
 }
开发者ID:nicholjy,项目名称:stylize,代码行数:4,代码来源:OverQualifiedNameStyleRule.cs

示例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);
            }
开发者ID:nicholjy,项目名称:stylize,代码行数:9,代码来源:StylizeEngineTests.cs

示例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));
            }
开发者ID:nicholjy,项目名称:stylize,代码行数:9,代码来源:StylizeEngineTests.cs


注:本文中的Microsoft.CodeAnalysis.Document.GetOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。