提交 73c70055 编写于 作者: F Fred Silberberg 提交者: Andy Gocke

Add nullable context api definitions (#37017)

Adds a public API, `NullableContext GetNullableContext(int position)`, for determining the nullable context at a particular file location, and types supporting that API.
上级 bef76eed
......@@ -36,7 +36,7 @@ public sealed class CSharpCompilationOptions : CompilationOptions, IEquatable<CS
/// <summary>
/// Global Nullable context options.
/// </summary>
public NullableContextOptions NullableContextOptions { get; private set; }
public override NullableContextOptions NullableContextOptions { get; protected set; }
// Defaults correspond to the compiler's defaults or indicate that the user did not specify when that is significant.
// That's significant when one option depends on another's setting. SubsystemVersion depends on Platform and Target.
......
......@@ -5024,6 +5024,27 @@ protected sealed override bool IsEventUsableAsFieldCore(int position, IEventSymb
return this.IsEventUsableAsField(position, symbol.EnsureCSharpSymbolOrNull<IEventSymbol, EventSymbol>(nameof(symbol)));
}
public sealed override NullableContext GetNullableContext(int position)
{
var syntaxTree = (CSharpSyntaxTree)Root.SyntaxTree;
NullableContextState contextState = syntaxTree.GetNullableContextState(position);
var defaultState = syntaxTree.IsGeneratedCode() ? NullableContextOptions.Disable : Compilation.Options.NullableContextOptions;
NullableContext context = getFlag(contextState.AnnotationsState, defaultState.AnnotationsEnabled(), NullableContext.AnnotationsContextInherited, NullableContext.AnnotationsEnabled);
context |= getFlag(contextState.WarningsState, defaultState.WarningsEnabled(), NullableContext.WarningsContextInherited, NullableContext.WarningsEnabled);
return context;
static NullableContext getFlag(bool? contextState, bool defaultEnableState, NullableContext inheritedFlag, NullableContext enableFlag) =>
contextState switch
{
null when defaultEnableState => (inheritedFlag | enableFlag),
null => inheritedFlag,
true => enableFlag,
false => NullableContext.Disabled
};
}
#endregion
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.CSharp
{
/// <summary>
/// Specifies the nullable context.
/// </summary>
public enum NullableContextOptions : byte
{
/// <summary>
/// Nullable annotation and warning contexts are disabled.
/// </summary>
Disable,
/// <summary>
/// Nullable annotation and warning contexts are enabled.
/// </summary>
Enable,
/// <summary>
/// Nullable annotation context is disabled and the nullable warning context is enabled.
/// </summary>
Warnings,
/// <summary>
/// Nullable annotation context is enabled and the nullable warning context is disabled.
/// </summary>
Annotations
}
}
......@@ -17,7 +17,8 @@
*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax>
*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.IncompleteMemberSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax>
*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.IncompleteMemberSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList
Microsoft.CodeAnalysis.CSharp.NullableContextOptions.Annotations = 3 -> Microsoft.CodeAnalysis.CSharp.NullableContextOptions
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, bool reportSuppressedDiagnostics = false, string moduleName = null, string mainTypeName = null, string scriptClassName = null, System.Collections.Generic.IEnumerable<string> usings = null, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel = Microsoft.CodeAnalysis.OptimizationLevel.Debug, bool checkOverflow = false, bool allowUnsafe = false, string cryptoKeyContainer = null, string cryptoKeyFile = null, System.Collections.Immutable.ImmutableArray<byte> cryptoPublicKey = default(System.Collections.Immutable.ImmutableArray<byte>), bool? delaySign = null, Microsoft.CodeAnalysis.Platform platform = Microsoft.CodeAnalysis.Platform.AnyCpu, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption = Microsoft.CodeAnalysis.ReportDiagnostic.Default, int warningLevel = 4, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.CodeAnalysis.ReportDiagnostic>> specificDiagnosticOptions = null, bool concurrentBuild = true, bool deterministic = false, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver = null, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver = null, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver = null, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer = null, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider = null, bool publicSign = false, Microsoft.CodeAnalysis.MetadataImportOptions metadataImportOptions = Microsoft.CodeAnalysis.MetadataImportOptions.Public, Microsoft.CodeAnalysis.NullableContextOptions nullableContextOptions = Microsoft.CodeAnalysis.NullableContextOptions.Disable) -> void
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithNullableContextOptions(Microsoft.CodeAnalysis.NullableContextOptions options) -> Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions
Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax.SemicolonToken.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax> attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken eventKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.AccessorListSyntax accessorList, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList<Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax> attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken eventKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax
......@@ -30,17 +31,10 @@ Microsoft.CodeAnalysis.CSharp.SyntaxKind.AnnotationsKeyword = 8489 -> Microsoft.
Microsoft.CodeAnalysis.CSharp.SyntaxKind.WarningsKeyword = 8488 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind
abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.AwaitKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.CSharp.Conversion.IsSwitchExpression.get -> bool
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, bool reportSuppressedDiagnostics = false, string moduleName = null, string mainTypeName = null, string scriptClassName = null, System.Collections.Generic.IEnumerable<string> usings = null, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel = Microsoft.CodeAnalysis.OptimizationLevel.Debug, bool checkOverflow = false, bool allowUnsafe = false, string cryptoKeyContainer = null, string cryptoKeyFile = null, System.Collections.Immutable.ImmutableArray<byte> cryptoPublicKey = default(System.Collections.Immutable.ImmutableArray<byte>), bool? delaySign = null, Microsoft.CodeAnalysis.Platform platform = Microsoft.CodeAnalysis.Platform.AnyCpu, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption = Microsoft.CodeAnalysis.ReportDiagnostic.Default, int warningLevel = 4, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.CodeAnalysis.ReportDiagnostic>> specificDiagnosticOptions = null, bool concurrentBuild = true, bool deterministic = false, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver = null, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver = null, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver = null, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer = null, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider = null, bool publicSign = false, Microsoft.CodeAnalysis.MetadataImportOptions metadataImportOptions = Microsoft.CodeAnalysis.MetadataImportOptions.Public, Microsoft.CodeAnalysis.CSharp.NullableContextOptions nullableContextOptions = Microsoft.CodeAnalysis.CSharp.NullableContextOptions.Disable) -> void
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, bool reportSuppressedDiagnostics, string moduleName, string mainTypeName, string scriptClassName, System.Collections.Generic.IEnumerable<string> usings, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel, bool checkOverflow, bool allowUnsafe, string cryptoKeyContainer, string cryptoKeyFile, System.Collections.Immutable.ImmutableArray<byte> cryptoPublicKey, bool? delaySign, Microsoft.CodeAnalysis.Platform platform, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption, int warningLevel, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, Microsoft.CodeAnalysis.ReportDiagnostic>> specificDiagnosticOptions, bool concurrentBuild, bool deterministic, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider, bool publicSign, Microsoft.CodeAnalysis.MetadataImportOptions metadataImportOptions) -> void
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.NullableContextOptions.get -> Microsoft.CodeAnalysis.CSharp.NullableContextOptions
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithNullableContextOptions(Microsoft.CodeAnalysis.CSharp.NullableContextOptions options) -> Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions
Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp8 = 800 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
Microsoft.CodeAnalysis.CSharp.LanguageVersion.LatestMajor = 2147483645 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
Microsoft.CodeAnalysis.CSharp.LanguageVersion.Preview = 2147483646 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion
Microsoft.CodeAnalysis.CSharp.NullableContextOptions
Microsoft.CodeAnalysis.CSharp.NullableContextOptions.Disable = 0 -> Microsoft.CodeAnalysis.CSharp.NullableContextOptions
Microsoft.CodeAnalysis.CSharp.NullableContextOptions.Enable = 1 -> Microsoft.CodeAnalysis.CSharp.NullableContextOptions
Microsoft.CodeAnalysis.CSharp.NullableContextOptions.Warnings = 2 -> Microsoft.CodeAnalysis.CSharp.NullableContextOptions
Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax.WithAsyncKeyword(Microsoft.CodeAnalysis.SyntaxToken asyncKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax.WithBody(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode body) -> Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.BaseArgumentListSyntax.AddArguments(params Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseArgumentListSyntax
......@@ -245,6 +239,7 @@ Microsoft.CodeAnalysis.CSharp.SyntaxKind.VarPattern = 9027 -> Microsoft.CodeAnal
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ClassifyCommonConversion(Microsoft.CodeAnalysis.ITypeSymbol source, Microsoft.CodeAnalysis.ITypeSymbol destination) -> Microsoft.CodeAnalysis.Operations.CommonConversion
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ContainsSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> bool
override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.ISymbol>
override Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.NullableContextOptions.get -> Microsoft.CodeAnalysis.NullableContextOptions
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitDiscardPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitNullableDirectiveTrivia(Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode
override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitPositionalPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Semantics
{
public class NullableContextTests : CSharpTestBase
{
[InlineData("#nullable enable", NullableContextOptions.Disable, NullableContext.Enabled)]
[InlineData("#nullable enable", NullableContextOptions.Annotations, NullableContext.Enabled)]
[InlineData("#nullable enable", NullableContextOptions.Warnings, NullableContext.Enabled)]
[InlineData("#nullable enable", NullableContextOptions.Enable, NullableContext.Enabled)]
[InlineData("#nullable enable warnings", NullableContextOptions.Disable, NullableContext.WarningsEnabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable enable warnings", NullableContextOptions.Warnings, NullableContext.WarningsEnabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable enable warnings", NullableContextOptions.Annotations, NullableContext.Enabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable enable warnings", NullableContextOptions.Enable, NullableContext.Enabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable enable annotations", NullableContextOptions.Disable, NullableContext.AnnotationsEnabled | NullableContext.WarningsContextInherited)]
[InlineData("#nullable enable annotations", NullableContextOptions.Warnings, NullableContext.Enabled | NullableContext.WarningsContextInherited)]
[InlineData("#nullable enable annotations", NullableContextOptions.Annotations, NullableContext.AnnotationsEnabled | NullableContext.WarningsContextInherited)]
[InlineData("#nullable enable annotations", NullableContextOptions.Enable, NullableContext.Enabled | NullableContext.WarningsContextInherited)]
[InlineData("#nullable disable", NullableContextOptions.Disable, NullableContext.Disabled)]
[InlineData("#nullable disable", NullableContextOptions.Annotations, NullableContext.Disabled)]
[InlineData("#nullable disable", NullableContextOptions.Warnings, NullableContext.Disabled)]
[InlineData("#nullable disable", NullableContextOptions.Enable, NullableContext.Disabled)]
[InlineData("#nullable disable warnings", NullableContextOptions.Disable, NullableContext.Disabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable disable warnings", NullableContextOptions.Warnings, NullableContext.Disabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable disable warnings", NullableContextOptions.Annotations, NullableContext.AnnotationsEnabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable disable warnings", NullableContextOptions.Enable, NullableContext.AnnotationsEnabled | NullableContext.AnnotationsContextInherited)]
[InlineData("#nullable disable annotations", NullableContextOptions.Disable, NullableContext.Disabled | NullableContext.WarningsContextInherited)]
[InlineData("#nullable disable annotations", NullableContextOptions.Warnings, NullableContext.WarningsEnabled | NullableContext.WarningsContextInherited)]
[InlineData("#nullable disable annotations", NullableContextOptions.Annotations, NullableContext.Disabled | NullableContext.WarningsContextInherited)]
[InlineData("#nullable disable annotations", NullableContextOptions.Enable, NullableContext.WarningsEnabled | NullableContext.WarningsContextInherited)]
[Theory]
public void NullableContextExplicitlySpecifiedAndRestoredInFile(string pragma, NullableContextOptions globalContext, NullableContext expectedContext)
{
var source = $@"
{pragma}
class C
{{
#nullable restore
void M() {{}}
}}";
var comp = CreateCompilation(source, options: WithNonNullTypes(globalContext));
var syntaxTree = comp.SyntaxTrees[0];
var model = comp.GetSemanticModel(syntaxTree);
var classDeclPosition = syntaxTree.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>().Single().SpanStart;
var methodDeclPosition = syntaxTree.GetRoot().DescendantNodes().OfType<MethodDeclarationSyntax>().Single().SpanStart;
Assert.Equal(expectedContext, model.GetNullableContext(classDeclPosition));
// The context at the start of the file should always be inherited and match the global context
var restoredContext = ((NullableContext)globalContext) | NullableContext.ContextInherited;
Assert.Equal(restoredContext, model.GetNullableContext(0));
Assert.Equal(restoredContext, model.GetNullableContext(methodDeclPosition));
}
[Fact]
public void NullableContextMultipleFiles()
{
var source1 = @"
#nullable enable
partial class C
{
void M1() {};
}";
var source2 = @"
partial class C
{
#nullable enable
void M2();
}";
var comp = CreateCompilation(new[] { source1, source2 }, options: WithNonNullTypesTrue());
var syntaxTree1 = comp.SyntaxTrees[0];
var model1 = comp.GetSemanticModel(syntaxTree1);
var syntaxTree2 = comp.SyntaxTrees[1];
var model2 = comp.GetSemanticModel(syntaxTree2);
var classDecl1 = syntaxTree1.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>().Single().SpanStart;
var classDecl2 = syntaxTree2.GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>().Single().SpanStart;
Assert.Equal(NullableContext.Enabled, model1.GetNullableContext(classDecl1));
Assert.Equal(NullableContext.Enabled | NullableContext.ContextInherited, model2.GetNullableContext(classDecl2));
}
[Fact]
public void NullableContextOptionsFlags()
{
Assert.True(NullableContextOptions.Enable.AnnotationsEnabled());
Assert.True(NullableContextOptions.Enable.WarningsEnabled());
Assert.True(NullableContextOptions.Annotations.AnnotationsEnabled());
Assert.False(NullableContextOptions.Annotations.WarningsEnabled());
Assert.False(NullableContextOptions.Warnings.AnnotationsEnabled());
Assert.True(NullableContextOptions.Warnings.WarningsEnabled());
Assert.False(NullableContextOptions.Disable.AnnotationsEnabled());
Assert.False(NullableContextOptions.Disable.WarningsEnabled());
}
[Fact]
public void NullableContextFlags()
{
AssertEnabledForInheritence(NullableContext.Disabled, warningsEnabled: false, annotationsEnabled: false);
AssertEnabledForInheritence(NullableContext.WarningsEnabled, warningsEnabled: true, annotationsEnabled: false);
AssertEnabledForInheritence(NullableContext.AnnotationsEnabled, warningsEnabled: false, annotationsEnabled: true);
AssertEnabledForInheritence(NullableContext.Enabled, warningsEnabled: true, annotationsEnabled: true);
void AssertEnabledForInheritence(NullableContext context, bool warningsEnabled, bool annotationsEnabled)
{
Assert.Equal(warningsEnabled, context.WarningsEnabled());
Assert.Equal(annotationsEnabled, context.AnnotationsEnabled());
Assert.False(context.WarningsInherited());
Assert.False(context.AnnotationsInherited());
var warningsInherited = context | NullableContext.WarningsContextInherited;
Assert.Equal(warningsEnabled, warningsInherited.WarningsEnabled());
Assert.Equal(annotationsEnabled, warningsInherited.AnnotationsEnabled());
Assert.True(warningsInherited.WarningsInherited());
Assert.False(warningsInherited.AnnotationsInherited());
var annotationsInherited = context | NullableContext.AnnotationsContextInherited;
Assert.Equal(warningsEnabled, annotationsInherited.WarningsEnabled());
Assert.Equal(annotationsEnabled, annotationsInherited.AnnotationsEnabled());
Assert.False(annotationsInherited.WarningsInherited());
Assert.True(annotationsInherited.AnnotationsInherited());
var contextInherited = context | NullableContext.ContextInherited;
Assert.Equal(warningsEnabled, contextInherited.WarningsEnabled());
Assert.Equal(annotationsEnabled, contextInherited.AnnotationsEnabled());
Assert.True(contextInherited.WarningsInherited());
Assert.True(contextInherited.AnnotationsInherited());
}
}
}
}
......@@ -134,6 +134,7 @@ public void Invariants()
TestProperty((old, value) => old.WithTopLevelBinderFlags(value), opt => opt.TopLevelBinderFlags, BinderFlags.IgnoreCorLibraryDuplicatedTypes);
TestProperty((old, value) => old.WithMetadataImportOptions(value), opt => opt.MetadataImportOptions, MetadataImportOptions.Internal);
TestProperty((old, value) => old.WithReferencesSupersedeLowerVersions(value), opt => opt.ReferencesSupersedeLowerVersions, true);
TestProperty((old, value) => old.WithNullableContextOptions(value), opt => opt.NullableContextOptions, NullableContextOptions.Enable);
}
[Fact]
......
......@@ -37,6 +37,7 @@ public void TestFieldsForEqualsAndGetHashCode()
"MetadataImportOptions",
"MetadataReferenceResolver",
"ModuleName",
"NullableContextOptions",
"OptimizationLevel",
"OutputKind",
"Platform",
......
......@@ -233,6 +233,15 @@ public abstract class CompilationOptions
/// </summary>
public AssemblyIdentityComparer AssemblyIdentityComparer { get; protected set; }
/// <summary>
/// Gets the default nullable context state in this compilation.
/// </summary>
/// <remarks>
/// This context does not apply to files that are marked as generated. Nullable is off
/// by default in those locations.
/// </remarks>
public abstract NullableContextOptions NullableContextOptions { get; protected set; }
/// <summary>
/// A set of strings designating experimental compiler features that are to be enabled.
/// </summary>
......@@ -624,7 +633,8 @@ protected bool EqualsHelper(CompilationOptions other)
object.Equals(this.SourceReferenceResolver, other.SourceReferenceResolver) &&
object.Equals(this.StrongNameProvider, other.StrongNameProvider) &&
object.Equals(this.AssemblyIdentityComparer, other.AssemblyIdentityComparer) &&
this.PublicSign == other.PublicSign;
this.PublicSign == other.PublicSign &&
this.NullableContextOptions == other.NullableContextOptions;
return equal;
}
......@@ -658,7 +668,8 @@ protected int GetHashCodeHelper()
Hash.Combine(this.SourceReferenceResolver,
Hash.Combine(this.StrongNameProvider,
Hash.Combine(this.AssemblyIdentityComparer,
Hash.Combine(this.PublicSign, 0))))))))))))))))))))))))));
Hash.Combine(this.PublicSign,
Hash.Combine((int)this.NullableContextOptions, 0)))))))))))))))))))))))))));
}
public static bool operator ==(CompilationOptions left, CompilationOptions right)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#nullable enable
using System;
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Represents the state of the nullable analysis at a specific point in a file. Bits one and
/// two correspond to whether the nullable feature is enabled. Bits three and four correspond
/// to whether the context was inherited from the global context.
/// </summary>
[Flags]
public enum NullableContext
{
/// <summary>
/// Nullable warnings and annotations are explicitly turned off at this location.
/// </summary>
Disabled = 0,
/// <summary>
/// Nullable warnings are enabled and will be reported at this file location.
/// </summary>
WarningsEnabled = 1,
/// <summary>
/// Nullable annotations are enabled and will be shown when APIs defined at
/// this location are used in other contexts.
/// </summary>
AnnotationsEnabled = 1 << 1,
/// <summary>
/// The nullable feature is fully enabled.
/// </summary>
Enabled = WarningsEnabled | AnnotationsEnabled,
/// <summary>
/// The nullable warning state is inherited from the project default.
/// </summary>
/// <remarks>
/// The project default can change depending on the file type. Generated
/// files have nullable off by default, regardless of of the project-level
/// default setting.
/// </remarks>
WarningsContextInherited = 1 << 2,
/// <summary>
/// The nullable annotation state is inherited from the project default.
/// </summary>
/// <remarks>
/// The project default can change depending on the file type. Generated
/// files have nullable off by default, regardless of of the project-level
/// default setting.
/// </remarks>
AnnotationsContextInherited = 1 << 3,
/// <summary>
/// The current state of both warnings and annotations are inherited from
/// the project default.
/// </summary>
/// <remarks>
/// This flag is set by default at the start of all files.
///
/// The project default can change depending on the file type. Generated
/// files have nullable off by default, regardless of of the project-level
/// default setting.
/// </remarks>
ContextInherited = WarningsContextInherited | AnnotationsContextInherited
}
public static class NullableContextExtensions
{
private static bool IsFlagSet(NullableContext context, NullableContext flag) =>
(context & flag) == flag;
/// <summary>
/// Returns whether nullable warnings are enabled for this context.
/// </summary>
public static bool WarningsEnabled(this NullableContext context) =>
IsFlagSet(context, NullableContext.WarningsEnabled);
/// <summary>
/// Returns whether nullable annotations are enabled for this context.
/// </summary>
public static bool AnnotationsEnabled(this NullableContext context) =>
IsFlagSet(context, NullableContext.AnnotationsEnabled);
/// <summary>
/// Returns whether the nullable warning state was inherited from the project default for this file type.
/// </summary>
public static bool WarningsInherited(this NullableContext context) =>
IsFlagSet(context, NullableContext.WarningsContextInherited);
/// <summary>
/// Returns whether the nullable annotation state was inherited from the project default for this file type.
/// </summary>
public static bool AnnotationsInherited(this NullableContext context) =>
IsFlagSet(context, NullableContext.AnnotationsContextInherited);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#nullable enable
using System;
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Represents the default state of nullable analysis in this compilation.
/// </summary>
[Flags]
public enum NullableContextOptions
{
/// <summary>
/// The nullable analysis feature is disabled.
/// </summary>
Disable = 0,
/// <summary>
/// Nullable warnings are enabled and will be reported by default.
/// </summary>
Warnings = 1,
/// <summary>
/// Nullable annotations are enabled and will be shown when APIs
/// defined in this project are used in other contexts.
/// </summary>
Annotations = 1 << 1,
/// <summary>
/// The nullable analysis feature is fully enabled.
/// </summary>
Enable = Warnings | Annotations,
}
public static class NullableContextOptionsExtensions
{
private static bool IsFlagSet(NullableContextOptions context, NullableContextOptions flag) =>
(context & flag) == flag;
/// <summary>
/// Returns whether nullable warnings are enabled.
/// </summary>
public static bool WarningsEnabled(this NullableContextOptions context) =>
IsFlagSet(context, NullableContextOptions.Warnings);
/// <summary>
/// Returns whether nullable annotations are enabled.
/// </summary>
public static bool AnnotationsEnabled(this NullableContextOptions context) =>
IsFlagSet(context, NullableContextOptions.Annotations);
}
}
......@@ -888,5 +888,11 @@ protected internal virtual SyntaxNode GetTopmostNodeForDiagnosticAnalysis(ISymbo
/// Root of this semantic model
/// </summary>
protected abstract SyntaxNode RootCore { get; }
/// <summary>
/// Gets the <see cref="NullableContext"/> at a position in the file.
/// </summary>
/// <param name="position">The position to get the context for.</param>
public abstract NullableContext GetNullableContext(int position);
}
}
......@@ -15,6 +15,8 @@ Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(Microsoft.CodeAnalysis.
*REMOVED*Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ITypeSymbol> elementTypes, System.Collections.Immutable.ImmutableArray<string> elementNames = default(System.Collections.Immutable.ImmutableArray<string>), System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Location> elementLocations = default(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Location>)) -> Microsoft.CodeAnalysis.INamedTypeSymbol
Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ITypeSymbol> elementTypes, System.Collections.Immutable.ImmutableArray<string> elementNames = default(System.Collections.Immutable.ImmutableArray<string>), System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Location> elementLocations = default(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Location>), System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.NullableAnnotation> elementNullableAnnotations = default(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.NullableAnnotation>)) -> Microsoft.CodeAnalysis.INamedTypeSymbol
Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.ITypeSymbol> elementTypes, System.Collections.Immutable.ImmutableArray<string> elementNames, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Location> elementLocations) -> Microsoft.CodeAnalysis.INamedTypeSymbol
Microsoft.CodeAnalysis.Compilation.HasImplicitConversion(Microsoft.CodeAnalysis.ITypeSymbol fromType, Microsoft.CodeAnalysis.ITypeSymbol toType) -> bool
Microsoft.CodeAnalysis.Compilation.IsSymbolAccessibleWithin(Microsoft.CodeAnalysis.ISymbol symbol, Microsoft.CodeAnalysis.ISymbol within, Microsoft.CodeAnalysis.ITypeSymbol throughType = null) -> bool
Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor
Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor.DiagnosticSuppressor() -> void
Microsoft.CodeAnalysis.Diagnostics.Suppression
......@@ -56,6 +58,21 @@ Microsoft.CodeAnalysis.NullableAnnotation.Annotated = 3 -> Microsoft.CodeAnalysi
Microsoft.CodeAnalysis.NullableAnnotation.Disabled = 1 -> Microsoft.CodeAnalysis.NullableAnnotation
Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated = 2 -> Microsoft.CodeAnalysis.NullableAnnotation
Microsoft.CodeAnalysis.NullableAnnotation.NotApplicable = 0 -> Microsoft.CodeAnalysis.NullableAnnotation
Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContext.AnnotationsContextInherited = 8 -> Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContext.AnnotationsEnabled = 2 -> Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContext.ContextInherited = Microsoft.CodeAnalysis.NullableContext.WarningsContextInherited | Microsoft.CodeAnalysis.NullableContext.AnnotationsContextInherited -> Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContext.Disabled = 0 -> Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContext.Enabled = Microsoft.CodeAnalysis.NullableContext.WarningsEnabled | Microsoft.CodeAnalysis.NullableContext.AnnotationsEnabled -> Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContext.WarningsContextInherited = 4 -> Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContext.WarningsEnabled = 1 -> Microsoft.CodeAnalysis.NullableContext
Microsoft.CodeAnalysis.NullableContextExtensions
Microsoft.CodeAnalysis.NullableContextOptions
Microsoft.CodeAnalysis.NullableContextOptions.Annotations = 2 -> Microsoft.CodeAnalysis.NullableContextOptions
Microsoft.CodeAnalysis.NullableContextOptions.Disable = 0 -> Microsoft.CodeAnalysis.NullableContextOptions
Microsoft.CodeAnalysis.NullableContextOptions.Enable = Microsoft.CodeAnalysis.NullableContextOptions.Warnings | Microsoft.CodeAnalysis.NullableContextOptions.Annotations -> Microsoft.CodeAnalysis.NullableContextOptions
Microsoft.CodeAnalysis.NullableContextOptions.Warnings = 1 -> Microsoft.CodeAnalysis.NullableContextOptions
Microsoft.CodeAnalysis.NullableContextOptionsExtensions
Microsoft.CodeAnalysis.NullableFlowState
Microsoft.CodeAnalysis.NullableFlowState.MaybeNull = 2 -> Microsoft.CodeAnalysis.NullableFlowState
Microsoft.CodeAnalysis.NullableFlowState.NotApplicable = 0 -> Microsoft.CodeAnalysis.NullableFlowState
......@@ -82,6 +99,7 @@ Microsoft.CodeAnalysis.TypeInfo.Nullability.get -> Microsoft.CodeAnalysis.Nullab
abstract Microsoft.CodeAnalysis.Compilation.ClassifyCommonConversion(Microsoft.CodeAnalysis.ITypeSymbol source, Microsoft.CodeAnalysis.ITypeSymbol destination) -> Microsoft.CodeAnalysis.Operations.CommonConversion
abstract Microsoft.CodeAnalysis.Compilation.ContainsSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> bool
abstract Microsoft.CodeAnalysis.Compilation.GetSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.ISymbol>
abstract Microsoft.CodeAnalysis.CompilationOptions.NullableContextOptions.get -> Microsoft.CodeAnalysis.NullableContextOptions
abstract Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions.TryGetValue(string key, out string value) -> bool
abstract Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider.GetOptions(Microsoft.CodeAnalysis.AdditionalText textFile) -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions
abstract Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider.GetOptions(Microsoft.CodeAnalysis.SyntaxTree tree) -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions
......@@ -94,6 +112,7 @@ abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterO
abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterOperationBlockStartAction(System.Action<Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext> action) -> void
abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterSymbolEndAction(System.Action<Microsoft.CodeAnalysis.Diagnostics.SymbolAnalysisContext> action) -> void
abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterSyntaxNodeAction<TLanguageKindEnum>(System.Action<Microsoft.CodeAnalysis.Diagnostics.SyntaxNodeAnalysisContext> action, System.Collections.Immutable.ImmutableArray<TLanguageKindEnum> syntaxKinds) -> void
abstract Microsoft.CodeAnalysis.SemanticModel.GetNullableContext(int position) -> Microsoft.CodeAnalysis.NullableContext
const Microsoft.CodeAnalysis.WellKnownMemberNames.CountPropertyName = "Count" -> string
const Microsoft.CodeAnalysis.WellKnownMemberNames.DisposeAsyncMethodName = "DisposeAsync" -> string
const Microsoft.CodeAnalysis.WellKnownMemberNames.DisposeMethodName = "Dispose" -> string
......@@ -119,8 +138,6 @@ Microsoft.CodeAnalysis.AnalyzerConfigOptionsResult.TreeOptions.get -> System.Col
Microsoft.CodeAnalysis.AnalyzerConfigSet
Microsoft.CodeAnalysis.AnalyzerConfigSet.GetOptionsForSourcePath(string sourcePath) -> Microsoft.CodeAnalysis.AnalyzerConfigOptionsResult
Microsoft.CodeAnalysis.CommandLineArguments.AnalyzerConfigPaths.get -> System.Collections.Immutable.ImmutableArray<string>
Microsoft.CodeAnalysis.Compilation.HasImplicitConversion(Microsoft.CodeAnalysis.ITypeSymbol fromType, Microsoft.CodeAnalysis.ITypeSymbol toType) -> bool
Microsoft.CodeAnalysis.Compilation.IsSymbolAccessibleWithin(Microsoft.CodeAnalysis.ISymbol symbol, Microsoft.CodeAnalysis.ISymbol within, Microsoft.CodeAnalysis.ITypeSymbol throughType = null) -> bool
Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions
Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions.AnalyzerConfigOptions() -> void
Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider
......@@ -330,6 +347,12 @@ static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.Cod
static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.SemanticModel semanticModel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph
static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraphExtensions.GetAnonymousFunctionControlFlowGraphInScope(this Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph controlFlowGraph, Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation anonymousFunction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph
static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraphExtensions.GetLocalFunctionControlFlowGraphInScope(this Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph controlFlowGraph, Microsoft.CodeAnalysis.IMethodSymbol localFunction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph
static Microsoft.CodeAnalysis.NullableContextExtensions.AnnotationsEnabled(this Microsoft.CodeAnalysis.NullableContext context) -> bool
static Microsoft.CodeAnalysis.NullableContextExtensions.AnnotationsInherited(this Microsoft.CodeAnalysis.NullableContext context) -> bool
static Microsoft.CodeAnalysis.NullableContextExtensions.WarningsEnabled(this Microsoft.CodeAnalysis.NullableContext context) -> bool
static Microsoft.CodeAnalysis.NullableContextExtensions.WarningsInherited(this Microsoft.CodeAnalysis.NullableContext context) -> bool
static Microsoft.CodeAnalysis.NullableContextOptionsExtensions.AnnotationsEnabled(this Microsoft.CodeAnalysis.NullableContextOptions context) -> bool
static Microsoft.CodeAnalysis.NullableContextOptionsExtensions.WarningsEnabled(this Microsoft.CodeAnalysis.NullableContextOptions context) -> bool
static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetCorrespondingOperation(this Microsoft.CodeAnalysis.Operations.IBranchOperation operation) -> Microsoft.CodeAnalysis.IOperation
static readonly Microsoft.CodeAnalysis.SyntaxTree.EmptyDiagnosticOptions -> System.Collections.Immutable.ImmutableDictionary<string, Microsoft.CodeAnalysis.ReportDiagnostic>
virtual Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.RegisterSymbolStartAction(System.Action<Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext> action, Microsoft.CodeAnalysis.SymbolKind symbolKind) -> void
......
......@@ -3475,6 +3475,10 @@ _Default:
Return declaringSyntax
End Function
Public NotOverridable Overrides Function GetNullableContext(position As Integer) As NullableContext
Return NullableContext.Disabled Or NullableContext.ContextInherited
End Function
#End Region
#Region "Logging Helpers"
......
......@@ -85,6 +85,7 @@ Overloads Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineArguments.Par
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.ClassifyCommonConversion(source As Microsoft.CodeAnalysis.ITypeSymbol, destination As Microsoft.CodeAnalysis.ITypeSymbol) -> Microsoft.CodeAnalysis.Operations.CommonConversion
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.ContainsSymbolsWithName(name As String, filter As Microsoft.CodeAnalysis.SymbolFilter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, cancellationToken As System.Threading.CancellationToken = Nothing) -> Boolean
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilation.GetSymbolsWithName(name As String, filter As Microsoft.CodeAnalysis.SymbolFilter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, cancellationToken As System.Threading.CancellationToken = Nothing) -> System.Collections.Generic.IEnumerable(Of Microsoft.CodeAnalysis.ISymbol)
Overrides Microsoft.CodeAnalysis.VisualBasic.VisualBasicCompilationOptions.NullableContextOptions() -> Microsoft.CodeAnalysis.NullableContextOptions
Shared Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.CarriageReturn() -> Microsoft.CodeAnalysis.SyntaxTrivia
Shared Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.CarriageReturnLineFeed() -> Microsoft.CodeAnalysis.SyntaxTrivia
Shared Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ElasticCarriageReturn() -> Microsoft.CodeAnalysis.SyntaxTrivia
......
......@@ -4,7 +4,6 @@ Imports System.Collections.Immutable
Imports System.ComponentModel
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.PooledObjects
Imports Roslyn.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
......@@ -1348,5 +1347,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Protected Overrides Function CommonWithCheckOverflow(checkOverflow As Boolean) As CompilationOptions
Return WithOverflowChecks(checkOverflow)
End Function
Public Overrides Property NullableContextOptions As NullableContextOptions
Get
Return NullableContextOptions.Disable
End Get
Protected Set(value As NullableContextOptions)
Throw New NotImplementedException()
End Set
End Property
End Class
End Namespace
......@@ -536,6 +536,7 @@ BC2042: The options /vbruntime* and /target:module cannot be combined.
"OptionCompareText",
"EmbedVbCoreRuntime",
"SuppressEmbeddedDeclarations",
"NullableContextOptions",
"ParseOptions",
"IgnoreCorLibraryDuplicatedTypes")
End Sub
......
......@@ -573,7 +573,7 @@ public void TestEncodingSerialization()
[Fact]
public void TestCompilationOptions_NullableAndImport()
{
var csharpOptions = CSharp.CSharpCompilation.Create("dummy").Options.WithNullableContextOptions(CSharp.NullableContextOptions.Warnings).WithMetadataImportOptions(MetadataImportOptions.All);
var csharpOptions = CSharp.CSharpCompilation.Create("dummy").Options.WithNullableContextOptions(NullableContextOptions.Warnings).WithMetadataImportOptions(MetadataImportOptions.All);
var vbOptions = VisualBasic.VisualBasicCompilation.Create("dummy").Options.WithMetadataImportOptions(MetadataImportOptions.Internal);
var hostServices = MefHostServices.Create(MefHostServices.DefaultAssemblies);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册