Skip to content

Did we need the union class type? #35172

Description

@BenLampson

Currently, the Blazor published preview 4.
But in my project(base on React's ANTD component to create the Blazor Component library) we found the "Demand UnionType".
There's React operation like this:
Union Type in React
The same property can get different types used to do a different operation.
Even I realization the sample union type, like this:

UnionType<int, string, TestClass> _testInstance = 1;
var x=_testInstance.Value;
_testInstance = "";
var y=_testInstance.Value;
_testInstance = new TestClass();
var z=_testInstance.Value;

You can find the all test case inTest Case
But, I think this type is the global case in Blazor, doesn't it?
And if I want to realization all case maybe I need to copy paste so many times to join as most type as we can write ..

And, there are so many bugs in my realization( It sample right now). But If we can add this type to a standard that so cool, cause you guys so strong than me in MS right, Maybe you can do super things than my demo(I'm sure about this, that's why I'm here)

In my realization, I create the instance every time, I try to use the BCL's operation(like the value type case I try to use get hashcode to compare) to fix the performance, but if this class in the BCL, it can do more things than me.

So, can we add the union class in the .NET standard?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-VM-coreclruntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions