-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Unions Test Plan
Championed proposal: dotnet/csharplang#9662
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/unions.md
Feature branch: https://github.com/dotnet/roslyn/tree/features/Unions
- Interactions with "pure null tests" in is-patterns, e.g.:
MyUnion myUnion = null; Console.WriteLine(myUnion is object);MyUnion myUnion = new MyUnion(new object()); Console.WriteLine(myUnion is object);MyUnion myUnion = new MyUnion(""); Console.WriteLine(myUnion is object);MyUnion myUnion = null; if (myUnion is object) { myUnion.ToString(); } else { myUnion.ToString(); }
- caching for
UnionCaseTypes? - Unconventional
UnionAttribuitedefinitions, like Use attribute to designate Union types #82408 (comment) - Exhaustiveness
- Unions containing union types as case types, where the nested union is exhausted by checking the nested case types. e.g.
union Parent(int, Child); union Child(string, bool); switch (new Parent()) { int => 1, string => 2, bool => 3 }
- Unions containing union types as case types, where the nested union is exhausted by checking the nested case types. e.g.
- nullability analysis
-
IUnion.Valuewithout nullable annotation (object!)
-
- BCL: add
IUnionand any other supporting types - Ping F# as FYI
- Review public APIs
- It would also be good to test the
MaybeNullpostcondition through the conversion as well. - WhitespaceNormalizer
- Named parameters, e.g.
union MyUnion(string str); - Parameter modifiers, attributes, and default values
- Redundant Union attribute
[Union] union MyUnion(string str); - Public API: confirm desired shape of declaration syntax
Productivity
Union declarations
- completion (keyword
union, type list, union members) - classfication
- FAR
- NavBar, FindSymbols
- formatting
- disable GenerateConstructor? Start with
var x = new MyUnion(""); union MyUnion(int) { } - UpgradeProject
- offer to upgrade from union type?
Union types
- do we want to display a list of possible types in the union?
Reactions are currently unavailable