Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7955,6 +7955,12 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="WRN_UninitializedNonNullableBackingField_Title" xml:space="preserve">
<value>Non-nullable property must contain a non-null value when exiting constructor. Consider adding the 'required' modifier, or declaring the property as nullable, or safely handling the case where 'field' is null in the 'get' accessor.</value>
</data>
<data name="WRN_UninitializedNonNullableEvent" xml:space="preserve">
<value>Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider declaring the {0} as nullable.</value>
</data>
<data name="WRN_UninitializedNonNullableEvent_Title" xml:space="preserve">
<value>Non-nullable event must contain a non-null value when exiting constructor. Consider declaring the event as nullable.</value>
</data>
<data name="IDS_FeatureFirstClassSpan" xml:space="preserve">
<value>first-class Span types</value>
</data>
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2463,6 +2463,8 @@ internal enum ErrorCode
ERR_CollectionRefLikeElementType = 9358,
ERR_BadCollectionArgumentsArgCount = 9359,

WRN_UninitializedNonNullableEvent = 9360,

// Note: you will need to do the following after adding errors:
// 1) Update ErrorFacts.IsBuildOnlyDiagnostic (src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs)
// 2) Add message to CSharpResources.resx
Expand Down
3 changes: 3 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static ErrorFacts()
nullableWarnings.Add(GetId(ErrorCode.WRN_NullabilityMismatchInParameterTypeOnInterceptor));

nullableWarnings.Add(GetId(ErrorCode.WRN_UninitializedNonNullableBackingField));
nullableWarnings.Add(GetId(ErrorCode.WRN_UninitializedNonNullableEvent));

NullableWarnings = nullableWarnings.ToImmutable();
}
Expand Down Expand Up @@ -568,6 +569,7 @@ internal static int GetWarningLevel(ErrorCode code)
case ErrorCode.WRN_PartialMemberSignatureDifference:
case ErrorCode.WRN_FieldIsAmbiguous:
case ErrorCode.WRN_UninitializedNonNullableBackingField:
case ErrorCode.WRN_UninitializedNonNullableEvent:
case ErrorCode.WRN_AccessorDoesNotUseBackingField:
case ErrorCode.WRN_UnscopedRefAttributeOldRules:
case ErrorCode.WRN_RedundantPattern:
Expand Down Expand Up @@ -2477,6 +2479,7 @@ or ErrorCode.ERR_CannotApplyOverloadResolutionPriorityToOverride
or ErrorCode.ERR_CannotApplyOverloadResolutionPriorityToMember
or ErrorCode.ERR_PartialPropertyDuplicateInitializer
or ErrorCode.WRN_UninitializedNonNullableBackingField
or ErrorCode.WRN_UninitializedNonNullableEvent
or ErrorCode.WRN_UnassignedInternalRefField
or ErrorCode.WRN_AccessorDoesNotUseBackingField
or ErrorCode.ERR_IteratorRefLikeElementType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,9 @@ void checkMemberStateOnConstructorExit(MethodSymbol constructor, Symbol member,
: NullableFlowState.MaybeNull;
if (memberState >= badState) // is 'memberState' as bad as or worse than 'badState'?
{
var errorCode = usesFieldKeyword ? ErrorCode.WRN_UninitializedNonNullableBackingField : ErrorCode.WRN_UninitializedNonNullableField;
var errorCode = usesFieldKeyword ? ErrorCode.WRN_UninitializedNonNullableBackingField
: symbol.Kind == SymbolKind.Event ? ErrorCode.WRN_UninitializedNonNullableEvent
: ErrorCode.WRN_UninitializedNonNullableField;
var info = new CSDiagnosticInfo(errorCode, new object[] { symbol.Kind.Localize(), symbol.Name }, ImmutableArray<Symbol>.Empty, additionalLocations: symbol.Locations);
Diagnostics.Add(info, exitLocation ?? symbol.GetFirstLocationOrNone());
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading