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


C# ParseOptions类代码示例

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


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

示例1: TestBraceHighlightingAsync

        protected async Task TestBraceHighlightingAsync(string markup, ParseOptions options = null)
        {
            using (var workspace = await CreateWorkspaceAsync(markup, options))
            {
                WpfTestCase.RequireWpfFact($"{nameof(AbstractBraceHighlightingTests)}.{nameof(TestBraceHighlightingAsync)} creates asynchronous taggers");

                var provider = new BraceHighlightingViewTaggerProvider(
                    workspace.GetService<IBraceMatchingService>(),
                    workspace.GetService<IForegroundNotificationService>(),
                    AggregateAsynchronousOperationListener.EmptyListeners);

                var testDocument = workspace.Documents.First();
                var buffer = testDocument.TextBuffer;
                var document = buffer.CurrentSnapshot.GetRelatedDocumentsWithChanges().FirstOrDefault();
                var context = new TaggerContext<BraceHighlightTag>(
                    document, buffer.CurrentSnapshot,
                    new SnapshotPoint(buffer.CurrentSnapshot, testDocument.CursorPosition.Value));
                await provider.ProduceTagsAsync_ForTestingPurposesOnly(context);

                var expectedHighlights = testDocument.SelectedSpans.Select(ts => ts.ToSpan()).OrderBy(s => s.Start).ToList();
                var actualHighlights = context.tagSpans.Select(ts => ts.Span.Span).OrderBy(s => s.Start).ToList();

                Assert.Equal(expectedHighlights, actualHighlights);
            }
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:AbstractBraceHighlightingTests.cs

示例2: Test

        private void Test(
            string markup,
            ParseOptions options,
            bool optionIsEnabled = true)
        {
            using (var workspace = CreateWorkspaceFromFile(markup, options))
            {
                var testDocument = workspace.Documents.Single();
                var expectedHighlightSpans = testDocument.SelectedSpans ?? new List<TextSpan>();
                expectedHighlightSpans = Sort(expectedHighlightSpans);
                var cursorSpan = testDocument.AnnotatedSpans["Cursor"].Single();
                var textSnapshot = testDocument.TextBuffer.CurrentSnapshot;
                var document = workspace.CurrentSolution.GetDocument(testDocument.Id);

                // If the position being tested is immediately following the keyword, 
                // we should get the token before this position to find the appropriate 
                // ancestor node.
                var highlighter = CreateHighlighter();

                var root = document.GetSyntaxRootAsync().Result;

                for (int i = 0; i <= cursorSpan.Length; i++)
                {
                    var position = cursorSpan.Start + i;
                    var highlightSpans = highlighter.GetHighlights(root, position, CancellationToken.None).ToList();
                    highlightSpans = Sort(highlightSpans);

                    CheckSpans(expectedHighlightSpans, highlightSpans);
                }
            }
        }
开发者ID:daking2014,项目名称:roslyn,代码行数:31,代码来源:AbstractKeywordHighlighterTests.cs

示例3: CompileAndVerify

 internal CompilationVerifier CompileAndVerify(
     string source,
     IEnumerable<MetadataReference> additionalRefs = null,
     IEnumerable<ModuleData> dependencies = null,
     Action<IModuleSymbol> sourceSymbolValidator = null,
     Action<PEAssembly> assemblyValidator = null,
     Action<IModuleSymbol> symbolValidator = null,
     SignatureDescription[] expectedSignatures = null,
     string expectedOutput = null,
     CompilationOptions options = null,
     ParseOptions parseOptions = null,
     bool verify = true)
 {
     return CompileAndVerify(
         sources: new string[] { source },
         additionalRefs: additionalRefs,
         dependencies: dependencies,
         sourceSymbolValidator: sourceSymbolValidator,
         assemblyValidator: assemblyValidator,
         symbolValidator: symbolValidator,
         expectedSignatures: expectedSignatures,
         expectedOutput: expectedOutput,
         options: options,
         parseOptions: parseOptions,
         verify: verify);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:26,代码来源:CommonTestBase.cs

示例4: TryParse

        /// <summary>
        /// Tries to parse the dataFields using the delimiter and fields. If true,
        /// result will hold an IStringConverter that can convert all valid input
        /// in the form of dataFields, only extracting fields.
        /// </summary>
        /// <param name="dataFields">Input string</param>
        /// <param name="delimiter">Seperator</param>
        /// <param name="fields">Required (conversion) fields</param>
        /// <param name="result">Converter</param>
        /// <param name="options">Parseoptions</param>
        /// <returns>Parse is possible</returns>
        public static Boolean TryParse(String dataFields, Char delimiter, String[] fields, out IStringConverter result, 
            ParseOptions options = ParseOptions.CleanupQuotes)
        {
            result = new DelimiterConverter(delimiter);

            var splittedDataFields = new Queue<String>(dataFields.Split(delimiter));
            var fieldsQueue = new Queue<String>(fields);

            while (fieldsQueue.Count > 0 && splittedDataFields.Count > 0)
            {
                var field = fieldsQueue.Peek();
                var data = splittedDataFields.Dequeue().Trim();

                if (options.HasFlag(ParseOptions.GlueStrings))
                    while (data.StartsWith("\"") && !data.EndsWith("\"") && splittedDataFields.Count > 0)
                        data = data + "," + splittedDataFields.Dequeue().Trim();

                if (options.HasFlag(ParseOptions.CleanupQuotes))
                    data = data.Replace("\"", "").Trim();

                (result as DelimiterConverter).PushMask(field == data);

                if (field == data)
                    fieldsQueue.Dequeue();
            }

            return fieldsQueue.Count == 0;
        }
开发者ID:SleeplessByte,项目名称:life-insights,代码行数:39,代码来源:DelimiterParser.cs

示例5: GenerateConstructorDeclaration

        internal static ConstructorDeclarationSyntax GenerateConstructorDeclaration(
            IMethodSymbol constructor, CodeGenerationDestination destination, 
            Workspace workspace, CodeGenerationOptions options, ParseOptions parseOptions)
        {
            options = options ?? CodeGenerationOptions.Default;

            var reusableSyntax = GetReuseableSyntaxNodeForSymbol<ConstructorDeclarationSyntax>(constructor, options);
            if (reusableSyntax != null)
            {
                return reusableSyntax;
            }

            bool hasNoBody = !options.GenerateMethodBodies;

            var declaration = SyntaxFactory.ConstructorDeclaration(
                attributeLists: AttributeGenerator.GenerateAttributeLists(constructor.GetAttributes(), options),
                modifiers: GenerateModifiers(constructor, options),
                identifier: CodeGenerationConstructorInfo.GetTypeName(constructor).ToIdentifierToken(),
                parameterList: ParameterGenerator.GenerateParameterList(constructor.Parameters, isExplicit: false, options: options),
                initializer: GenerateConstructorInitializer(constructor),
                body: hasNoBody ? null : GenerateBlock(constructor),
                semicolonToken: hasNoBody ? SyntaxFactory.Token(SyntaxKind.SemicolonToken) : default(SyntaxToken));

            declaration = UseExpressionBodyIfDesired(workspace, declaration, parseOptions);

            return AddCleanupAnnotationsTo(
                ConditionallyAddDocumentationCommentTo(declaration, constructor, options));
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:ConstructorGenerator.cs

示例6: GenerateConversionDeclarationWorker

        private static ConversionOperatorDeclarationSyntax GenerateConversionDeclarationWorker(
            IMethodSymbol method,
            CodeGenerationDestination destination,
            Workspace workspace,
            CodeGenerationOptions options,
            ParseOptions parseOptions)
        {
            var hasNoBody = !options.GenerateMethodBodies || method.IsExtern;

            var reusableSyntax = GetReuseableSyntaxNodeForSymbol<ConversionOperatorDeclarationSyntax>(method, options);
            if (reusableSyntax != null)
            {
                return reusableSyntax;
            }

            var operatorToken = SyntaxFactory.Token(SyntaxFacts.GetOperatorKind(method.MetadataName));
            var keyword = method.MetadataName == WellKnownMemberNames.ImplicitConversionName
                ? SyntaxFactory.Token(SyntaxKind.ImplicitKeyword)
                : SyntaxFactory.Token(SyntaxKind.ExplicitKeyword);

            var declaration = SyntaxFactory.ConversionOperatorDeclaration(
                attributeLists: AttributeGenerator.GenerateAttributeLists(method.GetAttributes(), options),
                modifiers: GenerateModifiers(method),
                implicitOrExplicitKeyword: keyword,
                operatorKeyword: SyntaxFactory.Token(SyntaxKind.OperatorKeyword),
                type: method.ReturnType.GenerateTypeSyntax(),
                parameterList: ParameterGenerator.GenerateParameterList(method.Parameters, isExplicit: false, options: options),
                body: hasNoBody ? null : StatementGenerator.GenerateBlock(method),
                semicolonToken: hasNoBody ? SyntaxFactory.Token(SyntaxKind.SemicolonToken) : new SyntaxToken());

            declaration = UseExpressionBodyIfDesired(workspace, declaration, parseOptions);

            return declaration;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:34,代码来源:ConversionGenerator.cs

示例7: GenerateMethodDeclarationWorker

        private static MethodDeclarationSyntax GenerateMethodDeclarationWorker(
            IMethodSymbol method, CodeGenerationDestination destination, 
            Workspace workspace, CodeGenerationOptions options, ParseOptions parseOptions)
        {
            var hasNoBody = !options.GenerateMethodBodies ||
                            destination == CodeGenerationDestination.InterfaceType ||
                            method.IsAbstract;

            var explicitInterfaceSpecifier = GenerateExplicitInterfaceSpecifier(method.ExplicitInterfaceImplementations);

            var returnType = method.ReturnsByRef
                ? method.ReturnType.GenerateRefTypeSyntax()
                : method.ReturnType.GenerateTypeSyntax();

            var methodDeclaration = SyntaxFactory.MethodDeclaration(
                attributeLists: GenerateAttributes(method, options, explicitInterfaceSpecifier != null),
                modifiers: GenerateModifiers(method, destination, options),
                returnType: returnType,
                explicitInterfaceSpecifier: explicitInterfaceSpecifier,
                identifier: method.Name.ToIdentifierToken(),
                typeParameterList: GenerateTypeParameterList(method, options),
                parameterList: ParameterGenerator.GenerateParameterList(method.Parameters, explicitInterfaceSpecifier != null, options),
                constraintClauses: GenerateConstraintClauses(method),
                body: hasNoBody ? null : StatementGenerator.GenerateBlock(method),
                expressionBody: default(ArrowExpressionClauseSyntax),
                semicolonToken: hasNoBody ? SyntaxFactory.Token(SyntaxKind.SemicolonToken) : new SyntaxToken());

            methodDeclaration = UseExpressionBodyIfDesired(workspace, methodDeclaration, parseOptions);

            return AddCleanupAnnotationsTo(methodDeclaration);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:31,代码来源:MethodGenerator.cs

示例8: WriteTo

        public override void WriteTo(ParseOptions options, ObjectWriter writer, CancellationToken cancellationToken)
        {
            WriteParseOptionsTo(options, writer, cancellationToken);

            var csharpOptions = (CSharpParseOptions)options;
            writer.WriteInt32((int)csharpOptions.LanguageVersion);
            writer.WriteValue(options.PreprocessorSymbolNames.ToArray());
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:8,代码来源:CSharpOptionsSerializationService.cs

示例9: CreateWorkspaceFromFileAsync

 protected override async Task<TestWorkspace> CreateWorkspaceFromFileAsync(string definition, ParseOptions parseOptions, CompilationOptions compilationOptions)
 {
     var workspace = await base.CreateWorkspaceFromFileAsync(definition, parseOptions, compilationOptions);
     workspace.Options = workspace.Options
         .WithChangedOption(AddImportOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp, true)
         .WithChangedOption(AddImportOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp, true);
     return workspace;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:AddUsingTests_NuGet.cs

示例10: 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:TerabyteX,项目名称:roslyn,代码行数:9,代码来源:VisualBasicWorkspaceFactory.cs

示例11: Parser

 /// <summary>
 /// Initializes a new instance of the <see cref="Parser"/> class.
 /// Returns the parser object that is used to store state throughout the
 /// process of parsing.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="options">The options.</param>
 protected Parser(Source source, ParseOptions options)
 {
     Source = source;
     Options = options ?? new ParseOptions();
     _lexToken = new Lexer(source);
     PrevEnd = 0;
     Token = _lexToken.NextToken();
 }
开发者ID:amarant,项目名称:GraphQLSharp,代码行数:15,代码来源:Parser.cs

示例12: CreateWorkspaceFromFileAsync

 /// <summary>
 /// Creates a single buffer in a workspace.
 /// </summary>
 /// <param name="content">Lines of text, the buffer contents</param>
 internal static Task<TestWorkspace> CreateWorkspaceFromFileAsync(
     string language,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     string content)
 {
     return CreateWorkspaceFromFilesAsync(language, compilationOptions, parseOptions, new[] { content });
 }
开发者ID:TerabyteX,项目名称:roslyn,代码行数:12,代码来源:TestWorkspaceFactory.cs

示例13: CreateAsync

        public static async Task<ChangeSignatureTestState> CreateAsync(string markup, string languageName, ParseOptions parseOptions = null)
        {
            var workspace = languageName == LanguageNames.CSharp
                  ? await CSharpWorkspaceFactory.CreateWorkspaceFromFileAsync(markup, exportProvider: s_exportProvider, parseOptions: (CSharpParseOptions)parseOptions)
                  : await VisualBasicWorkspaceFactory.CreateWorkspaceFromFileAsync(markup, exportProvider: s_exportProvider, parseOptions: parseOptions, compilationOptions: new VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary));

            return new ChangeSignatureTestState(workspace);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:8,代码来源:ChangeSignatureTestState.cs

示例14: TestWithAccessorCodeStyleOptionsOnAsync

 internal async Task TestWithAccessorCodeStyleOptionsOnAsync(
     string initialMarkup, string expectedMarkup,
     int index = 0, bool compareTokens = true,
     ParseOptions parseOptions = null,
     bool withScriptOption = false)
 {
     await TestAsync(initialMarkup, expectedMarkup, parseOptions, null,
         index, compareTokens, options: AccessorOptionsOn, withScriptOption: withScriptOption);
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:9,代码来源:ImplementInterfaceTests.cs

示例15: 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:TerabyteX,项目名称:roslyn,代码行数:9,代码来源:VisualBasicWorkspaceFactory.cs


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