microsoft / microsoft/testfx

Investigate C# union support impact on MSTest parameterized tests

Open
#7,741 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/mstest area/parameterized-tests
Dominant language
C#
Stars
1k
Forks
312
Avg merge
7h 46m
Merged PRs (30d)
465

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the parameterized-test handling relevant to the supplied C# StringOrIntUnion example. Consider the underlying union types, implicit language conversions, and other parameterized-test scenarios described in the issue. Done means documenting or implementing an agreed support direction after the open questions are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.