675 references to NullableContextOptions
ConfigurationSchemaGenerator.Tests (1)
GeneratorTests.cs (1)
1562
var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(
NullableContextOptions
.Enable);
Microsoft.Analyzers.Extra.Tests (1)
Resources\RoslynTestUtils.cs (1)
60
.WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.Analyzers.Local.Tests (1)
Resources\RoslynTestUtils.cs (1)
60
.WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.AspNetCore.Http.Extensions.Tests (1)
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
315
.WithNullableContextOptions(
NullableContextOptions
.Disable);
Microsoft.AspNetCore.Http.Microbenchmarks (1)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
315
.WithNullableContextOptions(
NullableContextOptions
.Disable);
Microsoft.CodeAnalysis (7)
Compilation\CompilationOptions.cs (1)
244
public abstract
NullableContextOptions
NullableContextOptions { get; protected set; }
Compilation\NullableContextOptions.cs (6)
39
private static bool IsFlagSet(
NullableContextOptions
context,
NullableContextOptions
flag) =>
45
public static bool WarningsEnabled(this
NullableContextOptions
context) =>
46
IsFlagSet(context,
NullableContextOptions
.Warnings);
51
public static bool AnnotationsEnabled(this
NullableContextOptions
context) =>
52
IsFlagSet(context,
NullableContextOptions
.Annotations);
Microsoft.CodeAnalysis.CSharp (35)
Binder\Binder.cs (4)
286
case
NullableContextOptions
.Enable:
287
case
NullableContextOptions
.Annotations:
290
case
NullableContextOptions
.Disable:
291
case
NullableContextOptions
.Warnings:
CommandLine\CSharpCommandLineParser.cs (14)
67
NullableContextOptions
nullableContextOptions =
NullableContextOptions
.Disable;
425
Debug.Assert(loweredValue == nameof(
NullableContextOptions
.Disable).ToLower());
426
nullableContextOptions =
NullableContextOptions
.Disable;
429
Debug.Assert(loweredValue == nameof(
NullableContextOptions
.Enable).ToLower());
430
nullableContextOptions =
NullableContextOptions
.Enable;
433
Debug.Assert(loweredValue == nameof(
NullableContextOptions
.Warnings).ToLower());
434
nullableContextOptions =
NullableContextOptions
.Warnings;
437
Debug.Assert(loweredValue == nameof(
NullableContextOptions
.Annotations).ToLower());
438
nullableContextOptions =
NullableContextOptions
.Annotations;
447
nullableContextOptions =
NullableContextOptions
.Enable;
457
nullableContextOptions =
NullableContextOptions
.Enable;
464
nullableContextOptions =
NullableContextOptions
.Disable;
1536
if (nullableContextOptions !=
NullableContextOptions
.Disable && parseOptions.LanguageVersion < MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion())
Compilation\CSharpCompilation.cs (3)
258
(Options.NullableContextOptions &
NullableContextOptions
.Warnings) != 0;
2971
if (Options.NullableContextOptions !=
NullableContextOptions
.Disable && LanguageVersion < MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion() &&
4756
if (Options.NullableContextOptions !=
NullableContextOptions
.Disable)
Compilation\CSharpDiagnosticFilter.cs (2)
38
NullableContextOptions
nullableOption,
144
NullableContextOptions
nullableOption,
Compilation\CSharpSemanticModel.cs (3)
5443
NullableContextOptions
? lazyDefaultState = null;
5462
NullableContextOptions
getDefaultState()
5464
?
NullableContextOptions
.Disable
CSharpCompilationOptions.cs (7)
44
public override
NullableContextOptions
NullableContextOptions { get; protected set; }
75
NullableContextOptions
nullableContextOptions =
NullableContextOptions
.Disable)
137
nullableContextOptions:
NullableContextOptions
.Disable)
217
NullableContextOptions
nullableContextOptions)
403
public CSharpCompilationOptions WithNullableContextOptions(
NullableContextOptions
options)
939
nullableContextOptions:
NullableContextOptions
.Disable)
FlowAnalysis\NullableWalker.cs (1)
1550
if (compilation.Options.NullableContextOptions !=
NullableContextOptions
.Disable)
Symbols\Synthesized\SynthesizedInteractiveInitializerMethod.cs (1)
251
bool value = (compilation.Options.NullableContextOptions !=
NullableContextOptions
.Disable) ||
Microsoft.CodeAnalysis.CSharp.CodeStyle (18)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (12)
60
var
defaultNullableContext = compilationOptions.NullableContextOptions;
61
NullableContextOptions
? currentState = context.Tree.IsGeneratedCode(context.Options, CSharpSyntaxFacts.Instance, context.CancellationToken)
62
?
NullableContextOptions
.Disable
120
internal static
NullableContextOptions
? GetNullableContextOptions(
NullableContextOptions
compilationOptions,
NullableContextOptions
? options, NullableDirectiveTriviaSyntax directive)
129
NullableContextOptions
flagToChange;
132
flagToChange =
NullableContextOptions
.Annotations;
136
flagToChange =
NullableContextOptions
.Warnings;
159
return
NullableContextOptions
.Annotations |
NullableContextOptions
.Warnings;
163
return
NullableContextOptions
.Disable;
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (6)
74
private static bool IsReducing([NotNullWhen(true)]
NullableContextOptions
? oldOptions, [NotNullWhen(true)]
NullableContextOptions
? newOptions)
105
var
compilationOptions = ((CSharpCompilationOptions)context.SemanticModel.Compilation.Options).NullableContextOptions;
108
NullableContextOptions
? retainedOptions = compilationOptions;
187
public static SyntaxTreeState Create(bool defaultCompleted,
NullableContextOptions
compilationOptions, SyntaxTree tree, CancellationToken cancellationToken)
195
NullableContextOptions
? currentOptions = compilationOptions;
Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests (107)
src\Analyzers\CSharp\Tests\ImplementAbstractClass\ImplementAbstractClassTests.cs (1)
181
nullableContextOptions:
NullableContextOptions
.Enable
src\Analyzers\CSharp\Tests\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveTests.cs (78)
24
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Annotations)]
25
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Warnings)]
26
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Enable)]
27
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Warnings)]
28
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Enable)]
29
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Annotations)]
30
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Enable)]
31
public async Task TestRedundantEnableDiffersFromCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
51
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Annotations)]
52
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Warnings)]
53
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Annotations)]
54
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Warnings)]
55
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Enable)]
56
public async Task TestRedundantEnableMatchesCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
75
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Annotations)]
76
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Enable)]
77
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Warnings)]
78
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Enable)]
79
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Annotations)]
80
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Warnings)]
81
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Enable)]
82
public async Task TestRedundantDisableDiffersFromCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
102
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Annotations)]
103
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Warnings)]
104
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Enable)]
105
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Warnings)]
106
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Annotations)]
107
public async Task TestRedundantDisableMatchesCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
126
public async Task TestRedundantRestoreDiffersFromPriorContext(
NullableContextOptions
compilationContext)
128
var enable = compilationContext !=
NullableContextOptions
.Enable;
149
public async Task TestRedundantRestoreMatchesCompilation(
NullableContextOptions
compilationContext)
170
NullableContextOptions
.Enable,
193
NullableContextOptions
.Enable,
222
NullableContextOptions
.Enable,
250
NullableContextOptions
.Enable,
278
NullableContextOptions
.Enable,
308
NullableContextOptions
.Enable,
338
NullableContextOptions
.Enable,
369
NullableContextOptions
.Enable,
398
NullableContextOptions
.Enable,
428
NullableContextOptions
.Enable,
453
private static string GetDisableDirectiveContext(
NullableContextOptions
options)
457
NullableContextOptions
.Warnings => "disable warnings",
458
NullableContextOptions
.Annotations => "disable annotations",
459
NullableContextOptions
.Enable => "disable",
464
private static string GetEnableDirectiveContext(
NullableContextOptions
options)
468
NullableContextOptions
.Warnings => "enable warnings",
469
NullableContextOptions
.Annotations => "enable annotations",
470
NullableContextOptions
.Enable => "enable",
475
private static async Task VerifyCodeFixAsync(
NullableContextOptions
compilationNullableContextOptions, string source, string fixedSource)
src\Analyzers\CSharp\Tests\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveTests.cs (28)
24
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Annotations)]
25
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Enable)]
26
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Warnings)]
27
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Enable)]
28
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Annotations)]
29
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Warnings)]
30
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Enable)]
31
public async Task TestUnnecessaryDisableDiffersFromCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
52
NullableContextOptions
.Enable,
74
NullableContextOptions
.Enable,
101
NullableContextOptions
.Enable,
131
NullableContextOptions
.Enable,
157
NullableContextOptions
.Enable,
181
NullableContextOptions
.Disable,
216
await VerifyCodeFixAsync(
NullableContextOptions
.Disable, code, code);
219
private static string GetDisableDirectiveContext(
NullableContextOptions
options)
223
NullableContextOptions
.Warnings => "disable warnings",
224
NullableContextOptions
.Annotations => "disable annotations",
225
NullableContextOptions
.Enable => "disable",
230
private static async Task VerifyCodeFixAsync(
NullableContextOptions
compilationNullableContextOptions, string source, string fixedSource)
Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests (81)
CommandLineTests.cs (81)
4864
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4868
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4875
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4879
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4883
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4890
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4897
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4903
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4907
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4916
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4920
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4924
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4931
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4938
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4942
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4946
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4956
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4960
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4964
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4971
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4978
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4982
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
4986
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
4996
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5000
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5004
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5011
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5018
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5022
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5026
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5039
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5046
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5053
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5062
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5071
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5078
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5085
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5094
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5101
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5108
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5115
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5119
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5126
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5133
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5137
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5144
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5148
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5152
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5159
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5166
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5173
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5180
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5187
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5194
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5201
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5208
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5212
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5216
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5220
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5224
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5228
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5232
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5239
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5246
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5250
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5254
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5258
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5265
Assert.Equal(
NullableContextOptions
.Warnings, parsedArgs.CompilationOptions.NullableContextOptions);
5272
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
5276
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
5280
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
5284
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
5288
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5292
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5296
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5303
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
5310
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
5314
Assert.Equal(
NullableContextOptions
.Disable, parsedArgs.CompilationOptions.NullableContextOptions);
5318
Assert.Equal(
NullableContextOptions
.Enable, parsedArgs.CompilationOptions.NullableContextOptions);
5322
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
5329
Assert.Equal(
NullableContextOptions
.Annotations, parsedArgs.CompilationOptions.NullableContextOptions);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
QuickInfo\SemanticQuickInfoSourceTests.cs (1)
8187
await TestWithOptionsAsync(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, nullableContextOptions:
NullableContextOptions
.Enable),
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (4)
Emit\EditAndContinue\EditAndContinueTests.cs (1)
259
var compilation0 = CreateCompilation(source0, parseOptions: TestOptions.Regular.WithNoRefSafetyRulesAttribute(), options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
PDB\CSharpDeterministicBuildCompilationTests.cs (3)
338
nullableContextOptions:
NullableContextOptions
.Enable);
341
yield return defaultOptions.WithNullableContextOptions(
NullableContextOptions
.Disable);
342
yield return defaultOptions.WithNullableContextOptions(
NullableContextOptions
.Warnings);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (21)
Attributes\AttributeTests_Nullable.cs (2)
886
var comp = CreateCompilation(new[] { source }, options: WithNullable(
NullableContextOptions
.Enable), parseOptions: TestOptions.Regular8);
908
var comp = CreateCompilation(new[] { source }, options: WithNullable(
NullableContextOptions
.Annotations), parseOptions: TestOptions.Regular8);
Semantics\PatternMatchingTests3.cs (15)
593
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
636
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
679
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
722
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
746
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
769
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
812
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
854
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
902
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
961
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
989
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
1036
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
1089
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
1142
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
1195
var compilation = CreateCompilation(source, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Disable));
Semantics\PatternMatchingTests5.cs (4)
3033
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(nullableEnable ?
NullableContextOptions
.Enable :
NullableContextOptions
.Disable));
3130
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(nullableEnable ?
NullableContextOptions
.Enable :
NullableContextOptions
.Disable));
Microsoft.CodeAnalysis.CSharp.Features (20)
CodeRefactorings\EnableNullable\EnableNullableCodeRefactoringProvider.cs (2)
65
CompilationOptions.NullableContextOptions:
NullableContextOptions
.Disable,
90
solution = solution.WithProjectCompilationOptions(project.Id, compilationOptions.WithNullableContextOptions(
NullableContextOptions
.Enable));
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (12)
60
var
defaultNullableContext = compilationOptions.NullableContextOptions;
61
NullableContextOptions
? currentState = context.Tree.IsGeneratedCode(context.Options, CSharpSyntaxFacts.Instance, context.CancellationToken)
62
?
NullableContextOptions
.Disable
120
internal static
NullableContextOptions
? GetNullableContextOptions(
NullableContextOptions
compilationOptions,
NullableContextOptions
? options, NullableDirectiveTriviaSyntax directive)
129
NullableContextOptions
flagToChange;
132
flagToChange =
NullableContextOptions
.Annotations;
136
flagToChange =
NullableContextOptions
.Warnings;
159
return
NullableContextOptions
.Annotations |
NullableContextOptions
.Warnings;
163
return
NullableContextOptions
.Disable;
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (6)
74
private static bool IsReducing([NotNullWhen(true)]
NullableContextOptions
? oldOptions, [NotNullWhen(true)]
NullableContextOptions
? newOptions)
105
var
compilationOptions = ((CSharpCompilationOptions)context.SemanticModel.Compilation.Options).NullableContextOptions;
108
NullableContextOptions
? retainedOptions = compilationOptions;
187
public static SyntaxTreeState Create(bool defaultCompleted,
NullableContextOptions
compilationOptions, SyntaxTree tree, CancellationToken cancellationToken)
195
NullableContextOptions
? currentOptions = compilationOptions;
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (115)
ConvertToRecord\ConvertToRecordCodeRefactoringTests.cs (2)
4701
compilationOptions = compilationOptions.WithNullableContextOptions(
NullableContextOptions
.Enable);
4744
compilationOptions = compilationOptions.WithNullableContextOptions(
NullableContextOptions
.Enable);
EnableNullable\EnableNullableTests.cs (6)
37
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions.WithNullableContextOptions(
NullableContextOptions
.Enable));
53
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions.WithNullableContextOptions(
NullableContextOptions
.Enable));
536
[InlineData(
NullableContextOptions
.Annotations)]
537
[InlineData(
NullableContextOptions
.Warnings)]
538
[InlineData(
NullableContextOptions
.Enable)]
539
public async Task DisabledIfSetInProject(
NullableContextOptions
nullableContextOptions)
src\Analyzers\CSharp\Tests\ImplementAbstractClass\ImplementAbstractClassTests.cs (1)
181
nullableContextOptions:
NullableContextOptions
.Enable
src\Analyzers\CSharp\Tests\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveTests.cs (78)
24
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Annotations)]
25
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Warnings)]
26
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Enable)]
27
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Warnings)]
28
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Enable)]
29
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Annotations)]
30
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Enable)]
31
public async Task TestRedundantEnableDiffersFromCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
51
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Annotations)]
52
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Warnings)]
53
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Annotations)]
54
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Warnings)]
55
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Enable)]
56
public async Task TestRedundantEnableMatchesCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
75
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Annotations)]
76
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Enable)]
77
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Warnings)]
78
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Enable)]
79
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Annotations)]
80
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Warnings)]
81
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Enable)]
82
public async Task TestRedundantDisableDiffersFromCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
102
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Annotations)]
103
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Warnings)]
104
[InlineData(
NullableContextOptions
.Disable,
NullableContextOptions
.Enable)]
105
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Warnings)]
106
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Annotations)]
107
public async Task TestRedundantDisableMatchesCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
126
public async Task TestRedundantRestoreDiffersFromPriorContext(
NullableContextOptions
compilationContext)
128
var enable = compilationContext !=
NullableContextOptions
.Enable;
149
public async Task TestRedundantRestoreMatchesCompilation(
NullableContextOptions
compilationContext)
170
NullableContextOptions
.Enable,
193
NullableContextOptions
.Enable,
222
NullableContextOptions
.Enable,
250
NullableContextOptions
.Enable,
278
NullableContextOptions
.Enable,
308
NullableContextOptions
.Enable,
338
NullableContextOptions
.Enable,
369
NullableContextOptions
.Enable,
398
NullableContextOptions
.Enable,
428
NullableContextOptions
.Enable,
453
private static string GetDisableDirectiveContext(
NullableContextOptions
options)
457
NullableContextOptions
.Warnings => "disable warnings",
458
NullableContextOptions
.Annotations => "disable annotations",
459
NullableContextOptions
.Enable => "disable",
464
private static string GetEnableDirectiveContext(
NullableContextOptions
options)
468
NullableContextOptions
.Warnings => "enable warnings",
469
NullableContextOptions
.Annotations => "enable annotations",
470
NullableContextOptions
.Enable => "enable",
475
private static async Task VerifyCodeFixAsync(
NullableContextOptions
compilationNullableContextOptions, string source, string fixedSource)
src\Analyzers\CSharp\Tests\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveTests.cs (28)
24
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Annotations)]
25
[InlineData(
NullableContextOptions
.Annotations,
NullableContextOptions
.Enable)]
26
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Warnings)]
27
[InlineData(
NullableContextOptions
.Warnings,
NullableContextOptions
.Enable)]
28
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Annotations)]
29
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Warnings)]
30
[InlineData(
NullableContextOptions
.Enable,
NullableContextOptions
.Enable)]
31
public async Task TestUnnecessaryDisableDiffersFromCompilation(
NullableContextOptions
compilationContext,
NullableContextOptions
codeContext)
52
NullableContextOptions
.Enable,
74
NullableContextOptions
.Enable,
101
NullableContextOptions
.Enable,
131
NullableContextOptions
.Enable,
157
NullableContextOptions
.Enable,
181
NullableContextOptions
.Disable,
216
await VerifyCodeFixAsync(
NullableContextOptions
.Disable, code, code);
219
private static string GetDisableDirectiveContext(
NullableContextOptions
options)
223
NullableContextOptions
.Warnings => "disable warnings",
224
NullableContextOptions
.Annotations => "disable annotations",
225
NullableContextOptions
.Enable => "disable",
230
private static async Task VerifyCodeFixAsync(
NullableContextOptions
compilationNullableContextOptions, string source, string fixedSource)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (219)
Semantics\NullableContextTests.cs (52)
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)
112
Assert.True(
NullableContextOptions
.Enable.AnnotationsEnabled());
113
Assert.True(
NullableContextOptions
.Enable.WarningsEnabled());
115
Assert.True(
NullableContextOptions
.Annotations.AnnotationsEnabled());
116
Assert.False(
NullableContextOptions
.Annotations.WarningsEnabled());
118
Assert.False(
NullableContextOptions
.Warnings.AnnotationsEnabled());
119
Assert.True(
NullableContextOptions
.Warnings.WarningsEnabled());
121
Assert.False(
NullableContextOptions
.Disable.AnnotationsEnabled());
122
Assert.False(
NullableContextOptions
.Disable.WarningsEnabled());
481
(
NullableContextOptions
?)null,
482
NullableContextOptions
.Disable,
501
NullableContextOptions
.Warnings,
502
NullableContextOptions
.Annotations,
503
NullableContextOptions
.Enable,
506
foreach (
var
projectSetting in projectSettings)
521
public void AnalyzeMethodsInEnabledContextOnly_01A(
NullableContextOptions
? projectContext, NullableDirectives classDirectives, NullableDirectives methodDirectives)
529
public void AnalyzeMethodsInEnabledContextOnly_01B(
NullableContextOptions
? projectContext, NullableDirectives classDirectives, NullableDirectives methodDirectives)
534
private static void AnalyzeMethodsInEnabledContextOnly_01_Execute(
NullableContextOptions
? projectContext, NullableDirectives classDirectives, NullableDirectives methodDirectives)
555
bool isNullableEnabledForProject = projectContext != null && (projectContext.Value &
NullableContextOptions
.Warnings) != 0;
1023
var options = TestOptions.ReleaseDll.WithNullableContextOptions(
NullableContextOptions
.Disable);
1051
verify(new[] { source1, source2, source3, source4 }, TestOptions.ReleaseDll.WithNullableContextOptions(
NullableContextOptions
.Enable), new[] { ".ctor" },
1652
verify(new[] { source }, projectContext:
NullableContextOptions
.Warnings, expectedAnalyzedKeys: new[] { "<Main>$" },
1733
static void verify(string[] source,
NullableContextOptions
? projectContext, string[] expectedAnalyzedKeys, params DiagnosticDescription[] expectedDiagnostics)
2179
public void AnalyzeMethodsInEnabledContextOnly_SpeculativeSemanticModel_A(
NullableContextOptions
? projectContext, NullableDirectives sourceDirectives, NullableDirectives speculativeDirectives)
2187
public void AnalyzeMethodsInEnabledContextOnly_SpeculativeSemanticModel_B(
NullableContextOptions
? projectContext, NullableDirectives sourceDirectives, NullableDirectives speculativeDirectives)
2192
private static void AnalyzeMethodsInEnabledContextOnly_SpeculativeSemanticModel_Execute(
NullableContextOptions
? projectContext, NullableDirectives sourceDirectives, NullableDirectives speculativeDirectives)
2213
bool isNullableEnabledForProject = projectContext != null && (projectContext.Value &
NullableContextOptions
.Warnings) != 0;
2221
private static void VerifySpeculativeSemanticModel(string source,
NullableContextOptions
? projectContext, string typeName, Microsoft.CodeAnalysis.NullableAnnotation expectedAnnotation)
Semantics\NullableReferenceTypesTests.cs (163)
2693
var comp = CreateCompilation(source, options: WithNullable(TestOptions.UnsafeReleaseDll,
NullableContextOptions
.Enable));
5285
var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithFeature("run-nullable-analysis", "always"), options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Disable));
5331
var comp = CreateCompilation(source, parseOptions: TestOptions.Regular.WithFeature("run-nullable-analysis", "always"), options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5406
comp = CreateCompilation(new[] { source0, source1, source2 }, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Disable));
5419
comp = CreateCompilation(new[] { source0, source1, source2 }, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5556
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5576
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5598
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5616
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5638
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5667
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5701
var comp = CreateCompilation(new[] { source1, source2 }, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5736
var comp = CreateCompilation(new[] { source1, source2 }, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
5815
.WithNullableContextOptions(
NullableContextOptions
.Enable)
5954
var comp = CreateCompilation(source, options: WithNullable(
NullableContextOptions
.Annotations));
6292
var comp = CreateCompilation(source, options: WithNullable(
NullableContextOptions
.Warnings));
8589
var comp = CreateCompilation("", options: WithNullable(
NullableContextOptions
.Enable), parseOptions: TestOptions.Regular7_3);
8595
comp = CreateCompilation("", options: WithNullable(
NullableContextOptions
.Warnings), parseOptions: TestOptions.Regular7_3);
8601
comp = CreateCompilation("", options: WithNullable(
NullableContextOptions
.Disable), parseOptions: TestOptions.Regular7_3);
8604
comp = CreateCompilation("", options: WithNullable(
NullableContextOptions
.Enable), parseOptions: TestOptions.Regular8);
8607
comp = CreateCompilation("", options: WithNullable(
NullableContextOptions
.Warnings), parseOptions: TestOptions.Regular8);
8610
comp = CreateCompilation("", options: WithNullable(
NullableContextOptions
.Disable), parseOptions: TestOptions.Regular8);
8613
comp = CreateCompilation(new string[] { }, options: WithNullable(
NullableContextOptions
.Enable), parseOptions: TestOptions.Regular7_3);
8616
comp = CreateCompilation(new string[] { }, options: WithNullable(
NullableContextOptions
.Enable), parseOptions: TestOptions.Regular8);
8619
comp = CreateCompilation(new string[] { }, options: WithNullable(
NullableContextOptions
.Warnings), parseOptions: TestOptions.Regular7_3);
8622
comp = CreateCompilation(new string[] { }, options: WithNullable(
NullableContextOptions
.Warnings), parseOptions: TestOptions.Regular8);
8625
comp = CreateCompilation(new string[] { }, options: WithNullable(
NullableContextOptions
.Disable), parseOptions: TestOptions.Regular7_3);
8628
comp = CreateCompilation(new string[] { }, options: WithNullable(
NullableContextOptions
.Disable), parseOptions: TestOptions.Regular8);
32070
options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Enable));
98649
var comp3 = CreateCompilation(new[] { source2 }, references: new[] { comp2.ToMetadataReference() }, options: WithNullable(
NullableContextOptions
.Warnings), parseOptions: TestOptions.Regular8);
99337
var comp3 = CreateCompilation(new[] { source2 }, references: new[] { comp2.ToMetadataReference() }, options: WithNullable(
NullableContextOptions
.Warnings), parseOptions: TestOptions.Regular8);
100114
var comp3 = CreateCompilation(new[] { source2 }, references: new[] { comp2.ToMetadataReference() }, options: WithNullable(
NullableContextOptions
.Warnings));
100233
var comp3 = CreateCompilation(new[] { source2 }, references: new[] { comp2.ToMetadataReference() }, options: WithNullable(
NullableContextOptions
.Warnings));
101370
var comp2 = CreateCompilation(source2, options: WithNullable(
NullableContextOptions
.Warnings), references: new[] { reference });
111692
string bangOrEmpty = comp0.Options.NullableContextOptions ==
NullableContextOptions
.Disable ? "" : "!";
113222
assertNonNullTypesContext(source1,
NullableContextOptions
.Disable);
113223
assertNonNullTypesContext(source1,
NullableContextOptions
.Warnings);
113225
assertNonNullTypesContext(source2,
NullableContextOptions
.Disable);
113226
assertNonNullTypesContext(source2,
NullableContextOptions
.Warnings);
113228
void assertNonNullTypesContext(string source,
NullableContextOptions
nullableContextOptions)
113288
assertNonNullTypesContext(source1,
NullableContextOptions
.Disable);
113289
assertNonNullTypesContext(source1,
NullableContextOptions
.Warnings);
113291
assertNonNullTypesContext(source2,
NullableContextOptions
.Disable);
113292
assertNonNullTypesContext(source2,
NullableContextOptions
.Warnings);
113294
void assertNonNullTypesContext(string source,
NullableContextOptions
nullableContextOptions)
113360
assertNonNullTypesContext(source1,
NullableContextOptions
.Disable);
113361
assertNonNullTypesContext(source1,
NullableContextOptions
.Warnings);
113363
assertNonNullTypesContext(source2,
NullableContextOptions
.Disable);
113364
assertNonNullTypesContext(source2,
NullableContextOptions
.Warnings);
113366
void assertNonNullTypesContext(string source,
NullableContextOptions
nullableContextOptions)
113415
assertNonNullTypesContext(
NullableContextOptions
.Disable);
113416
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
113418
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
113470
assertNonNullTypesContext(
NullableContextOptions
.Disable);
113471
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
113473
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
113525
assertNonNullTypesContext(
NullableContextOptions
.Disable);
113526
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
113528
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
113583
assertNonNullTypesContext(
NullableContextOptions
.Disable);
113584
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
113586
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
113641
assertNonNullTypesContext(
NullableContextOptions
.Disable);
113642
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
113644
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
113684
assertNonNullTypesContext(
NullableContextOptions
.Disable);
113685
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
113687
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
113739
assertNonNullTypesContext(
NullableContextOptions
.Disable);
113740
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
113742
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
113793
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Enable, type, "A<System.String!>");
113796
private static void AssertGetSpeculativeTypeInfo(string source,
NullableContextOptions
nullableContextOptions, TypeSyntax type, string expected)
113830
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Disable, type, "A<System.String>");
113831
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Warnings, type, "A<System.String>");
113856
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Enable, type, "A<System.String>");
113881
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Disable, type, "A<System.String!>");
113882
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Warnings, type, "A<System.String!>");
113909
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Enable, type, "A<System.String>");
113936
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Disable, type, "A<System.String!>");
113937
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Warnings, type, "A<System.String!>");
113965
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Enable, type, "A<System.String!>");
113993
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Disable, type, "A<System.String>");
113994
AssertGetSpeculativeTypeInfo(source,
NullableContextOptions
.Warnings, type, "A<System.String>");
114018
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Enable, type, "A<System.String!>!");
114021
private static void AssertTryGetSpeculativeSemanticModel(string source,
NullableContextOptions
nullableContextOptions, TypeSyntax type, string expected)
114056
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Disable, type, "A<System.String>");
114057
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Warnings, type, "A<System.String>!");
114082
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Enable, type, "A<System.String>");
114107
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Disable, type, "A<System.String!>!");
114108
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Warnings, type, "A<System.String!>!");
114135
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Enable, type, "A<System.String>");
114162
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Disable, type, "A<System.String!>!");
114163
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Warnings, type, "A<System.String!>!");
114191
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Enable, type, "A<System.String!>!");
114219
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Disable, type, "A<System.String>");
114220
AssertTryGetSpeculativeSemanticModel(source,
NullableContextOptions
.Warnings, type, "A<System.String>");
114241
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114242
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114244
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114299
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114300
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114302
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114360
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114361
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114363
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114418
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114419
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114421
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114454
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114455
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114457
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114491
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114492
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114494
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114527
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114528
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114530
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114557
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114558
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114560
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114589
assertNonNullTypesContext(
NullableContextOptions
.Disable);
114590
assertNonNullTypesContext(
NullableContextOptions
.Warnings);
114592
void assertNonNullTypesContext(
NullableContextOptions
nullableContextOptions)
114622
assertType(
NullableContextOptions
.Enable);
114624
void assertType(
NullableContextOptions
nullableContextOptions)
114653
assertType(
NullableContextOptions
.Enable);
114655
void assertType(
NullableContextOptions
nullableContextOptions)
114683
assertType(
NullableContextOptions
.Enable);
114685
void assertType(
NullableContextOptions
nullableContextOptions)
114714
assertType(
NullableContextOptions
.Enable);
114716
void assertType(
NullableContextOptions
nullableContextOptions)
114744
assertType(
NullableContextOptions
.Enable);
114746
void assertType(
NullableContextOptions
nullableContextOptions)
114773
assertType(
NullableContextOptions
.Enable);
114775
void assertType(
NullableContextOptions
nullableContextOptions)
123810
comp = CreateCompilation(new[] { source }, options: WithNullable(
NullableContextOptions
.Warnings));
123820
comp = CreateCompilation(new[] { source }, options: WithNullable(
NullableContextOptions
.Annotations));
125119
assertDiagnosticOptions(
NullableContextOptions
.Enable);
125120
assertDiagnosticOptions(
NullableContextOptions
.Warnings);
125122
void assertDiagnosticOptions(
NullableContextOptions
nullableContextOptions)
125302
assertDiagnosticOptions(
NullableContextOptions
.Disable);
125303
assertDiagnosticOptions(
NullableContextOptions
.Enable);
125304
assertDiagnosticOptions(
NullableContextOptions
.Warnings);
125305
assertDiagnosticOptions(
NullableContextOptions
.Annotations);
125307
void assertDiagnosticOptions(
NullableContextOptions
nullableContextOptions)
125451
assertDiagnosticOptions(
NullableContextOptions
.Disable);
125452
assertDiagnosticOptions(
NullableContextOptions
.Enable);
125453
assertDiagnosticOptions(
NullableContextOptions
.Warnings);
125454
assertDiagnosticOptions(
NullableContextOptions
.Annotations);
125456
void assertDiagnosticOptions(
NullableContextOptions
nullableContextOptions)
125990
assertDiagnosticOptions1(
NullableContextOptions
.Enable);
125991
assertDiagnosticOptions1(
NullableContextOptions
.Warnings);
125993
assertDiagnosticOptions2(
NullableContextOptions
.Disable);
125994
assertDiagnosticOptions2(
NullableContextOptions
.Annotations);
125996
void assertDiagnosticOptions1(
NullableContextOptions
nullableContextOptions)
126071
void assertDiagnosticOptions2(
NullableContextOptions
nullableContextOptions)
126136
assertDiagnosticOptions(
NullableContextOptions
.Disable);
126137
assertDiagnosticOptions(
NullableContextOptions
.Enable);
126138
assertDiagnosticOptions(
NullableContextOptions
.Warnings);
126139
assertDiagnosticOptions(
NullableContextOptions
.Annotations);
126141
void assertDiagnosticOptions(
NullableContextOptions
nullableContextOptions)
157871
var comp = CreateCompilation(src, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Enable));
Semantics\SemanticErrorTests.cs (2)
7628
public void WriteOfReadonlyStaticMemberOfAnotherInstantiation03(
NullableContextOptions
nullableContextOptions)
22592
CreateCompilationWithMscorlib40(source, references: new[] { Net40.References.SystemCore }, options: TestOptions.ReleaseDll.WithNullableContextOptions(
NullableContextOptions
.Disable)).VerifyDiagnostics(
Semantics\TopLevelStatementsTests.cs (2)
183
comp = CreateCompilation(text1, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Enable), parseOptions: DefaultParseOptions);
308
comp = CreateCompilation(new[] { text1, text2 }, options: TestOptions.DebugExe.WithNullableContextOptions(
NullableContextOptions
.Enable), parseOptions: DefaultParseOptions);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (14)
Compilation\CSharpCompilationOptionsTests.cs (6)
141
TestProperty((old, value) => old.WithNullableContextOptions(value), opt => opt.NullableContextOptions,
NullableContextOptions
.Enable);
415
NullableContextOptions
nullableContextOptions =
NullableContextOptions
.Disable;
454
Assert.Equal(
NullableContextOptions
.Disable, new CSharpCompilationOptions(OutputKind.ConsoleApplication).NullableContextOptions);
456
var values = (
NullableContextOptions
[])System.Enum.GetValues(typeof(
NullableContextOptions
));
Compilation\SemanticModelAPITests.cs (2)
4464
public void TestVarTuple(
NullableContextOptions
nullableContextOption)
4518
public void TestVarTupleWithVarTypeInScope(
NullableContextOptions
nullableContextOption)
DocumentationComments\DocumentationCommentIDTests.cs (2)
402
public void Generic(
NullableContextOptions
nullableContextOptions)
422
public void Generic2(
NullableContextOptions
nullableContextOptions)
Symbols\PartialPropertiesTests.cs (2)
1624
var comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Enable));
1639
comp = CreateCompilation(source, options: TestOptions.DebugDll.WithNullableContextOptions(
NullableContextOptions
.Annotations));
Symbols\Source\ClsComplianceTests.cs (1)
1337
public void WRN_CLS_BadArgType_ConstructedTypeAccessibility(
NullableContextOptions
nullableContextOptions)
Symbols\Source\NullablePublicAPITests.cs (1)
4930
var comp = CreateCompilation(code, options: TestOptions.ReleaseExe.WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.CodeAnalysis.CSharp.Test.Utilities (4)
CSharpTestBase.cs (4)
779
return WithNullable(options,
NullableContextOptions
.Enable);
784
return WithNullable(options,
NullableContextOptions
.Disable);
787
protected static CSharpCompilationOptions WithNullable(
NullableContextOptions
nullableContextOptions)
792
protected static CSharpCompilationOptions WithNullable(CSharpCompilationOptions options,
NullableContextOptions
nullableContextOptions)
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
Serialization\CSharpOptionsSerializationService.cs (2)
56
var
nullableContextOptions = (
NullableContextOptions
)reader.ReadByte();
Microsoft.CodeAnalysis.Rebuild (4)
CSharpCompilationFactory.cs (4)
82
var
nullableOptions = nullable is null
83
?
NullableContextOptions
.Disable
84
: (
NullableContextOptions
)Enum.Parse(typeof(
NullableContextOptions
), nullable);
Microsoft.CodeAnalysis.Rebuild.UnitTests (1)
CSharpDeterministicKeyBuilderTests.cs (1)
274
public void CSharpCompilationOptionsCombination(bool @unsafe,
NullableContextOptions
nullableContextOptions)
Microsoft.CodeAnalysis.VisualBasic (3)
VisualBasicCompilationOptions.vb (3)
1379
Public Overrides Property NullableContextOptions As
NullableContextOptions
1381
Return
NullableContextOptions
.Disable
1383
Protected Set(value As
NullableContextOptions
)
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (5)
Workspaces\TestWorkspace_XmlConsumption.cs (4)
417
var
nullable =
NullableContextOptions
.Disable;
485
nullable = (
NullableContextOptions
)Enum.Parse(typeof(
NullableContextOptions
), nullableAttribute.Value);
Workspaces\TestWorkspace_XmlCreation.cs (1)
178
if (options.NullableContextOptions !=
NullableContextOptions
.Disable)
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
SolutionTests\SolutionTests.cs (1)
4831
.WithProjectCompilationOptions(projectId, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.Gen.ComplianceReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
84
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.Gen.ContextualOptions.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
84
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.Gen.Logging.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
84
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.Gen.Metrics.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
84
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.Gen.MetricsReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
84
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary).WithNullableContextOptions(
NullableContextOptions
.Enable));
Microsoft.VisualStudio.LanguageServices.CSharp (3)
Utilities\CSharpCompilationOptionsChangingService.cs (3)
48
NullableContextOptions
.Enable => "enable",
49
NullableContextOptions
.Warnings => "warnings",
50
NullableContextOptions
.Annotations => "annotations",