You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reject a device category that selects the reproduction out
The published device selector is TestFilter=Category=Issue<N>, and
DeviceTestSharedHelpers.GetExcludedTestCategories implements that by
subtraction: it lists the public static string fields of TestCategory,
removes the requested one, and excludes everything left. "Issue<N>" is
deliberately not a TestCategory field, so the removal is a no-op and every
conventional category ends up excluded -- including the one the test itself
declares. The selector then selects the test out rather than in.
The authoring guidance asked for exactly that shape, telling the agent to
add [Category("Issue<N>")] "in addition to any conventional TestCategory".
Reviewers measured the consequence twice: an Android reproduction reported
576 discovered / 3 passed / 573 ignored, and a Mac Catalyst one executed
zero tests. Deleting only the broad category made each exact test run.
Windows is exempt and stays exempt: its runner filters by discovered traits,
so "Issue<N>" is a real category there.
Corrects the guidance, rejects the shape in both the authoring guards and
the publishing gate, and fixes the doc comment that asserted the opposite.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 735ac9a2-7bec-4baa-ad19-c298e5bc795a
"Generated device test '$file' declares [Category($conflict)] "+
3714
+
"alongside [Category(`"Issue$Issue`")]. On $TargetPlatform the "+
3715
+
'runner implements "Category=X" by excluding every other '+
3716
+
'TestCategory field, and "Issue'+$Issue+'" is not one of '+
3717
+
"them, so [Category($conflict)] lands in the excluded list and "+
3718
+
'the test is skipped. Declare the issue-keyed category on its '+
3719
+
'own so the published selector selects it.')
3720
+
if (-not$guardFailures.Contains($conflictMessage)) {
3721
+
$guardFailures.Add($conflictMessage)
3722
+
}
3723
+
}
3706
3724
} catch {
3707
3725
$message=$_.Exception.Message
3708
3726
if (-not$guardFailures.Contains($message)) { $guardFailures.Add($message) }
@@ -5963,7 +5981,7 @@ If the issue requests a new public event, property, method, or other API that do
5963
5981
Use testFilter "Maui$IssueNumber" only for XAML; otherwise use "Issue$IssueNumber".
5964
5982
Never assert an environment precondition. A test that calls Assert.True(OperatingSystem.IsIOSVersionAtLeast(26), ...) turns red on every device below that floor before its oracle runs, so the failure reports the lane rather than the defect and survives a complete product fix. When the reported behavior needs an OS floor, skip instead: "if (!OperatingSystem.IsIOSVersionAtLeast(26)) return;" -- the shape this repository uses at 49 sites. The same applies to throwing or Assert.Fail from an unmet version gate.
5965
5983
5966
-
A device test must also declare [Category("Issue$IssueNumber")] on its test class, in addition to any conventional TestCategory it already carries. CategoryAttribute takes params string[] and allows multiples, so this adds a category without editing the shared TestCategory file. The stock device-test runner honours only "Category=X" and "SkipCategories=X,Y", so without this category the published selector cannot isolate the reproduction and the whole suite runs instead.
5984
+
A device test must also declare [Category("Issue$IssueNumber")] on its test class, and on android, ios and catalyst that must be the ONLY category the test carries. Do not add a conventional TestCategory next to it. The stock device-test runner honours only "Category=X" and "SkipCategories=X,Y", and it implements "Category=X" by subtraction: it lists the public static string fields of TestCategory, removes X, and excludes every one that remains. "Issue$IssueNumber" is not a TestCategory field, so removing it removes nothing and every conventional category ends up excluded -- a test that also declares [Category(TestCategory.Shape)] then carries an excluded category and is skipped. Reviewers measured this twice: an Android reproduction reported 576 discovered / 3 passed / 573 ignored, and a Mac Catalyst one executed zero tests; deleting only the broad category made each exact test run. Windows selects from discovered traits instead, so a second category is harmless there, but keep the issue-keyed category alone on every platform for one publishable selector. Without this category the published selector cannot isolate the reproduction and the whole suite runs instead.
5967
5985
List 1-10 exact new repository-relative .cs or .xaml files. Every filename must contain "$IssueNumber", every parent directory must already exist, and every path must be under one of these roots:
0 commit comments