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