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


C# CodeAnalysis.ParseOptions类代码示例

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


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


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