Add RFC 016: Union Types in Data-Driven Tests#8612
Draft
Evangelink wants to merge 1 commit into
Draft
Conversation
Draft design for handling C# [Union] parameter types in MSTest's data-driven testing surface (DataRow, DynamicData, ITestDataSource, DataRowShouldBeValidAnalyzer). Tracks #7741. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds a draft design RFC (RFC 016) to explore how MSTest could support upcoming C# union types ([System.Runtime.CompilerServices.Union]) in data-driven tests, with an emphasis on keeping analyzer and runtime behavior aligned and deferring implementation until the language exposes a metadata-observable case contract.
Changes:
- Add RFC 016 describing current MSTest behavior for argument binding and analyzer validation with unions.
- Propose a phased approach for potential support across classic adapter and MTP source-generation paths.
- Document open questions (Roslyn conversion surface, case discovery contract, AOT/trimming, package version skew).
Show a summary per file
| File | Description |
|---|---|
| docs/RFCs/016-Union-Types-In-Data-Driven-Tests.md | New RFC draft laying out motivation, current behavior, proposed design, rollout phases, and open questions for union-type support in data-driven tests. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
Comment on lines
+200
to
+201
| is decorated with `UnionAttribute`: | ||
|
|
Comment on lines
+244
to
+249
| mismatch. The same applies if a method takes a single `StringOrInt[]` parameter and the | ||
| data source supplies an `object[]` whose elements are case values. | ||
|
|
||
| This is a small but real addition to the implementation: the conversion hook is applied | ||
| per-element for any array-typed slot whose element type is a union. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft RFC for review — design exploration only, no implementation in this PR.
Addresses #7741: should MSTest support C# union types (
[System.Runtime.CompilerServices.Union]) in data-driven tests?What the RFC does
TestMethodInfo.ResolveArgumentsdoes no conversion at all;DataRowShouldBeValidAnalyzerrejects viaClassifyCommonConversion).[DataRow], MTP source-genDynamicData, AOT source-gen) and explains how each is — or isn't — affected.[UnionDataRow]attribute (splits API for no real reason), source-generator-only path (heavy machinery for a small problem).TestDataRow.OfUnion<T>(...)helper.What I'd appreciate review on
StandardConversion.TryConvertover a small spec-defined set realistic, or should we narrow further?op_Implicit>[UnionCase]> constructors-as-fallback). Does anyone have inside knowledge of where the language design is headed?params+ AOT all in Phase 1 is intentionally conservative against the "analyzer green, runtime red" trap. Pushback welcome.Not ready to be marked Approved; opening as draft to start discussion.