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


C# AnalysisContext.EnableConcurrentExecution方法代码示例

本文整理汇总了C#中AnalysisContext.EnableConcurrentExecution方法的典型用法代码示例。如果您正苦于以下问题:C# AnalysisContext.EnableConcurrentExecution方法的具体用法?C# AnalysisContext.EnableConcurrentExecution怎么用?C# AnalysisContext.EnableConcurrentExecution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnalysisContext的用法示例。


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

示例1: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationAction(AnalyzeCompilation);
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:7,代码来源:MarkAssembliesWithComVisible.cs

示例2: Initialize

        public override void Initialize(AnalysisContext context)
        {
            context.EnableConcurrentExecution();
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            context.RegisterCompilationStartAction(compilationContext =>
            {
                var exportAttributes = new List<INamedTypeSymbol>();

                foreach (var mefNamespace in s_mefNamespaces)
                {
                    var exportAttribute = compilationContext.Compilation.GetTypeByMetadataName(mefNamespace + ".ExportAttribute");

                    if (exportAttribute == null)
                    {
                        // We don't need to check assemblies unless they're referencing both versions of MEF, so we're done
                        return;
                    }

                    exportAttributes.Add(exportAttribute);
                }

                compilationContext.RegisterSymbolAction(c => AnalyzeSymbol(c, exportAttributes), SymbolKind.NamedType);
            });
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:25,代码来源:DoNotMixAttributesFromDifferentVersionsOfMEF.cs

示例3: Initialize

        /// <inheritdoc/>
        public override void Initialize(AnalysisContext context)
        {
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
            context.EnableConcurrentExecution();

            context.RegisterSyntaxNodeAction(DoStatementAction, SyntaxKind.DoStatement);
        }
开发者ID:EdwinEngelen,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1511WhileDoFooterMustNotBePrecededByBlankLine.cs

示例4: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterSymbolAction(
                symbolAnalysisContext =>
                {
                    ISymbol symbol = symbolAnalysisContext.Symbol;
                    if (!symbol.ContainingType.IsGenericType ||
                        symbol.DeclaredAccessibility != Accessibility.Public ||
                        !symbol.IsStatic)
                    {
                        return;
                    }

                    var methodSymbol = symbol as IMethodSymbol;
                    if (methodSymbol != null &&
                        (methodSymbol.IsAccessorMethod() ||
                         (methodSymbol.MethodKind == MethodKind.UserDefinedOperator &&
                          (methodSymbol.Name == WellKnownMemberNames.EqualityOperatorName ||
                           methodSymbol.Name == WellKnownMemberNames.InequalityOperatorName))))
                    {
                        return;
                    }

                    symbolAnalysisContext.ReportDiagnostic(symbol.CreateDiagnostic(Rule, symbol.Name));
                }, SymbolKind.Method, SymbolKind.Property);
        }
开发者ID:duracellko,项目名称:roslyn-analyzers,代码行数:29,代码来源:DoNotDeclareStaticMembersOnGenericTypes.cs

示例5: Initialize

        /// <inheritdoc/>
        public override void Initialize(AnalysisContext context)
        {
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
            context.EnableConcurrentExecution();

            context.RegisterSyntaxNodeAction(RegionDirectiveTriviaAction, SyntaxKind.RegionDirectiveTrivia);
        }
开发者ID:EdwinEngelen,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1124DoNotUseRegions.cs

示例6: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterSyntaxNodeAction<SyntaxKind>(AnalyzeNode, SyntaxKind.ThrowStatement);
        }
开发者ID:duracellko,项目名称:roslyn-analyzers,代码行数:7,代码来源:CSharpRethrowToPreserveStackDetails.cs

示例7: Initialize

        public override void Initialize(AnalysisContext context)
        {
            context.EnableConcurrentExecution();
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            context.RegisterSyntaxNodeAction(AnalyzeXmlAttribute, SyntaxKind.XmlTextAttribute);
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:7,代码来源:CSharpAvoidUsingCrefTagsWithAPrefix.cs

示例8: Initialize

        /// <inheritdoc/>
        public override void Initialize(AnalysisContext context)
        {
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
            context.EnableConcurrentExecution();

            context.RegisterSyntaxNodeAction(EnumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration);
        }
开发者ID:EdwinEngelen,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1602EnumerationItemsMustBeDocumented.cs

示例9: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(
                (context) =>
                {
                    INamedTypeSymbol dllImportType = context.Compilation.GetTypeByMetadataName("System.Runtime.InteropServices.DllImportAttribute");
                    if (dllImportType == null)
                    {
                        return;
                    }

                    INamedTypeSymbol marshalAsType = context.Compilation.GetTypeByMetadataName("System.Runtime.InteropServices.MarshalAsAttribute");
                    if (marshalAsType == null)
                    {
                        return;
                    }

                    INamedTypeSymbol stringBuilderType = context.Compilation.GetTypeByMetadataName("System.Text.StringBuilder");
                    if (stringBuilderType == null)
                    {
                        return;
                    }

                    INamedTypeSymbol unmanagedType = context.Compilation.GetTypeByMetadataName("System.Runtime.InteropServices.UnmanagedType");
                    if (unmanagedType == null)
                    {
                        return;
                    }

                    context.RegisterSymbolAction(new SymbolAnalyzer(dllImportType, marshalAsType, stringBuilderType, unmanagedType).AnalyzeSymbol, SymbolKind.Method);
                });
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:35,代码来源:PInvokeDiagnosticAnalyzer.cs

示例10: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(
                compilationContext =>
                {
                    Compilation compilation = compilationContext.Compilation;
                    ITypeSymbol argumentExceptionType = compilation.GetTypeByMetadataName("System.ArgumentException");

                    if (argumentExceptionType == null)
                    {
                        return;
                    }

                    compilationContext.RegisterOperationBlockStartAction(
                        operationBlockStartContext =>
                        {
                            operationBlockStartContext.RegisterOperationAction(
                                operationContext => AnalyzeObjectCreation(
                                    operationContext,
                                    operationBlockStartContext.OwningSymbol,
                                    argumentExceptionType),
                                OperationKind.ObjectCreationExpression);
                        });
                });
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:28,代码来源:InstantiateArgumentExceptionsCorrectly.cs

示例11: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(compilationContext =>
            {
                INamedTypeSymbol conditionalAttributeSymbol = WellKnownTypes.ConditionalAttribute(compilationContext.Compilation);

                compilationContext.RegisterOperationBlockAction(context =>
                {
                    var method = context.OwningSymbol as IMethodSymbol;
                    if (method == null)
                    {
                        return;
                    }

                    if (!method.IsFinalizer())
                    {
                        return;
                    }

                    if (IsEmptyFinalizer(context.OperationBlocks, conditionalAttributeSymbol))
                    {
                        context.ReportDiagnostic(context.OwningSymbol.CreateDiagnostic(Rule));
                    }
                });
            });
        }
开发者ID:duracellko,项目名称:roslyn-analyzers,代码行数:29,代码来源:RemoveEmptyFinalizers.cs

示例12: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterSymbolAction(symbolContext =>
            {
                var method = (IMethodSymbol)symbolContext.Symbol;
                if (!IsEventLikeNameCandidate(method.Name))
                {
                    Debug.Assert(!HasEventLikeName(method), "fast check failed but eventual check succeeds?");
                    return;
                }

                // Bail out for implicitly declared methods, overridden methods, interface implementations, constructors and finalizers (FxCop compat).
                if (method.IsImplicitlyDeclared ||
                    method.IsOverride ||
                    method.IsImplementationOfAnyInterfaceMember() ||
                    method.IsConstructor() ||
                    method.IsFinalizer())
                {
                    return;
                }

                if (HasEventLikeName(method))
                {
                    // Consider making '{0}' an event.
                    var diagnostic = method.CreateDiagnostic(Rule, method.Name);
                    symbolContext.ReportDiagnostic(diagnostic);
                }
            }, SymbolKind.Method);
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:32,代码来源:UseEventsWhereAppropriate.cs

示例13: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(
               (context) =>
               {
                   INamedTypeSymbol iCollectionType = WellKnownTypes.ICollection(context.Compilation);
                   INamedTypeSymbol genericICollectionType = WellKnownTypes.GenericICollection(context.Compilation);
                   INamedTypeSymbol iEnumerableType = WellKnownTypes.IEnumerable(context.Compilation);
                   INamedTypeSymbol genericIEnumerableType = WellKnownTypes.GenericIEnumerable(context.Compilation);
                   INamedTypeSymbol iListType = WellKnownTypes.IList(context.Compilation);
                   INamedTypeSymbol genericIListType = WellKnownTypes.GenericIList(context.Compilation);

                   if (iCollectionType == null && genericICollectionType == null &&
                       iEnumerableType == null && genericIEnumerableType == null &&
                       iListType == null && genericIListType == null)
                   {
                       return;
                   }

                   context.RegisterSymbolAction(c => AnalyzeSymbol(c,
                                                iCollectionType, genericICollectionType,
                                                iEnumerableType, genericIEnumerableType,
                                                iListType, genericIListType),
                                                SymbolKind.NamedType);
               });
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:29,代码来源:CollectionsShouldImplementGenericInterface.cs

示例14: Initialize

        /// <inheritdoc/>
        public override void Initialize(AnalysisContext context)
        {
            context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
            context.EnableConcurrentExecution();

            context.RegisterSyntaxNodeAction(TypeParameterConstraintClauseAction, SyntaxKind.TypeParameterConstraintClause);
        }
开发者ID:EdwinEngelen,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1127GenericTypeConstraintsMustBeOnOwnLine.cs

示例15: Initialize

        public override void Initialize(AnalysisContext analysisContext)
        {
            analysisContext.EnableConcurrentExecution();
            analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

            analysisContext.RegisterCompilationStartAction(
                (context) =>
                {
                    INamedTypeSymbol eventHandler = WellKnownTypes.EventHandler(context.Compilation);
                    if (eventHandler == null)
                    {
                        return;
                    }

                    INamedTypeSymbol genericEventHandler = WellKnownTypes.GenericEventHandler(context.Compilation);
                    if (genericEventHandler == null)
                    {
                        return;
                    }

                    INamedTypeSymbol eventArgs = WellKnownTypes.EventArgs(context.Compilation);
                    if (eventArgs == null)
                    {
                        return;
                    }

                    INamedTypeSymbol comSourceInterfacesAttribute = WellKnownTypes.ComSourceInterfaceAttribute(context.Compilation);
                    if (comSourceInterfacesAttribute == null)
                    {
                        return;
                    }

                    context.RegisterSymbolAction(GetAnalyzer(context.Compilation, eventHandler, genericEventHandler, eventArgs, comSourceInterfacesAttribute).AnalyzeSymbol, SymbolKind.Event);
                });
        }
开发者ID:duracellko,项目名称:roslyn-analyzers,代码行数:35,代码来源:UseGenericEventHandlerInstances.cs


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