Skip to content

test: MSTEST0061 — add edge case tests for OSPlatform.Create and mobile OS platforms - #9818

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/mstest0061-edge-cases
Jul 10, 2026
Merged

test: MSTEST0061 — add edge case tests for OSPlatform.Create and mobile OS platforms#9818
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/mstest0061-edge-cases

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

Adds four tests covering previously untested code paths in UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzer (MSTEST0061).

The analyzer has two distinct code paths for extracting the OS platform name from RuntimeInformation.IsOSPlatform() calls:

  • Property reference path: OSPlatform.Windows, OSPlatform.Linux, etc. — already tested
  • OSPlatform.Create() path: OSPlatform.Create("Windows") — not previously tested

Additionally, OperatingSystem.Is*() methods for mobile/embedded platforms (iOS, Android) were not tested. These map to platform names that have no corresponding OperatingSystems enum value, so the analyzer fires but the fixer cannot produce a code fix.

Tests added

TestCode PathFix?
WhenOSPlatformCreateWithKnownPlatform_DiagnosticOSPlatform.Create("Windows")TryGetOSPlatformFromIsOSPlatformCall Create branch✅ fixes to [OSCondition(OperatingSystems.Windows)]
WhenOSPlatformCreateWithUnknownPlatform_DiagnosticOSPlatform.Create("CustomOS") → Create branch, no OperatingSystems mapping❌ analyzer fires, fixer does nothing
WhenOperatingSystemIsIOS_DiagnosticOperatingSystem.IsIOS() → maps to "iOS", no OperatingSystems.iOS❌ analyzer fires, fixer does nothing
WhenOperatingSystemIsAndroid_DiagnosticOperatingSystem.IsAndroid() → maps to "Android", no OperatingSystems.Android❌ analyzer fires, fixer does nothing

The unknown-platform and mobile-platform tests confirm that the fixer silently does nothing for unsupported platforms — a known limitation documented in the issue.

Test status

All 27 tests in UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzerTests pass locally:

Test run summary: Passed!
total: 27, failed: 0, succeeded: 27, skipped: 0

Fixes#9808

…le OS platforms
Add four tests covering previously untested code paths in
UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzer:
1. WhenOSPlatformCreateWithKnownPlatform_Diagnostic - exercises the
OSPlatform.Create("Windows") branch in TryGetOSPlatformFromIsOSPlatformCall.
The fixer maps "Windows" to OperatingSystems.Windows and applies the fix.
2. WhenOSPlatformCreateWithUnknownPlatform_Diagnostic - same OSPlatform.Create()
branch with a custom platform name ("CustomOS") that has no OperatingSystems
enum mapping; the analyzer fires but the fixer produces no change.
3. WhenOperatingSystemIsIOS_Diagnostic - OperatingSystem.IsIOS() maps to "iOS",
which has no OperatingSystems enum value; analyzer fires, fixer has no fix.
4. WhenOperatingSystemIsAndroid_Diagnostic - same as above for IsAndroid().
Fixes#9808
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings July 10, 2026 09:33

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds MSTEST0061 edge-case coverage for OSPlatform.Create and unsupported mobile platforms.

Changes:

  • Tests known and custom OSPlatform.Create values.
  • Tests iOS and Android diagnostics.
  • Validates the supported Windows code fix.
Show a summary per file
FileDescription
UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzerTests.csAdds four analyzer and fixer edge-case tests.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 3
  • Review effort level: Medium

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review Summary

All 22 dimensions reviewed — no findings.

DimensionVerdict
1. Algorithmic Correctness✅ N/A — test-only change
2. Error Handling✅ N/A
3. Concurrency / Thread Safety✅ N/A
4. Performance✅ N/A
5. Security✅ N/A
6. Public API Surface✅ N/A — no public API changes
7. Backward Compatibility✅ N/A
8. Cross-TFM Correctness✅ N/A
9. Localization✅ N/A
10. Naming & Conventions✅ Clean — test names follow existing patterns
11. Code Style✅ Clean — consistent with adjacent tests
12. Documentation / Comments✅ Clean — each test has a clear comment explaining the code path exercised
13. Test Quality✅ Clean — tests cover distinct code paths (Create branch, unknown platform, mobile OS methods)
14. Test Assertion Conventions✅ Clean — uses VerifyCS.VerifyCodeFixAsync / VerifyAnalyzerAsync per project conventions
15. Scope Discipline✅ Clean — single concern (edge-case test coverage)
16. Duplication✅ Clean — no unnecessary repetition beyond the structural boilerplate inherent to Roslyn verifier tests
17. Disposal & Lifetime✅ N/A
18. Configuration✅ N/A
19. Logging & Diagnostics✅ N/A
20. IPC / Wire Compat✅ N/A
21. Build Infrastructure✅ N/A
22. TODO Policy✅ N/A — no TODOs

Verdict: All clear. Four well-targeted tests covering previously untested analyzer branches. No issues found.

@github-actions

This comment has been minimized.

Review feedback pointed out that the three unsupported-platform tests used
VerifyAnalyzerAsync, which never invokes the code-fix provider and would not
catch a regression that corrupted the code.
Rather than leaving the fixer registering a no-op code action for platforms
that have no OperatingSystems enum value (the "known limitation" noted in the
issue), suppress the code action entirely: move the OperatingSystems mapping
check up to RegisterCodeFixesAsync so no fix is offered when the platform is
unmappable. This is the improvement the issue flagged as future work.
The three tests now use VerifyCodeFixAsync(code, code), which exercises the
code-fix provider and asserts no fix is offered (0 iterations), consistent
with the rest of the suite.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings July 10, 2026 13:04

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #9818

GradeTestNotes
A (90–100)new UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzerTests.
WhenOSPlatformCreateWithKnownPlatform_
Diagnostic
Clear AAA; VerifyCodeFixAsync asserts both diagnostic detection and the fix transformation. No issues found.
A (90–100)new UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzerTests.
WhenOSPlatformCreateWithUnknownPlatform_
Diagnostic
Clear AAA; VerifyCodeFixAsync(code, code) correctly verifies the fixer is a no-op for unmapped platforms. No issues found.
A (90–100)new UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzerTests.
WhenOperatingSystemIsIOS_
Diagnostic
Clear AAA; VerifyCodeFixAsync(code, code) correctly verifies the fixer is a no-op for iOS. No issues found.
A (90–100)new UseOSConditionAttributeInsteadOfRuntimeCheckAnalyzerTests.
WhenOperatingSystemIsAndroid_
Diagnostic
Clear AAA; VerifyCodeFixAsync(code, code) correctly verifies the fixer is a no-op for Android. No issues found.

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Re-run with
/grade-tests.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · 31.6 AIC · ⌖ 6.43 AIC · ⊞ 9.5K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit b7b9903 into mainJul 10, 2026
49 of 54 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/mstest0061-edge-cases branch July 10, 2026 13:26
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test-improver] test: MSTEST0061 — add edge case tests for OSPlatform.Create and mobile OS platforms

2 participants

@Evangelink