-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Work items] Nullable reference types #22152
Comments
Championed issue: dotnet/csharplang#36 Notes on project property:
Dogfood experience:
Some various notes from LDM discussions and others:
static void F(out string x) => throw new Exception();
static void G(out IEnumerable<string> y) => throw new Exception();
F(out string? x); // warning?
G(out IEnumerable<string?> y); // warning?
static void F<T>(T x, out T y) => throw new Exception();
string? x = null;
string y;
F(x, out y); // warning
F(x!, out y); // warning? static void F(object? x)
{
object y;
y = x; // warning: `x` may be null
y.ToString(); // warning?
y = x!; // no warning
y.ToString(); // warning?
}
static void F(object? x)
{
if (x == null) return;
x!.ToString(); // warning: unnecessary `!`?
// maybe the IDE offers to remove uncessary ! operators?
}
|
Nit: Should probably add |
I looked at the remaining issues. Extracted one or two as discrete issues. |
Preview 2:
#nullable
#pragma warning nullable (enable|disable|restore)
PR Add support for restore and safeonly for #nullable directive. #31806[MaybeNull]
!
suppress conversion warnings!
should suppress conversion warnings #30376e switch { … }
,switch (e) { … }
Nullable reference types: no nullability flow check in switch statements. #23944[Nullable]
metadata encoding (PR Adjust the way nullable annotations are represented in metadata #31212)yield return
Null warnings not reported for iterator methods #23701Non-blocking:
parameter!
NullableWalker
#27233NullEquals
,NullInNullOut
,NotNulled
) Recognize annotations on methods that affect nullability analysis #26761[Nullable]
NullableAttribute
in framework? See Use synthesized attribute infrastructure for System.NullableAttribute #22820 (comment)#nullable enable
andNullableReferenceTypes
Nullable: Fixer to add#nullable
and project-level setting #30099TypeSymbolWithAnnotations
MethodSymbol.ReturnType
, etc.) toTypeSymbol
and addTypeSymbolWithAnnotations
propertiesTypeMap.AsTypeSymbol
andTypeMap.AsTypeSymbolWithAnnotations
for cases where nullability is dropped (@jcouv)SymbolDisplay
?
!
and~
Add SymbolDisplay option to append suffix for unannotated reference types #28242void M(out string x)
invoked withM(out string? x);
out var
out var
treated as non-nullable #25347case null:
,case string:
,case string s:
) Nullable reference types: no nullability flow check in switch statements. #23944x
invar x = obliviousListOfString;
should beList<string!>!
foreach (var x in maybeNull) { }
Report warning using foreach with a nullable value #23493null
initializernull
initializer for non-nullable property (or field) should warn #26628VisitType
to implementContainsNullableReferenceTypes
. SeeTestDeepTypeAccessibilityBug18018
test.!
operatorWarning for unnecessary!
? Report hidden diagnostic for unnecessary!
#25372Error for!!
. SeeStaticNullChecking.SuppressNullableWarning_Multiple
!!
should be disallowed #29902a! = b;
. SeeStaticNullChecking.SuppressNullableWarning_Assignment
and InvalidOperationException in StackOptimizerPass1.IsIndirectAssignment withx! = null;
#28377ERR_NotNullableOperatorNotReferenceType
should be a warning not an errorMergeDynamic
andMergeTupleNames
ignore nullabilityInferExtensionMethodTypeArguments
ignores nullabilityMethodGroupReturnTypeInference
ignores nullability??=
?
annotations in Type for Locals and WatchProductivity Migrated to project https://github.com/dotnet/roslyn/projects/43
QuickInfo
Authoring experience for external annotations
Can we make it easier to see what context we're in?
null
assignment suggests declaring as nullable Add a DeclareAsNullable fixer #26630null
test suggests declaring as nullable Add DeclareAsNullable refactoring #26661Fix interface implementation or override Nullability fixer for interface implementations #26833
Grey out unnecessary
!
Gray out unnecessary non-null suppression operator #26736Grey out unnecessary
?
Using
?
or!
suggests turning feature on (issue Nullable: Fixer to add#nullable
and project-level setting #30099)help move
#nullable
up/down the scopesclassify
#nullable
(PR Add syntax classification for nullable directives #31579)Indent
#nullable
to the marginMarshalling options in OOP process (PR add new compilation options to data sync to OOP. #32726)
Performance
IDE: Metadata view
Work related to project-system:
NullableReferenceTypes
project property (settingProject.Configuration.Properties["NullableReferenceTypes"]
and declaring that "NullableReferenceTypes" BooleanProperty)Preview 1:
[NonNullTypes]
Disable warnings with(no longer applicable)[NonNullTypes(Warnings=false)]
Add NonNullTypesAttribute.Warnings property #29616Fix/verify(no longer applicable)[NonNullTypes]
in PE symbols!
if no attribute (needs a new solution)[NonNullTypes]
?
if no attribute or if[NonNullTypes(false)]
[NonNullTypes]
or[NonNullTypes(value)]
(Bind NonNullTypes for types #28491)
~
Incorrect nullability from method type inference #27961(object)x != null
Warnings reported after comparing with object == or != #27928t.ToString();
for unconstrainedT
?.
Infer nullability of receiver and member from?.
expression #25870s is string
Pattern test should inform nullability #26745is
patternsx is C y
x is K
whereK
is a constant other thannull
~
and?
or!
(oblivious doesn't survive, LDM 7-11)object
constraint; useobject?
for unconstrained Support Object type as a generic type constraint. #29809T?
unlessT
is constrained to a reference type or a value type Report error for T? when T is unconstrained #28804class?
constraintThe text was updated successfully, but these errors were encountered: