93 references to NullableContext
Microsoft.CodeAnalysis (12)
Compilation\NullableContext.cs (10)
74private static bool IsFlagSet(NullableContext context, NullableContext flag) => 80public static bool WarningsEnabled(this NullableContext context) => 81IsFlagSet(context, NullableContext.WarningsEnabled); 86public static bool AnnotationsEnabled(this NullableContext context) => 87IsFlagSet(context, NullableContext.AnnotationsEnabled); 92public static bool WarningsInherited(this NullableContext context) => 93IsFlagSet(context, NullableContext.WarningsContextInherited); 98public static bool AnnotationsInherited(this NullableContext context) => 99IsFlagSet(context, NullableContext.AnnotationsContextInherited);
Compilation\SemanticModel.cs (2)
926/// Gets the <see cref="NullableContext"/> at a position in the file. 929public abstract NullableContext GetNullableContext(int position);
Microsoft.CodeAnalysis.CSharp (11)
Compilation\CSharpSemanticModel.cs (11)
5432public sealed override NullableContext GetNullableContext(int position) 5441NullableContextState.State.Enabled => NullableContext.AnnotationsEnabled, 5442NullableContextState.State.Disabled => NullableContext.Disabled, 5443_ when getDefaultState().AnnotationsEnabled() => NullableContext.AnnotationsContextInherited | NullableContext.AnnotationsEnabled, 5444_ => NullableContext.AnnotationsContextInherited, 5448NullableContextState.State.Enabled => NullableContext.WarningsEnabled, 5449NullableContextState.State.Disabled => NullableContext.Disabled, 5450_ when getDefaultState().WarningsEnabled() => NullableContext.WarningsContextInherited | NullableContext.WarningsEnabled, 5451_ => NullableContext.WarningsContextInherited,
Microsoft.CodeAnalysis.CSharp.Features (4)
ConvertCast\CSharpConvertDirectCastToTryCastCodeRefactoringProvider.cs (1)
40protected override BinaryExpressionSyntax ConvertExpression(CastExpressionSyntax castExpression, NullableContext nullableContext, bool isReferenceType)
ConvertCast\CSharpConvertTryCastToDirectCastCodeRefactoringProvider.cs (2)
42protected override CastExpressionSyntax ConvertExpression(BinaryExpressionSyntax asExpression, NullableContext nullableContext, bool isReferenceType) 59if (expression.IsKind(SyntaxKind.NullLiteralExpression) && nullableContext.HasFlag(NullableContext.AnnotationsEnabled) && isReferenceType)
QuickInfo\CSharpSemanticQuickInfoProvider.cs (1)
97var nullableContext = semanticModel.GetNullableContext(node.SpanStart);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (58)
Semantics\NullableContextTests.cs (58)
23[InlineData("#nullable enable", NullableContextOptions.Disable, NullableContext.Enabled)] 24[InlineData("#nullable enable", NullableContextOptions.Annotations, NullableContext.Enabled)] 25[InlineData("#nullable enable", NullableContextOptions.Warnings, NullableContext.Enabled)] 26[InlineData("#nullable enable", NullableContextOptions.Enable, NullableContext.Enabled)] 28[InlineData("#nullable enable warnings", NullableContextOptions.Disable, NullableContext.WarningsEnabled | NullableContext.AnnotationsContextInherited)] 29[InlineData("#nullable enable warnings", NullableContextOptions.Warnings, NullableContext.WarningsEnabled | NullableContext.AnnotationsContextInherited)] 30[InlineData("#nullable enable warnings", NullableContextOptions.Annotations, NullableContext.Enabled | NullableContext.AnnotationsContextInherited)] 31[InlineData("#nullable enable warnings", NullableContextOptions.Enable, NullableContext.Enabled | NullableContext.AnnotationsContextInherited)] 33[InlineData("#nullable enable annotations", NullableContextOptions.Disable, NullableContext.AnnotationsEnabled | NullableContext.WarningsContextInherited)] 34[InlineData("#nullable enable annotations", NullableContextOptions.Warnings, NullableContext.Enabled | NullableContext.WarningsContextInherited)] 35[InlineData("#nullable enable annotations", NullableContextOptions.Annotations, NullableContext.AnnotationsEnabled | NullableContext.WarningsContextInherited)] 36[InlineData("#nullable enable annotations", NullableContextOptions.Enable, NullableContext.Enabled | NullableContext.WarningsContextInherited)] 38[InlineData("#nullable disable", NullableContextOptions.Disable, NullableContext.Disabled)] 39[InlineData("#nullable disable", NullableContextOptions.Annotations, NullableContext.Disabled)] 40[InlineData("#nullable disable", NullableContextOptions.Warnings, NullableContext.Disabled)] 41[InlineData("#nullable disable", NullableContextOptions.Enable, NullableContext.Disabled)] 43[InlineData("#nullable disable warnings", NullableContextOptions.Disable, NullableContext.Disabled | NullableContext.AnnotationsContextInherited)] 44[InlineData("#nullable disable warnings", NullableContextOptions.Warnings, NullableContext.Disabled | NullableContext.AnnotationsContextInherited)] 45[InlineData("#nullable disable warnings", NullableContextOptions.Annotations, NullableContext.AnnotationsEnabled | NullableContext.AnnotationsContextInherited)] 46[InlineData("#nullable disable warnings", NullableContextOptions.Enable, NullableContext.AnnotationsEnabled | NullableContext.AnnotationsContextInherited)] 48[InlineData("#nullable disable annotations", NullableContextOptions.Disable, NullableContext.Disabled | NullableContext.WarningsContextInherited)] 49[InlineData("#nullable disable annotations", NullableContextOptions.Warnings, NullableContext.WarningsEnabled | NullableContext.WarningsContextInherited)] 50[InlineData("#nullable disable annotations", NullableContextOptions.Annotations, NullableContext.Disabled | NullableContext.WarningsContextInherited)] 51[InlineData("#nullable disable annotations", NullableContextOptions.Enable, NullableContext.WarningsEnabled | NullableContext.WarningsContextInherited)] 53public void NullableContextExplicitlySpecifiedAndRestoredInFile(string pragma, NullableContextOptions globalContext, NullableContext expectedContext) 73var restoredContext = ((NullableContext)globalContext) | NullableContext.ContextInherited; 105Assert.Equal(NullableContext.Enabled, model1.GetNullableContext(classDecl1)); 106Assert.Equal(NullableContext.Enabled | NullableContext.ContextInherited, model2.GetNullableContext(classDecl2)); 128AssertEnabledForInheritance(NullableContext.Disabled, warningsEnabled: false, annotationsEnabled: false); 129AssertEnabledForInheritance(NullableContext.WarningsEnabled, warningsEnabled: true, annotationsEnabled: false); 130AssertEnabledForInheritance(NullableContext.AnnotationsEnabled, warningsEnabled: false, annotationsEnabled: true); 131AssertEnabledForInheritance(NullableContext.Enabled, warningsEnabled: true, annotationsEnabled: true); 133void AssertEnabledForInheritance(NullableContext context, bool warningsEnabled, bool annotationsEnabled) 140var warningsInherited = context | NullableContext.WarningsContextInherited; 146var annotationsInherited = context | NullableContext.AnnotationsContextInherited; 152var contextInherited = context | NullableContext.ContextInherited;
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Simplification\Reducers\CSharpNullableAnnotationReducer.cs (1)
37var context = semanticModel.GetNullableContext(node.Span.End);
Microsoft.CodeAnalysis.Features (2)
ConvertCast\AbstractConvertCastCodeRefactoringProvider.cs (2)
32protected abstract TToExpression ConvertExpression(TFromExpression from, NullableContext nullableContext, bool isReferenceType); 71NullableContext nullableContext,
Microsoft.CodeAnalysis.VisualBasic (3)
Compilation\SemanticModel.vb (3)
3573Public NotOverridable Overrides Function GetNullableContext(position As Integer) As NullableContext 3574Return NullableContext.Disabled Or NullableContext.ContextInherited
Microsoft.CodeAnalysis.VisualBasic.Features (2)
ConvertCast\VisualBasicConvertDirectCastToTryCastCodeRefactoringProvider.vb (1)
31Protected Overrides Function ConvertExpression(fromExpression As DirectCastExpressionSyntax, nullableContext As NullableContext, isReferenceType As Boolean) As TryCastExpressionSyntax
ConvertCast\VisualBasicConvertTryCastToDirectCastCodeRefactoringProvider.vb (1)
31Protected Overrides Function ConvertExpression(fromExpression As TryCastExpressionSyntax, nullableContext As NullableContext, isReferenceType As Boolean) As DirectCastExpressionSyntax