本文整理汇总了C#中AnalysisContext.ConfigureGeneratedCodeAnalysis方法的典型用法代码示例。如果您正苦于以下问题:C# AnalysisContext.ConfigureGeneratedCodeAnalysis方法的具体用法?C# AnalysisContext.ConfigureGeneratedCodeAnalysis怎么用?C# AnalysisContext.ConfigureGeneratedCodeAnalysis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnalysisContext
的用法示例。
在下文中一共展示了AnalysisContext.ConfigureGeneratedCodeAnalysis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public override void Initialize(AnalysisContext analysisContext)
{
analysisContext.EnableConcurrentExecution();
analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
analysisContext.RegisterCompilationAction(AnalyzeCompilation);
}
示例2: 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);
});
}
示例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);
}
示例5: Initialize
public override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.RegisterCompilationStartAction(OnCompilationStart);
}
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:7,代码来源:DoNotUseEnumerableMethodsOnIndexableCollectionsInsteadUseTheCollectionDirectly.cs
示例6: Initialize
/// <inheritdoc/>
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(DocumentationTriviaAction, SyntaxKind.SingleLineDocumentationCommentTrivia);
}
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1612ElementParameterDocumentationMustMatchElementParameters.cs
示例7: Initialize
/// <inheritdoc/>
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSymbolAction(Analyzer.HandleFieldDeclaration, SymbolKind.Field);
}
开发者ID:EdwinEngelen,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1303ConstFieldNamesMustBeginWithUpperCaseLetter.cs
示例8: Initialize
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.RegisterSymbolAction(
(symbol) =>
{
Diagnostic diagnostic;
if (TryGetDiagnostic(symbol, out diagnostic))
{
symbol.ReportDiagnostic(diagnostic);
}
},
new SymbolKind[] {
SymbolKind.Method
}
);
context.RegisterSyntaxNodeAction(
(nodeContext) =>
{
Diagnostic diagnostic;
if (TryGetDiagnostic(nodeContext, out diagnostic))
{
nodeContext.ReportDiagnostic(diagnostic);
}
},
new SyntaxKind[] {
SyntaxKind.AnonymousMethodExpression,
SyntaxKind.ParenthesizedLambdaExpression,
SyntaxKind.SimpleLambdaExpression
}
);
}
示例9: Initialize
public override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.RegisterCompilationStartAction(compilationStartContext =>
{
var immutableArrayType = compilationStartContext.Compilation.GetTypeByMetadataName(ImmutableArrayMetadataName);
if (immutableArrayType == null)
{
return;
}
compilationStartContext.RegisterOperationAction(operationContext =>
{
var invocation = (IInvocationExpression)operationContext.Operation;
if (invocation.IsInvalid ||
invocation.TargetMethod?.Name != "ToImmutableArray")
{
return;
}
var receiverType = invocation.GetReceiverType(operationContext.Compilation, beforeConversion: true, cancellationToken: operationContext.CancellationToken);
if (receiverType != null &&
receiverType.DerivesFromOrImplementsAnyConstructionOf(immutableArrayType))
{
operationContext.ReportDiagnostic(Diagnostic.Create(Rule, invocation.Syntax.GetLocation()));
}
}, OperationKind.InvocationExpression);
});
}
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:31,代码来源:DoNotCallToImmutableArrayOnAnImmutableArrayValue.cs
示例10: Initialize
/// <inheritdoc/>
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(BinaryExpressionAction, HandledBinaryExpressionKinds);
}
示例11: 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);
});
}
示例12: Initialize
/// <inheritdoc/>
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(EnumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration);
}
示例13: 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));
}
});
});
}
示例14: 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);
});
});
}
示例15: 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);
}