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