Skip to content

Conversation

rolfbjarne
Copy link
Member

When an API supported on IOS it also supported by maccatalyst as they are related. To remove implicit maccatalyst support one need to add [UnsupportedOSPlatform (""maccatalyst"")] to the [SupportedOSPlatform (""ios"")]

The [UnsupportedOSPlatform (""maccatalyst"")] applied to the immediate (child) attributes list and removed the implicit maccatalyst support but when child attributes are merged to the parent attributes list this is not accounted and merged list will keep the implicit maccatalyst support. The PR fixes this bug.

Fixes #50337

This is a re-creation of this pull request from dotnet/roslyn-analyzers: dotnet/roslyn-analyzers#7644

…tributes but not accounted parent child attributes merge
@rolfbjarne
Copy link
Member Author

CC @buyaa-n

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where unsupported MacCatalyst attributes applied to child methods were not properly accounted for when merging with parent attributes. The issue occurred because iOS implicitly supports MacCatalyst, but when [UnsupportedOSPlatform("maccatalyst")] is explicitly added to remove this implicit support, the merge logic wasn't preserving this unsupported status.

  • Fixed merge logic to properly handle unsupported platform attributes during parent-child attribute merging
  • Added condition to check if attributes are set before determining deny list status
  • Restructured conditional logic for better handling of supported version boundaries

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
PlatformCompatibilityAnalyzer.cs Fixed merge logic for platform attributes and updated deny list condition
PlatformCompatibilityAnalyzerTests.cs Added comprehensive test cases to verify the fix works correctly

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

…alysis.NetAnalyzers.UnitTests/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzerTests.cs

Co-authored-by: Viktor Hofer <[email protected]>
@rolfbjarne
Copy link
Member Author

@ViktorHofer is anything else needed here to get it approved and merged?

…ysis.NetAnalyzers/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CA1416 when property accessor is unsupported on Mac Catalyst

4 participants