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