Skip to content

Test plan for nullable annotations on unconstrained type parameters #44578

@jcouv

Description

@jcouv

See initial PR #45993

  • draft spec on dotnet/csharplang
  • language version errors for T? and where T : default
  • nullability of default(T) and default(T?)
  • nullability of var: var t = new T(); Local of unconstrained type parameter type is reported as NotAnnotated when using var #46236
  • nullability of (T?)t
  • nullability of (T)default(T)
  • interop with T from outside nullable context: see UnconstrainedTypeParameter_45, _46
  • T? outside nullable context
  • T? with no constraints, with class? constraint, with notnull constraint
  • T? as type argument
  • T? as constraint
  • T? substituted with U or U? where U : { T, T?, class, class?, struct, notnull }
  • T? in variance
  • T? in method type inference
  • T? in lambda return type inference
  • T? and T in best common type
  • T? in ref types
  • T? in out parameters: see UnconstrainedTypeParameter_47, No warning when overriding method with out T? rather than out T #49131
  • T? in ref parameters
  • T? in type argument constraint checks
  • T? with [AllowNull], [MaybeNull]: see UnconstrainedTypeParameter_16
  • T? with [DisallowNull], [NotNull]: see UnconstrainedTypeParameter_41, _42
  • non-safety warnings for assignment or explicit cast of T? to T No warning reported for assignment or explicit cast of possibly null value of unconstrained type parameter type #46044
  • conversions from U or U? to T or T? where U : { T, T? } No warning reported returning nullable version of unconstrained type parameter #46150
  • default constraint on method overrides and explicit implementations
  • default constraint on other methods
  • default constraint combined with other constraints
  • default constraint required to treat T? as unconstrained
  • overrides that differ by default and struct constraints
  • overrides that differ by default and other constraints { class, class?, notnull, I, I? }
  • overrides that differ by T and T?: see UnconstrainedTypeParameter_09, _10
  • T? consumed in C#8
  • T? consumed in C#8 with [AllowNull], [MaybeNull]
  • overrides and implementations with T? and [MaybeNull]T, etc.
  • symbol display of T? and IEnumerable<T?>
  • symbol display of method with where T : default constraint
  • unassigned fields of type T and T?
  • annotations from GetDeclaredSymbol()
  • flow state from GetSymbolInfo() on a method re-inferred with T?
  • flow state from IOperation on a method re-inferred with T?

Productivity:

  • check publicAPI analyzer on T?
  • recommend default keyword
  • UseExplicitType

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions