C# supports unions now in the latest SDK preview. An example for this is:
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)]
public class UnionAttribute : Attribute;
}
[System.Runtime.CompilerServices.Union]
// this can be either string or int.
// There is an implicit language conversion from string/int to StringOrIntUnion.
public record struct StringOrIntUnion
{
public StringOrIntUnion(string value) => Value = value;
public StringOrIntUnion(int value) => Value = value;
public object? Value { get; }
}
We should consider if we want to have good support for that around parameterized tests and think of all the scenarios for this. Probably the most obvious is having a parameterized test where one of the parameter types is a union, and the input to the test is one of the underlying union types. In that case, while there is no really "runtime" conversion, there is an implicit language conversion. Whether or not we should do anything for this issue, or wait for feedback, is up to discussion.
C# supports unions now in the latest SDK preview. An example for this is:
We should consider if we want to have good support for that around parameterized tests and think of all the scenarios for this. Probably the most obvious is having a parameterized test where one of the parameter types is a union, and the input to the test is one of the underlying union types. In that case, while there is no really "runtime" conversion, there is an implicit language conversion. Whether or not we should do anything for this issue, or wait for feedback, is up to discussion.