Skip to content

Test plan for "Unions" #81074

@AlekseyTs

Description

@AlekseyTs

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 UnionAttribuite definitions, 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 }
  • nullability analysis
    • IUnion.Value without nullable annotation (object!)
  • BCL: add IUnion and any other supporting types
  • Ping F# as FYI
  • Review public APIs
  • It would also be good to test the MaybeNull postcondition 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?

Sub-issues

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions