未验证 提交 7fdcc97a 编写于 作者: R Rikki Gibson 提交者: GitHub

Don't warn about empty initializers on nullable properties in object initializers (#38642)

上级 ec85a192
......@@ -15790,6 +15790,24 @@ internal class CSharpResources {
}
}
/// <summary>
/// Looks up a localized string similar to Object or collection initializer implicitly dereferences possibly null member &apos;{0}&apos;..
/// </summary>
internal static string WRN_NullReferenceInitializer {
get {
return ResourceManager.GetString("WRN_NullReferenceInitializer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Object or collection initializer implicitly dereferences possibly null member..
/// </summary>
internal static string WRN_NullReferenceInitializer_Title {
get {
return ResourceManager.GetString("WRN_NullReferenceInitializer_Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Possible null reference assignment to iteration variable.
/// </summary>
......
......@@ -5753,6 +5753,12 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="WRN_MissingNonNullTypesContextForAnnotationInGeneratedCode_Title" xml:space="preserve">
<value>The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.</value>
</data>
<data name="WRN_NullReferenceInitializer" xml:space="preserve">
<value>Object or collection initializer implicitly dereferences possibly null member '{0}'.</value>
</data>
<data name="WRN_NullReferenceInitializer_Title" xml:space="preserve">
<value>Object or collection initializer implicitly dereferences possibly null member.</value>
</data>
<data name="ERR_ExpressionTreeCantContainRefStruct" xml:space="preserve">
<value>Expression tree cannot contain value of ref struct or restricted type '{0}'.</value>
</data>
......
......@@ -1706,6 +1706,7 @@ internal enum ErrorCode
WRN_NullabilityMismatchInConstraintsOnPartialImplementation = 8667,
ERR_NullableDirectiveTargetExpected = 8668,
WRN_MissingNonNullTypesContextForAnnotationInGeneratedCode = 8669,
WRN_NullReferenceInitializer = 8670,
ERR_MultipleAnalyzerConfigsInSameDir = 8700,
......
......@@ -63,6 +63,7 @@ static ErrorFacts()
builder.Add(getId(ErrorCode.WRN_NullabilityMismatchInInterfaceImplementedByBase));
builder.Add(getId(ErrorCode.WRN_DuplicateInterfaceWithNullabilityMismatchInBaseList));
builder.Add(getId(ErrorCode.WRN_NullabilityMismatchInConstraintsOnPartialImplementation));
builder.Add(getId(ErrorCode.WRN_NullReferenceInitializer));
NullableWarnings = builder.ToImmutable();
......@@ -430,6 +431,7 @@ internal static int GetWarningLevel(ErrorCode code)
case ErrorCode.WRN_UndecoratedCancellationTokenParameter:
case ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint:
case ErrorCode.WRN_DisallowNullAttributeForbidsMaybeNullAssignment:
case ErrorCode.WRN_NullReferenceInitializer:
return 1;
default:
return 0;
......
......@@ -1836,9 +1836,12 @@ private void VisitObjectCreationInitializer(Symbol containingSymbol, int contain
void checkImplicitReceiver()
{
if (containingSlot >= 0)
if (containingSlot >= 0 && (node as BoundObjectInitializerExpressionBase)?.Initializers.Length != 0)
{
_ = ReportPossibleNullReceiverIfNeeded(node.Type, this.State[containingSlot], checkNullableValueType: false, node.Syntax, out _);
if (!node.Type.IsValueType && State[containingSlot].MayBeNull())
{
ReportDiagnostic(ErrorCode.WRN_NullReferenceInitializer, node.Syntax, containingSymbol);
}
}
}
}
......
......@@ -229,6 +229,7 @@ public static bool IsWarning(ErrorCode code)
case ErrorCode.WRN_ImplicitCopyInReadOnlyMember:
case ErrorCode.WRN_NullabilityMismatchInConstraintsOnPartialImplementation:
case ErrorCode.WRN_MissingNonNullTypesContextForAnnotationInGeneratedCode:
case ErrorCode.WRN_NullReferenceInitializer:
case ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint:
return true;
default:
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Může jít o přiřazení s odkazem null.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Možné přiřazení odkazu s hodnotou null k proměnné iterace</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Mögliche Nullverweiszuweisung.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Mögliche Zuweisung eines Nullverweises zu Iterationsvariable</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Posible asignación de referencia nula</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Posible asignación de referencia de tipo NULL a variable de iteración</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Existence possible d'une assignation de référence null.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Affectation d'une éventuelle référence null à la variable d'itération</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Possibile assegnazione di riferimento Null.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Possibile assegnazione di riferimento Null alla variabile di iterazione</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Null 参照割り当ての可能性があります。</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">繰り返し変数に対する null 参照代入の可能性があります</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">가능한 null 참조 할당입니다.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">반복 변수에 대한 가능한 null 참조 할당</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Możliwe przypisanie odwołania o wartości null.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Możliwe przypisanie odwołania o wartości null do zmiennej iteracji</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Possível atribuição de referência nula.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Possível atribuição de referência nula à variável de iteração</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Возможно, присваивание-ссылка, допускающее значение NULL.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Назначение вероятной пустой ссылки переменной итерации</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">Olası null başvuru ataması.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">Yineleme değişkenine olası null başvuru ataması</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">可能的 null 引用赋值。</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">迭代变量的可能的空引用赋值</target>
......
......@@ -1492,6 +1492,16 @@
<target state="translated">可能有 Null 參考指派。</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer">
<source>Object or collection initializer implicitly dereferences possibly null member '{0}'.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceInitializer_Title">
<source>Object or collection initializer implicitly dereferences possibly null member.</source>
<target state="new">Object or collection initializer implicitly dereferences possibly null member.</target>
<note />
</trans-unit>
<trans-unit id="WRN_NullReferenceIterationVariable">
<source>Possible null reference assignment to iteration variable</source>
<target state="translated">反覆運算變數的可能 null 參考指派</target>
......
......@@ -307,15 +307,166 @@ public class C
public B? f;
static void Main()
{
new C() { f = { f2 = null, f3 = null }};
new C() { f = { f2 = null, f3 = null }}; // 1
}
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (12,23): warning CS8602: Dereference of a possibly null reference.
// new C() { f = { f2 = null, f3 = null }};
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "{ f2 = null, f3 = null }").WithLocation(12, 23)
);
// (12,23): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C.f'.
// new C() { f = { f2 = null, f3 = null }}; // 1
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ f2 = null, f3 = null }").WithArguments("C.f").WithLocation(12, 23));
}
[Fact, WorkItem(32495, "https://github.com/dotnet/roslyn/issues/32495")]
public void CheckImplicitObjectInitializerReceiver_Generic()
{
var comp = CreateCompilation(@"
public interface IB
{
object? f2 { get; set; }
object? f3 { get; set; }
}
public struct StructB : IB
{
public object? f2 { get; set; }
public object? f3 { get; set; }
}
public class ClassB : IB
{
public object? f2 { get; set; }
public object? f3 { get; set; }
}
public class C<T> where T : IB?
{
public T f = default!;
static void Main()
{
new C<T>() { f = { f2 = null, f3 = null }}; // 1
new C<ClassB>() { f = { f2 = null, f3 = null }};
new C<ClassB?>() { f = { f2 = null, f3 = null }}; // 2
new C<StructB>() { f = { f2 = null, f3 = null }};
}
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (25,26): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C<T>.f'.
// new C<T>() { f = { f2 = null, f3 = null }}; // 1
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ f2 = null, f3 = null }").WithArguments("C<T>.f").WithLocation(25, 26),
// (27,32): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C<ClassB?>.f'.
// new C<ClassB?>() { f = { f2 = null, f3 = null }}; // 2
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ f2 = null, f3 = null }").WithArguments("C<ClassB?>.f").WithLocation(27, 32));
}
[Fact, WorkItem(38060, "https://github.com/dotnet/roslyn/issues/38060")]
public void CheckImplicitObjectInitializerReceiver_EmptyInitializers()
{
var comp = CreateCompilation(@"
public class B { }
public class C
{
public B? f;
static void Main()
{
new C() { f = { }};
}
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics();
}
[Fact, WorkItem(32495, "https://github.com/dotnet/roslyn/issues/32495")]
public void CheckImplicitObjectInitializerReceiver_CollectionInitializer()
{
var comp = CreateCompilation(@"
using System.Collections;
public class B : IEnumerable
{
public void Add(object o) { }
public IEnumerator GetEnumerator() => null!;
}
public class C
{
public B? f;
static void Main()
{
new C() { f = { new object(), new object() }}; // 1
}
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (15,23): warning CS8670: Object or collection initializer implicitly dereferences nullable member 'C.f'.
// new C() { f = { new object(), new object() }}; // 1
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ new object(), new object() }").WithArguments("C.f").WithLocation(15, 23));
}
[Fact, WorkItem(32495, "https://github.com/dotnet/roslyn/issues/32495")]
public void CheckImplicitObjectInitializerReceiver_CollectionInitializer_Generic()
{
var comp = CreateCompilation(@"
using System.Collections;
public interface IAddable : IEnumerable
{
void Add(object o);
}
public class ClassAddable : IAddable
{
public void Add(object o) { }
public IEnumerator GetEnumerator() => null!;
}
public struct StructAddable : IAddable
{
public void Add(object o) { }
public IEnumerator GetEnumerator() => null!;
}
public class C<T> where T : IAddable?
{
public T f = default!;
static void Main()
{
new C<T>() { f = { new object(), new object() }}; // 1
new C<ClassAddable>() { f = { new object(), new object() }};
new C<ClassAddable?>() { f = { new object(), new object() }}; // 2
new C<StructAddable>() { f = { new object(), new object() }};
}
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (27,26): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C<T>.f'.
// new C<T>() { f = { new object(), new object() }}; // 1
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ new object(), new object() }").WithArguments("C<T>.f").WithLocation(27, 26),
// (29,38): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C<ClassAddable?>.f'.
// new C<ClassAddable?>() { f = { new object(), new object() }}; // 2
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ new object(), new object() }").WithArguments("C<ClassAddable?>.f").WithLocation(29, 38));
}
[Fact, WorkItem(38060, "https://github.com/dotnet/roslyn/issues/38060")]
public void CheckImplicitObjectInitializerReceiver_EmptyCollectionInitializer()
{
var comp = CreateCompilation(@"
public class B
{
void Add(object o) { }
}
public class C
{
public B? f;
static void Main()
{
new C() { f = { }};
}
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics();
}
[Fact, WorkItem(32495, "https://github.com/dotnet/roslyn/issues/32495")]
......@@ -382,10 +533,9 @@ static void Main()
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (10,25): warning CS8602: Dereference of a possibly null reference.
// (10,25): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C.this[int]'.
// new C() { [0] = { f2 = null }};
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "{ f2 = null }").WithLocation(10, 25)
);
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ f2 = null }").WithArguments("C.this[int]").WithLocation(10, 25));
}
[Fact, WorkItem(32495, "https://github.com/dotnet/roslyn/issues/32495")]
......@@ -407,13 +557,12 @@ static void Main()
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (12,24): warning CS8602: Dereference of a possibly null reference.
// (12,24): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C.fc'.
// new C() { fc = { fb = { f2 = null} }};
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "{ fb = { f2 = null} }").WithLocation(12, 24),
// (12,31): warning CS8602: Dereference of a possibly null reference.
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ fb = { f2 = null} }").WithArguments("C.fc").WithLocation(12, 24),
// (12,31): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C.fb'.
// new C() { fc = { fb = { f2 = null} }};
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "{ f2 = null}").WithLocation(12, 31)
);
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ f2 = null}").WithArguments("C.fb").WithLocation(12, 31));
}
[Fact, WorkItem(32495, "https://github.com/dotnet/roslyn/issues/32495")]
......@@ -434,10 +583,9 @@ static void Main()
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (11,23): warning CS8602: Dereference of a possibly null reference.
// (11,23): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C.f'.
// new C() { f = { [0] = null }};
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "{ [0] = null }").WithLocation(11, 23)
);
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ [0] = null }").WithArguments("C.f").WithLocation(11, 23));
}
[Fact, WorkItem(32495, "https://github.com/dotnet/roslyn/issues/32495")]
......@@ -460,10 +608,9 @@ static void Main()
}", options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (13,23): warning CS8602: Dereference of a possibly null reference.
// (13,23): warning CS8670: Object or collection initializer implicitly dereferences possibly null member 'C.f'.
// new C() { f = { 1 }};
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "{ 1 }").WithLocation(13, 23)
);
Diagnostic(ErrorCode.WRN_NullReferenceInitializer, "{ 1 }").WithArguments("C.f").WithLocation(13, 23));
}
[Fact, WorkItem(29964, "https://github.com/dotnet/roslyn/issues/29964")]
......@@ -309,6 +309,7 @@ public void WarningLevel_2()
case ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull:
case ErrorCode.WRN_ImplicitCopyInReadOnlyMember:
case ErrorCode.WRN_NullabilityMismatchInTypeParameterNotNullConstraint:
case ErrorCode.WRN_NullReferenceInitializer:
Assert.Equal(1, ErrorFacts.GetWarningLevel(errorCode));
break;
case ErrorCode.WRN_InvalidVersionFormat:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册