• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CodeAnalysis.ParseOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.CodeAnalysis.ParseOptions的典型用法代码示例。如果您正苦于以下问题:C# ParseOptions类的具体用法?C# ParseOptions怎么用?C# ParseOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParseOptions类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了ParseOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestMissing

 protected virtual void TestMissing(
     string initial,
     ParseOptions parseOptions,
     Func<dynamic, dynamic> nodeLocator = null)
 {
     TestMissing(initial, parseOptions, null, nodeLocator);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:7,代码来源:AbstractCodeActionTest.cs


示例2: TestAnnotations

        private void TestAnnotations(
            string expectedText,
            IList<TextSpan> expectedSpans,
            SyntaxNode fixedRoot,
            string annotationKind,
            bool compareTokens,
            ParseOptions parseOptions = null)
        {
            expectedSpans = expectedSpans ?? new List<TextSpan>();
            var annotatedTokens = fixedRoot.GetAnnotatedNodesAndTokens(annotationKind).Select(n => (SyntaxToken)n).ToList();

            Assert.Equal(expectedSpans.Count, annotatedTokens.Count);

            if (expectedSpans.Count > 0)
            {
                var expectedTokens = TokenUtilities.GetTokens(TokenUtilities.GetSyntaxRoot(expectedText, GetLanguage(), parseOptions));
                var actualTokens = TokenUtilities.GetTokens(fixedRoot);

                for (var i = 0; i < Math.Min(expectedTokens.Count, actualTokens.Count); i++)
                {
                    var expectedToken = expectedTokens[i];
                    var actualToken = actualTokens[i];

                    var actualIsConflict = annotatedTokens.Contains(actualToken);
                    var expectedIsConflict = expectedSpans.Contains(expectedToken.Span);
                    Assert.Equal(expectedIsConflict, actualIsConflict);
                }
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:AbstractCodeActionOrUserDiagnosticTest.cs


示例3: VerifyAnalyzer

        public static void VerifyAnalyzer(string path, DiagnosticAnalyzer diagnosticAnalyzer, ParseOptions options = null,
            params MetadataReference[] additionalReferences)
        {
            var file = new FileInfo(path);
            var parseOptions = GetParseOptionsAlternatives(options, file);

            using (var workspace = new AdhocWorkspace())
            {
                var document = GetDocument(file, GeneratedAssemblyName, workspace, additionalReferences);
                var project = document.Project;

                foreach (var parseOption in parseOptions)
                {
                    if (parseOption != null)
                    {
                        project = project.WithParseOptions(parseOption);
                    }

                    var compilation = project.GetCompilationAsync().Result;
                    var diagnostics = GetDiagnostics(compilation, diagnosticAnalyzer);
                    var expected = ExpectedIssues(compilation.SyntaxTrees.First()).ToList();

                    foreach (var diagnostic in diagnostics)
                    {
                        var line = diagnostic.GetLineNumberToReport();
                        expected.Should().Contain(line);
                        expected.Remove(line);
                    }

                    expected.Should().BeEquivalentTo(Enumerable.Empty<int>());
                }
            }
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:33,代码来源:Verifier.cs


示例4: Create

        public static DocumentState Create(
            DocumentInfo info,
            ParseOptions options,
            HostLanguageServices language,
            SolutionServices services)
        {
            var textSource = info.TextLoader != null
                ? CreateRecoverableText(info.TextLoader, info.Id, services)
                : CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, Encoding.UTF8), VersionStamp.Default, info.FilePath));

            var treeSource = CreateLazyFullyParsedTree(
                textSource,
                GetSyntaxTreeFilePath(info),
                options,
                languageServices: language);

            // remove any initial loader so we don't keep source alive
            info = info.WithTextLoader(null);

            return new DocumentState(
                languageServices: language,
                solutionServices: services,
                info: info,
                options: options,
                textSource: textSource,
                treeSource: treeSource);
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:27,代码来源:DocumentState.cs


示例5: Test

        private void Test(string markup, bool isMissing, bool isLine, ParseOptions options = null)
        {
            int? position;
            TextSpan? expectedSpan;
            string source;
            MarkupTestFile.GetPositionAndSpan(markup, out source, out position, out expectedSpan);
            var tree = SyntaxFactory.ParseSyntaxTree(source, options);

            TextSpan breakpointSpan;
            bool hasBreakpoint = BreakpointSpans.TryGetBreakpointSpan(tree, position.Value, CancellationToken.None, out breakpointSpan);

            if (isLine)
            {
                Assert.True(hasBreakpoint);
                Assert.True(breakpointSpan.Length == 0);
            }
            else if (isMissing)
            {
                Assert.False(hasBreakpoint);
            }
            else
            {
                Assert.True(hasBreakpoint);
                Assert.Equal(expectedSpan.Value, breakpointSpan);
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:26,代码来源:BreakpointSpansTests.cs


示例6: GetCodeGenerationOptions

 private static CodeGenerationOptions GetCodeGenerationOptions(
     EnvDTE.vsCMAccess access, ParseOptions parseOptions)
 {
     var generateDefaultAccessibility = (access & EnvDTE.vsCMAccess.vsCMAccessDefault) == 0;
     return new CodeGenerationOptions(
         generateDefaultAccessibility: generateDefaultAccessibility,
         parseOptions: parseOptions);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:8,代码来源:AbstractCodeModelObject_CodeGen.cs


示例7: CommonGetObjectData

        protected static void CommonGetObjectData(ParseOptions options, SerializationInfo info, StreamingContext context)
        {
            //public readonly SourceCodeKind Kind;
            info.AddValue("Kind", options.Kind, typeof(SourceCodeKind));

            //public readonly DocumentationMode DocumentationMode;
            info.AddValue("DocumentationMode", options.DocumentationMode, typeof(DocumentationMode));
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:8,代码来源:SerializableParseOptions.cs


示例8: SetOptionsCore

 private void SetOptionsCore(CompilationOptions newCompilationOptions, ParseOptions newParseOptions)
 {
     lock (_gate)
     {
         _currentCompilationOptions = newCompilationOptions;
         _currentParseOptions = newParseOptions;
     }
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:8,代码来源:AbstractProject_Options.cs


示例9: TestHostSolution

 public TestHostSolution(
     HostLanguageServices languageServiceProvider,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     params MetadataReference[] references)
     : this(new TestHostProject(languageServiceProvider, compilationOptions, parseOptions, references))
 {
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:TestHostSolution.cs


示例10: TestMissing

 protected void TestMissing(
     string initialMarkup,
     ParseOptions parseOptions,
     IDictionary<OptionKey, object> options = null,
     string fixAllActionEquivalenceKey = null)
 {
     TestMissing(initialMarkup, parseOptions, compilationOptions: null, options:options, fixAllActionEquivalenceKey: fixAllActionEquivalenceKey);
 }
开发者ID:RipCurrent,项目名称:roslyn,代码行数:8,代码来源:AbstractCodeActionOrUserDiagnosticTest.cs


示例11: CreateWorkspaceFromFilesAsync

 /// <param name="files">Can pass in multiple file contents with individual source kind: files will be named test1.vb, test2.vbx, etc.</param>
 public static Task<TestWorkspace> CreateWorkspaceFromFilesAsync(
     string[] files,
     ParseOptions[] parseOptions = null,
     CompilationOptions compilationOptions = null,
     ExportProvider exportProvider = null)
 {
     return TestWorkspaceFactory.CreateWorkspaceFromFilesAsync(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:9,代码来源:VisualBasicWorkspaceFactory.cs


示例12: CreateWorkspaceFromFiles

 /// <param name="files">Can pass in multiple file contents: files will be named test1.vb, test2.vb, etc. and additional metadata references</param>
 public static TestWorkspace CreateWorkspaceFromFiles(
     string[] files,
     ParseOptions parseOptions = null,
     CompilationOptions compilationOptions = null,
     ExportProvider exportProvider = null,
     string[] metadataReferences = null)
 {
     return TestWorkspaceFactory.CreateWorkspaceFromFiles(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider, metadataReferences);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:10,代码来源:VisualBasicWorkspaceFactory.cs


示例13: CreateWorkspaceFromFileAsync

 public static Task<TestWorkspace> CreateWorkspaceFromFileAsync(
     string file,
     ParseOptions parseOptions = null,
     CompilationOptions compilationOptions = null,
     ExportProvider exportProvider = null,
     string[] metadataReferences = null)
 {
     return CreateWorkspaceFromFilesAsync(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:9,代码来源:VisualBasicWorkspaceFactory.cs


示例14: TestMissingAsync

 protected Task TestMissingAsync(
     string initialMarkup,
     ParseOptions parseOptions,
     IDictionary<OptionKey, object> options = null,
     string fixAllActionEquivalenceKey = null,
     object fixProviderData = null)
 {
     return TestMissingAsync(initialMarkup, parseOptions, compilationOptions: null, options: options, fixAllActionEquivalenceKey: fixAllActionEquivalenceKey, fixProviderData: fixProviderData);
 }
开发者ID:rgani,项目名称:roslyn,代码行数:9,代码来源:AbstractCodeActionOrUserDiagnosticTest.cs


示例15: Test

 protected void Test(
     string initial,
     string expected,
     ParseOptions parseOptions,
     int index = 0,
     bool compareTokens = true,
     Func<dynamic, dynamic> nodeLocator = null,
     IDictionary<OptionKey, object> options = null)
 {
     Test(initial, expected, parseOptions, null, index, compareTokens, nodeLocator, options);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:11,代码来源:AbstractCodeActionTest.cs


示例16: GetSyntaxRoot

 internal static SyntaxNode GetSyntaxRoot(string expectedText, string language, ParseOptions options = null)
 {
     if (language == LanguageNames.CSharp)
     {
         return CS.SyntaxFactory.ParseCompilationUnit(expectedText, options: (CS.CSharpParseOptions)options);
     }
     else
     {
         return VB.SyntaxFactory.ParseCompilationUnit(expectedText, options: (VB.VisualBasicParseOptions)options);
     }
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:11,代码来源:TokenUtilities.cs


示例17: CreateLazyFullyParsedTree

 private static ValueSource<TreeAndVersion> CreateLazyFullyParsedTree(
     ValueSource<TextAndVersion> newTextSource,
     string filePath,
     ParseOptions options,
     HostLanguageServices languageServices,
     PreservationMode mode = PreservationMode.PreserveValue)
 {
     return new AsyncLazy<TreeAndVersion>(
         c => FullyParseTreeAsync(newTextSource, filePath, options, languageServices, mode, c),
         cacheResult: true);
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:11,代码来源:DocumentState.cs


示例18: EqualsHelper

        protected bool EqualsHelper(ParseOptions other)
        {
            if (object.ReferenceEquals(other, null))
            {
                return false;
            }

            return
                this.Kind == other.Kind &&
                this.DocumentationMode == other.DocumentationMode &&
                (this.PreprocessorSymbolNames == null ? other.PreprocessorSymbolNames == null : this.PreprocessorSymbolNames.SequenceEqual(other.PreprocessorSymbolNames, StringComparer.Ordinal));
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:12,代码来源:ParseOptions.cs


示例19: SetOptions

        /// <summary>
        /// Sets the given compilation and parse options.
        /// </summary>
        protected void SetOptions(CompilationOptions newCompilationOptions, ParseOptions newParseOptions)
        {
            this.UpdateRuleSetError(this.RuleSetFile);

            // Set options.
            CurrentCompilationOptions = newCompilationOptions;
            CurrentParseOptions = newParseOptions;

            if (_pushingChangesToWorkspaceHosts)
            {
                this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnOptionsChanged(Id, newCompilationOptions, newParseOptions));
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:16,代码来源:AbstractProject_Options.cs


示例20: DocumentState

 private DocumentState(
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     DocumentInfo info,
     ParseOptions options,
     ValueSource<TextAndVersion> textSource,
     ValueSource<TreeAndVersion> treeSource)
     : base(solutionServices, info, textSource)
 {
     _languageServices = languageServices;
     _options = options;
     _treeSource = treeSource;
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:13,代码来源:DocumentState.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeAnalysis.Project类代码示例发布时间:2022-05-26
下一篇:
C# CodeAnalysis.MetadataReferenceResolver类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap