Repository navigation
Conversation
Decode OperatingSystem.IsApplePlatform as macOS, MacCatalyst, iOS, or tvOS instead of a fictitious ApplePlatform OS. Preserve existing builtin guard registration and flow-analysis negation. Add C# and VB regressions for allow lists, deny lists, each Apple platform, Windows, watchOS, and negation. Document builtin guard test setup. Co-authored-by: Copilot App <[email protected]> Copilot-Session: ee6e48ad-6898-45d7-98ed-9850afb3bd30
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Restore AGENTS.md to the original baseline as requested, preserving IsApplePlatform analyzer changes and regression tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: ee6e48ad-6898-45d7-98ed-9850afb3bd30
Should the tests for this API use .NET 12 reference assemblies (once the runtime change is merged) so that they test the actual user experience? |
Route IsApplePlatform through the existing guard attribute decoder instead of inferring a platform from its name or hardcoding the Apple platform set. Preserve iOS/MacCatalyst relationships and cover metadata-driven guards in regression tests. Co-authored-by: Copilot App <[email protected]>
Once dotnet/runtime#135475 is merged and a reference pack containing the API is available, I'll switch the C# and VB API-usage tests to .NET 12 reference assemblies and remove their |
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
The C# and VB API-usage tests now use real reference assemblies instead of I'm waiting for the SDK dependency flow to bring in |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the Apple-platform guard analysis changes.
No open issues 🎉
What changed in this PR
Updates CA1416 platform compatibility analysis to recognize OperatingSystem.IsApplePlatform() through its guard attributes, rather than treating it as a single platform name.
Changes:
- Routes the aggregate Apple guard through existing attribute-based analysis while preserving iOS/MacCatalyst dependency handling.
- Adds C# and Visual Basic coverage for positive and negated guards, Windows controls, and metadata-driven behavior.
- Enables selected tests to use the build-resolved reference pack while retaining existing test baselines.
| File | Description |
|---|---|
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.GuardedCallsTests.cs |
Adds Apple guard tests and current-reference-pack setup. |
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.cs |
Adds verification overloads accepting explicit reference assemblies. |
src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests.csproj |
Exposes reference-pack metadata through runtime configuration and copies NuGet configuration. |
src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs |
Excludes IsApplePlatform from name-based platform inference. |
src/Microsoft.CodeAnalysis.NetAnalyzers/AGENTS.md |
Documents the current-reference-pack test setup and incremental-build requirements. |
Review effort: Balanced
Summary
Teach CA1416 to recognize
OperatingSystem.IsApplePlatform()using the API'sSupportedOSPlatformGuardattributes, supporting the public API added in dotnet/runtime#135475.IsApplePlatformas a single platform name.Coverage
The Apple guard tests cover positive and negated branches, Windows negative controls, and the iOS/MacCatalyst relationship. Tests that deliberately vary guard annotations retain a source stub to verify that analysis follows metadata rather than a fixed Apple platform list.
Validation
IsApplePlatformtests using the build-resolvedMicrosoft.NETCore.App.Ref12.0.0-alpha.1.26564.101, brought into SDKmainby dotnet/sdk#57118.Prepared with GitHub Copilot.