Skip to content

Investigate C# union support impact on MSTest parameterized tests #7741

@Youssef1313

Description

@Youssef1313

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: MSTestIssues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)Area: Parameterized tests

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions