219 references to Compilation
Aspire.Hosting.Analyzers (1)
AppHostAnalyzer.cs (1)
29
var compilation = context.
Compilation
;
ILLink.RoslynAnalyzer (3)
COMAnalyzer.cs (1)
35
var compilation = context.
Compilation
;
DynamicallyAccessedMembersAnalyzer.cs (1)
98
var dataFlowAnalyzerContext = DataFlowAnalyzerContext.Create (context.Options, context.
Compilation
, RequiresAnalyzers.Value);
RequiresAnalyzerBase.cs (1)
48
var compilation = context.
Compilation
;
Microsoft.Analyzers.Extra (20)
AsyncCallInsideUsingBlockAnalyzer.cs (4)
28
var taskType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.Task");
29
var taskOfTType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.Task`1");
30
var valueTaskType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.ValueTask");
31
var valueTaskOfTType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.ValueTask`1");
AsyncMethodWithoutCancellation.cs (8)
28
var taskType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.Task");
29
var taskOfTType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.Task`1");
30
var valueTaskType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.ValueTask");
31
var valueTaskOfTType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.Tasks.ValueTask`1");
42
var cancellationTokenType = compilationContext.
Compilation
.GetTypeByMetadataName("System.Threading.CancellationToken");
43
var httpContextType = compilationContext.
Compilation
.GetTypeByMetadataName("Microsoft.AspNetCore.Http.HttpContext");
45
compilationContext.
Compilation
.GetTypeByMetadataName("Microsoft.AspNetCore.Connections.ConnectionContext");
47
compilationContext.
Compilation
.GetTypeByMetadataName("System.ObsoleteAttribute");
CallAnalysis\CallAnalyzer.cs (1)
34
var reg = new Registrar(state, compilationStartContext.
Compilation
);
CoalesceAnalyzer.cs (1)
28
if (compilationStartContext.
Compilation
.IsNet6OrGreater())
ConditionalAccessAnalyzer.cs (2)
28
if (compilationStartContext.
Compilation
.IsNet6OrGreater())
30
var maybeNull = compilationStartContext.
Compilation
.GetTypeByMetadataName("System.Diagnostics.CodeAnalysis.MaybeNullAttribute");
MakeExeTypesInternalAnalyzer.cs (4)
62
var type = compilationStartContext.
Compilation
.GetTypeByMetadataName(name);
72
var type = compilationStartContext.
Compilation
.GetTypeByMetadataName(name);
82
var type = compilationStartContext.
Compilation
.GetTypeByMetadataName(name);
89
if (compilationStartContext.
Compilation
.Options.OutputKind == OutputKind.ConsoleApplication)
Microsoft.Analyzers.Local (3)
ApiLifecycle\ApiLifecycleAnalyzer.cs (1)
36
var compilation = start.
Compilation
;
ApiLifecycle\ModelLoader.cs (1)
23
var compilation = context.
Compilation
;
CallAnalysis\CallAnalyzer.cs (1)
30
var reg = new Registrar(state, compilationStartContext.
Compilation
);
Microsoft.AspNetCore.Analyzers (2)
StartupAnalyzer.cs (2)
31
var symbols = new StartupSymbols(context.
Compilation
);
39
var entryPoint = context.
Compilation
.GetEntryPoint(context.CancellationToken);
Microsoft.AspNetCore.App.Analyzers (7)
Authorization\AddAuthorizationBuilderAnalyzer.cs (1)
30
var wellKnownTypes = WellKnownTypes.GetOrCreate(context.
Compilation
);
Http\HeaderDictionaryAddAnalyzer.cs (1)
28
var wellKnownTypes = WellKnownTypes.GetOrCreate(context.
Compilation
);
Http\RequestDelegateReturnTypeAnalyzer.cs (1)
25
var compilation = context.
Compilation
;
Mvc\MvcAnalyzer.cs (1)
36
var compilation = context.
Compilation
;
RenderTreeBuilder\RenderTreeBuilderAnalyzer.cs (1)
27
var compilation = context.
Compilation
;
RouteHandlers\RouteHandlerAnalyzer.cs (1)
41
var compilation = context.
Compilation
;
WebApplicationBuilder\WebApplicationBuilderAnalyzer.cs (1)
38
var compilation = context.
Compilation
;
Microsoft.AspNetCore.Components.Analyzers (2)
ComponentParameterAnalyzer.cs (1)
42
if (!ComponentSymbols.TryCreate(context.
Compilation
, out var symbols))
ComponentParameterUsageAnalyzer.cs (1)
31
if (!ComponentSymbols.TryCreate(context.
Compilation
, out var symbols))
Microsoft.AspNetCore.Components.SdkAnalyzers (2)
ComponentParameterAnalyzer.cs (1)
36
if (!ComponentSymbols.TryCreate(context.
Compilation
, out var symbols))
ComponentParameterUsageAnalyzer.cs (1)
31
if (!ComponentSymbols.TryCreate(context.
Compilation
, out var symbols))
Microsoft.AspNetCore.Mvc.Analyzers (4)
AttributesShouldNotBeAppliedToPageModelAnalyzer.cs (1)
25
var typeCache = new TypeCache(context.
Compilation
);
TagHelpersInCodeBlocksAnalyzer.cs (1)
29
if (!SymbolCache.TryCreate(context.
Compilation
, out var symbolCache))
TopLevelParameterNameAnalyzer.cs (1)
26
if (!SymbolCache.TryCreate(context.
Compilation
, out var typeCache))
ViewFeaturesAnalyzerContext.cs (1)
26
private INamedTypeSymbol GetType(string name) => Context.
Compilation
.GetTypeByMetadataName(name);
Microsoft.AspNetCore.Mvc.Api.Analyzers (2)
ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzer.cs (1)
25
if (!ApiControllerSymbolCache.TryCreate(context.
Compilation
, out var symbolCache))
ApiConventionAnalyzer.cs (1)
27
if (!ApiControllerSymbolCache.TryCreate(context.
Compilation
, out var symbolCache))
Microsoft.CodeAnalysis (1)
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.cs (1)
45
var analyzer = new CompilationAnalyzer(c.
Compilation
);
Microsoft.CodeAnalysis.CodeStyle (29)
src\Analyzers\Core\Analyzers\AddAccessibilityModifiers\AbstractAddAccessibilityModifiersDiagnosticAnalyzer.cs (1)
28
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderDiagnosticAnalyzer.cs (1)
40
context.RegisterSyntaxTreeAction(treeContext => HandleSyntaxTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (1)
32
context.RegisterSyntaxTreeAction(treeContext => AnalyzeSyntaxTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
44
var compilation = context.
Compilation
;
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
39
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesDiagnosticAnalyzer.cs (1)
34
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\OrderModifiers\AbstractOrderModifiersDiagnosticAnalyzer.cs (1)
38
context.RegisterSyntaxTreeAction(treeContext => AnalyzeSyntaxTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (2)
60
var suppressMessageAttributeType = context.
Compilation
.SuppressMessageAttributeType();
66
RegisterAttributeSyntaxAction(context, new CompilationAnalyzer(context.
Compilation
, suppressMessageAttributeType));
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
189
var compilationAnalyzer = new CompilationAnalyzer(compilationStartContext.
Compilation
, analyzer);
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (4)
51
var attributeSetForMethodsToIgnore = ImmutableHashSet.CreateRange(GetAttributesForMethodsToIgnore(context.
Compilation
).WhereNotNull());
52
var eventsArgType = context.
Compilation
.EventArgsType();
53
var deserializationConstructorCheck = new DeserializationConstructorCheck(context.
Compilation
);
54
var iCustomMarshaler = context.
Compilation
.GetTypeByMetadataName(typeof(ICustomMarshaler).FullName!);
src\Analyzers\Core\Analyzers\SimplifyLinqExpression\AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs (1)
59
if (TryGetEnumerableTypeSymbol(context.
Compilation
, out var enumerableType) &&
src\Analyzers\Core\Analyzers\UseCollectionInitializer\AbstractUseCollectionInitializerDiagnosticAnalyzer.cs (3)
98
if (!AreCollectionInitializersSupported(context.
Compilation
))
101
var ienumerableType = context.
Compilation
.IEnumerableType();
118
var expressionType = context.
Compilation
.ExpressionOfTType();
src\Analyzers\Core\Analyzers\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs (3)
34
var objectType = context.
Compilation
.GetSpecialType(SpecialType.System_Object);
35
if (objectType != null && IsLanguageVersionSupported(context.
Compilation
))
44
var unconstraintedGenericSupported = IsUnconstrainedGenericSupported(context.
Compilation
);
src\Analyzers\Core\Analyzers\UseNullPropagation\AbstractUseNullPropagationDiagnosticAnalyzer.cs (3)
90
if (!ShouldAnalyze(context.
Compilation
))
93
var expressionType = context.
Compilation
.ExpressionOfTType();
95
var objectType = context.
Compilation
.GetSpecialType(SpecialType.System_Object);
src\Analyzers\Core\Analyzers\UseObjectInitializer\AbstractUseObjectInitializerDiagnosticAnalyzer.cs (1)
69
if (!AreObjectInitializersSupported(context.
Compilation
))
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (1)
33
if (HashCodeAnalyzer.TryGetAnalyzer(c.
Compilation
, out var analyzer))
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (2)
60
if (!IsSupported(startContext.
Compilation
))
65
var expressionType = startContext.
Compilation
.ExpressionOfTType();
src\Analyzers\Core\Analyzers\ValidateFormatString\AbstractValidateFormatStringDiagnosticAnalyzer.cs (1)
73
var formatProviderType = startContext.
Compilation
.GetTypeByMetadataName(typeof(System.IFormatProvider).FullName!);
Microsoft.CodeAnalysis.CSharp.CodeStyle (40)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToProgramMainDiagnosticAnalyzer.cs (1)
35
if (!IsApplication(context.
Compilation
))
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToTopLevelStatementsDiagnosticAnalyzer.cs (2)
38
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9 ||
39
!IsApplication(context.
Compilation
))
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs (1)
35
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (1)
50
var compilation = compilationContext.
Compilation
;
src\Analyzers\CSharp\Analyzers\MakeAnonymousFunctionStatic\MakeAnonymousFunctionStaticDiagnosticAnalyzer.cs (1)
32
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9)
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticDiagnosticAnalyzer.cs (1)
32
if (MakeLocalFunctionStaticHelper.IsStaticLocalFunctionSupported(context.
Compilation
.LanguageVersion()))
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
37
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (1)
33
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
33
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
33
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
34
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
30
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (1)
38
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (3)
44
if (context.
Compilation
.LanguageVersion().IsCSharp11OrAbove())
46
var expressionType = context.
Compilation
.ExpressionOfTType();
47
var conditionalAttributeType = context.
Compilation
.ConditionalAttribute();
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
36
var compilation = (CSharpCompilation)context.
Compilation
;
src\Analyzers\CSharp\Analyzers\SimplifyLinqExpression\CSharpSimplifyLinqTypeCheckAndCastDiagnosticAnalyzer.cs (1)
31
var enumerableType = context.
Compilation
.GetTypeByMetadataName(typeof(Enumerable).FullName!);
src\Analyzers\CSharp\Analyzers\SimplifyPropertyPattern\CSharpSimplifyPropertyPatternDiagnosticAnalyzer.cs (1)
45
if (compilationContext.
Compilation
.LanguageVersion() < LanguageVersion.CSharp10)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\AbstractCSharpUseCollectionExpressionDiagnosticAnalyzer.cs (1)
55
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (1)
46
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseIndexOperatorDiagnosticAnalyzer.cs (1)
61
var compilation = (CSharpCompilation)context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
54
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs (1)
38
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp7)
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs (1)
35
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
57
var compilation = compilationContext.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (1)
47
if (context.
Compilation
.LanguageVersion() >= LanguageVersion.CSharp11)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndMemberAccessDiagnosticAnalyzer.cs (1)
46
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (1)
52
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp7)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpUseNotPatternDiagnosticAnalyzer.cs (2)
42
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9)
45
var expressionOfTType = context.
Compilation
.ExpressionOfTType();
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (1)
73
if (!context.
Compilation
.LanguageVersion().SupportsPrimaryConstructors())
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
70
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
57
var compilation = compilationContext.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseTupleSwap\CSharpUseTupleSwapDiagnosticAnalyzer.cs (1)
52
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseUnboundGenericTypeInNameOf\CSharpUseUnboundGenericTypeInNameOfDiagnosticAnalyzer.cs (1)
47
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (3)
49
if (!context.
Compilation
.LanguageVersion().IsCSharp11OrAbove())
52
if (context.
Compilation
.GetBestTypeByMetadataName(typeof(ReadOnlySpan<>).FullName!) is null)
55
var expressionType = context.
Compilation
.GetTypeByMetadataName(typeof(System.Linq.Expressions.Expression<>).FullName!);
Microsoft.CodeAnalysis.CSharp.Features (41)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToProgramMainDiagnosticAnalyzer.cs (1)
35
if (!IsApplication(context.
Compilation
))
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToTopLevelStatementsDiagnosticAnalyzer.cs (2)
38
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9 ||
39
!IsApplication(context.
Compilation
))
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs (1)
35
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (1)
50
var compilation = compilationContext.
Compilation
;
src\Analyzers\CSharp\Analyzers\MakeAnonymousFunctionStatic\MakeAnonymousFunctionStaticDiagnosticAnalyzer.cs (1)
32
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9)
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticDiagnosticAnalyzer.cs (1)
32
if (MakeLocalFunctionStaticHelper.IsStaticLocalFunctionSupported(context.
Compilation
.LanguageVersion()))
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
37
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (1)
33
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
33
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
33
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
34
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
30
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (1)
38
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (3)
44
if (context.
Compilation
.LanguageVersion().IsCSharp11OrAbove())
46
var expressionType = context.
Compilation
.ExpressionOfTType();
47
var conditionalAttributeType = context.
Compilation
.ConditionalAttribute();
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
36
var compilation = (CSharpCompilation)context.
Compilation
;
src\Analyzers\CSharp\Analyzers\SimplifyLinqExpression\CSharpSimplifyLinqTypeCheckAndCastDiagnosticAnalyzer.cs (1)
31
var enumerableType = context.
Compilation
.GetTypeByMetadataName(typeof(Enumerable).FullName!);
src\Analyzers\CSharp\Analyzers\SimplifyPropertyPattern\CSharpSimplifyPropertyPatternDiagnosticAnalyzer.cs (1)
45
if (compilationContext.
Compilation
.LanguageVersion() < LanguageVersion.CSharp10)
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\AbstractCSharpUseCollectionExpressionDiagnosticAnalyzer.cs (1)
55
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (1)
46
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseIndexOperatorDiagnosticAnalyzer.cs (1)
61
var compilation = (CSharpCompilation)context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseIndexOrRangeOperator\CSharpUseRangeOperatorDiagnosticAnalyzer.cs (1)
54
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs (1)
38
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp7)
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs (1)
35
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
57
var compilation = compilationContext.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (1)
47
if (context.
Compilation
.LanguageVersion() >= LanguageVersion.CSharp11)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndMemberAccessDiagnosticAnalyzer.cs (1)
46
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (1)
52
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp7)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpUseNotPatternDiagnosticAnalyzer.cs (2)
42
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp9)
45
var expressionOfTType = context.
Compilation
.ExpressionOfTType();
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (1)
73
if (!context.
Compilation
.LanguageVersion().SupportsPrimaryConstructors())
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
70
if (context.
Compilation
.LanguageVersion() < LanguageVersion.CSharp8)
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
57
var compilation = compilationContext.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseTupleSwap\CSharpUseTupleSwapDiagnosticAnalyzer.cs (1)
52
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseUnboundGenericTypeInNameOf\CSharpUseUnboundGenericTypeInNameOfDiagnosticAnalyzer.cs (1)
47
var compilation = context.
Compilation
;
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (3)
49
if (!context.
Compilation
.LanguageVersion().IsCSharp11OrAbove())
52
if (context.
Compilation
.GetBestTypeByMetadataName(typeof(ReadOnlySpan<>).FullName!) is null)
55
var expressionType = context.
Compilation
.GetTypeByMetadataName(typeof(System.Linq.Expressions.Expression<>).FullName!);
UsePatternMatching\CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs (1)
56
var expressionType = context.
Compilation
.ExpressionOfTType();
Microsoft.CodeAnalysis.Features (29)
src\Analyzers\Core\Analyzers\AddAccessibilityModifiers\AbstractAddAccessibilityModifiersDiagnosticAnalyzer.cs (1)
28
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderDiagnosticAnalyzer.cs (1)
40
context.RegisterSyntaxTreeAction(treeContext => HandleSyntaxTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (1)
32
context.RegisterSyntaxTreeAction(treeContext => AnalyzeSyntaxTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (1)
44
var compilation = context.
Compilation
;
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
39
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesDiagnosticAnalyzer.cs (1)
34
context.RegisterSyntaxTreeAction(treeContext => AnalyzeTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\OrderModifiers\AbstractOrderModifiersDiagnosticAnalyzer.cs (1)
38
context.RegisterSyntaxTreeAction(treeContext => AnalyzeSyntaxTree(treeContext, context.
Compilation
.Options)));
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (2)
60
var suppressMessageAttributeType = context.
Compilation
.SuppressMessageAttributeType();
66
RegisterAttributeSyntaxAction(context, new CompilationAnalyzer(context.
Compilation
, suppressMessageAttributeType));
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
189
var compilationAnalyzer = new CompilationAnalyzer(compilationStartContext.
Compilation
, analyzer);
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (4)
51
var attributeSetForMethodsToIgnore = ImmutableHashSet.CreateRange(GetAttributesForMethodsToIgnore(context.
Compilation
).WhereNotNull());
52
var eventsArgType = context.
Compilation
.EventArgsType();
53
var deserializationConstructorCheck = new DeserializationConstructorCheck(context.
Compilation
);
54
var iCustomMarshaler = context.
Compilation
.GetTypeByMetadataName(typeof(ICustomMarshaler).FullName!);
src\Analyzers\Core\Analyzers\SimplifyLinqExpression\AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs (1)
59
if (TryGetEnumerableTypeSymbol(context.
Compilation
, out var enumerableType) &&
src\Analyzers\Core\Analyzers\UseCollectionInitializer\AbstractUseCollectionInitializerDiagnosticAnalyzer.cs (3)
98
if (!AreCollectionInitializersSupported(context.
Compilation
))
101
var ienumerableType = context.
Compilation
.IEnumerableType();
118
var expressionType = context.
Compilation
.ExpressionOfTType();
src\Analyzers\Core\Analyzers\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsDiagnosticAnalyzer.cs (3)
34
var objectType = context.
Compilation
.GetSpecialType(SpecialType.System_Object);
35
if (objectType != null && IsLanguageVersionSupported(context.
Compilation
))
44
var unconstraintedGenericSupported = IsUnconstrainedGenericSupported(context.
Compilation
);
src\Analyzers\Core\Analyzers\UseNullPropagation\AbstractUseNullPropagationDiagnosticAnalyzer.cs (3)
90
if (!ShouldAnalyze(context.
Compilation
))
93
var expressionType = context.
Compilation
.ExpressionOfTType();
95
var objectType = context.
Compilation
.GetSpecialType(SpecialType.System_Object);
src\Analyzers\Core\Analyzers\UseObjectInitializer\AbstractUseObjectInitializerDiagnosticAnalyzer.cs (1)
69
if (!AreObjectInitializersSupported(context.
Compilation
))
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (1)
33
if (HashCodeAnalyzer.TryGetAnalyzer(c.
Compilation
, out var analyzer))
src\Analyzers\Core\Analyzers\UseThrowExpression\AbstractUseThrowExpressionDiagnosticAnalyzer.cs (2)
60
if (!IsSupported(startContext.
Compilation
))
65
var expressionType = startContext.
Compilation
.ExpressionOfTType();
src\Analyzers\Core\Analyzers\ValidateFormatString\AbstractValidateFormatStringDiagnosticAnalyzer.cs (1)
73
var formatProviderType = startContext.
Compilation
.GetTypeByMetadataName(typeof(System.IFormatProvider).FullName!);
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (1)
Diagnostics\NonLocalDiagnosticTests.cs (1)
86
var compilation = context.
Compilation
;
Microsoft.CodeAnalysis.Test.Utilities (4)
Diagnostics\CommonDiagnosticAnalyzers.cs (3)
1147
Assert.True(context.
Compilation
.Options.ConcurrentBuild, "This analyzer is intended to be used only when concurrent build is enabled.");
1150
foreach (var type in context.
Compilation
.GlobalNamespace.GetTypeMembers())
2934
context.RegisterSyntaxTreeAction(syntaxContext => HandleCallback(syntaxContext.Tree.GetRoot().GetLocation(), context.
Compilation
, syntaxContext.ReportDiagnostic, syntaxContext.CancellationToken));
Diagnostics\SuppressMessageAttributeTests.DiagnosticAnalyzers.cs (1)
279
analysisContext.RegisterCompilationStartAction(context => AssemblyName = context.
Compilation
.AssemblyName);
Microsoft.CodeAnalysis.UnitTests (1)
Diagnostics\AnalysisContextInfoTests.cs (1)
75
c.RegisterCompilationStartAction(b => ThrowIfMatch(nameof(c.RegisterCompilationStartAction), new AnalysisContextInfo(b.
Compilation
)));
Microsoft.DotNet.CodeAnalysis (1)
Analyzers\ResourceUsageAnalyzer.cs (1)
27
SRSymbol = context.
Compilation
.GetTypeByMetadataName("System.SR");
Microsoft.Interop.ComInterfaceGenerator (13)
Analyzers\AddGeneratedComClassAnalyzer.cs (2)
25
var generatedComClassAttributeType = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.GeneratedComClassAttribute);
26
var generatedComInterfaceAttributeType = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.GeneratedComInterfaceAttribute);
Analyzers\ComHostingDoesNotSupportGeneratedComInterfaceAnalyzer.cs (3)
32
INamedTypeSymbol? generatedComClassAttribute = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.GeneratedComClassAttribute);
33
INamedTypeSymbol? generatedComInterfaceAttribute = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.GeneratedComInterfaceAttribute);
34
INamedTypeSymbol? comVisibleAttribute = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.System_Runtime_InteropServices_ComVisibleAttribute)!;
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (4)
36
INamedTypeSymbol? interfaceTypeAttribute = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.InterfaceTypeAttribute)!;
37
INamedTypeSymbol? generatedComInterfaceAttribute = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.GeneratedComInterfaceAttribute);
45
context.
Compilation
,
46
context.
Compilation
.GetEnvironmentFlags());
Analyzers\RuntimeComApiUsageWithSourceGeneratedComAnalyzer.cs (4)
29
INamedTypeSymbol? marshalType = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.System_Runtime_InteropServices_Marshal);
30
INamedTypeSymbol? generatedComClassAttribute = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.GeneratedComClassAttribute);
31
INamedTypeSymbol? generatedComInterfaceAttribute = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.GeneratedComInterfaceAttribute);
32
INamedTypeSymbol? comObjectType = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.System_Runtime_InteropServices_Marshalling_ComObject);
Microsoft.Interop.LibraryImportGenerator (6)
Analyzers\ConvertToLibraryImportAnalyzer.cs (3)
55
INamedTypeSymbol? libraryImportAttrType = context.
Compilation
.GetBestTypeByMetadataName(TypeNames.LibraryImportAttribute);
60
context.
Compilation
,
61
context.
Compilation
.GetEnvironmentFlags());
Analyzers\CustomMarshallerAttributeAnalyzer.cs (2)
621
if (context.
Compilation
.GetBestTypeByMetadataName(TypeNames.CustomMarshallerAttribute) is { } customMarshallerAttribute)
623
var perCompilationAnalyzer = new PerCompilationAnalyzer(context.
Compilation
, customMarshallerAttribute);
Analyzers\NativeMarshallingAttributeAnalyzer.cs (1)
70
var perCompilationAnalyzer = new PerCompilationAnalyzer(context.
Compilation
);
Microsoft.ML.InternalCodeAnalyzer (3)
BaseTestClassAnalyzer.cs (2)
40
if (!(context.
Compilation
.GetTypeByMetadataName("Xunit.FactAttribute") is { } factAttribute))
45
var analyzerImpl = new AnalyzerImpl(context.
Compilation
, factAttribute);
BestFriendOnPublicDeclarationsAnalyzer.cs (1)
48
var attribute = context.
Compilation
.GetTypeByMetadataName(attributeName);
System.Private.CoreLib.Generators (3)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (3)
140
INamespaceSymbol systemRuntimeIntrinsicsNamespace = GetNamespace(context.
Compilation
.Assembly, "System", "Runtime", "Intrinsics");
141
INamedTypeSymbol? bypassReadyToRunAttribute = context.
Compilation
.Assembly.GetTypeByMetadataName("System.Runtime.BypassReadyToRunAttribute");
142
INamedTypeSymbol? compExactlyDependsOn = context.
Compilation
.Assembly.GetTypeByMetadataName("System.Runtime.CompilerServices.CompExactlyDependsOnAttribute");
System.Text.RegularExpressions.Generator (1)
UpgradeToGeneratedRegexAnalyzer.cs (1)
40
Compilation compilation = context.
Compilation
;