Description
Summary
Add a generic ConditionAttribute (likely a [ConditionalFact]/[ConditionalDataRow] equivalent) that defers the boolean condition evaluation to a static member referenced by Type + member name, mirroring xUnit.net's ConditionalFactAttribute/ConditionalTheoryAttribute (Microsoft.DotNet.XUnitExtensions).
Motivation
While migrating dotnet/sdk tests from xUnit to MSTest (dotnet/sdk#54731), many tests use:
[ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))]
public void InvalidAdvance_Large() { ... }This pattern is extremely common in dotnet/runtime, dotnet/sdk, dotnet/aspnetcore, etc. It allows test authors to skip a test when an arbitrary static bool property/field/method returns false -- without having to write a new ConditionBaseAttribute subclass each time.
MSTest already ships specific ConditionBaseAttribute subclasses like [OSCondition], but there is no generic facility for "skip if Type.Member returns false". Today every project has to define its own one-off ConditionBaseAttribute (e.g. Is64BitProcessConditionAttribute, IsBigEndianConditionAttribute, IsLinuxBionicConditionAttribute, ...) which is boilerplate-heavy.
Proposed shape
Match the dotnet/runtime / xUnit.net naming so migration is mechanical:
[ConditionalTest(typeof(Environment), nameof(Environment.Is64BitProcess))]
[TestMethod]
public void InvalidAdvance_Large() { ... }
// Multiple members → AND together
[ConditionalTest(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser), nameof(PlatformDetection.IsThreadingSupported))]
public void HttpClient_Works() { ... }Where each referenced member can be:
public static bool Property { get; }public static readonly bool Fieldpublic static bool Method()
Bonus: an [ConditionalIgnore(...)] flavor with the inverse semantics (skip when the member returns true), for symmetry with ConditionMode.Exclude.
Workaround today
Hand-roll a ConditionBaseAttribute per condition (verbose, hard to discover):
internal sealed class Is64BitProcessConditionAttribute : ConditionBaseAttribute
{
public Is64BitProcessConditionAttribute() : base(ConditionMode.Include)
{
IgnoreMessage = ""This test requires a 64-bit process."";
}
public override string GroupName => nameof(Is64BitProcessConditionAttribute);
public override bool IsConditionMet => Environment.Is64BitProcess;
}References
- xUnit.net pattern (
Microsoft.DotNet.XUnitExtensions): https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.XUnitExtensions/src/ConditionalFactAttribute.cs - Repro: Migrate Microsoft.DotNet.HotReload.Client.Tests to MSTest.Sdk dotnet/sdk#54731
Activity
Use [OSCondition] and [Is64BitProcessCondition] instead of runtime ch…
Youssef1313 commentedon Jun 12, 2026
Note: the implementation of this attribute is currently on Arcade, it's not xunit built-in attribute, and I think it exists for historical reason and not required for xunit.v3 (even if Arcade implements it for xunit.v3 as well - it's only to ease migration)
Add [MemberCondition] attribute for static-member-based test conditio…