Skip to content

Fix: Unsupported maccatalyst attribute is getting applied to child attributes but not accounted parent child attributes merge#50334

Open
rolfbjarne wants to merge 9 commits into
dotnet:mainfrom
rolfbjarne:roslyn-analyzers-pr-7644
Open

Fix: Unsupported maccatalyst attribute is getting applied to child attributes but not accounted parent child attributes merge#50334
rolfbjarne wants to merge 9 commits into
dotnet:mainfrom
rolfbjarne:roslyn-analyzers-pr-7644

Conversation

@rolfbjarne

Copy link
Copy Markdown
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
Copy Markdown
Member Author

CC @buyaa-n

Copilot AI 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

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 <viktor.hofer@microsoft.com>
@rolfbjarne

Copy link
Copy Markdown
Member Author

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

rolfbjarne and others added 2 commits October 7, 2025 14:42
…ysis.NetAnalyzers/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ViktorHofer

Copy link
Copy Markdown
Member

@dotnet/dotnet-analyzers PTAL

@rolfbjarne

Copy link
Copy Markdown
Member Author

@dotnet/dotnet-analyzers anything I can do to push this along?

@rolfbjarne

Copy link
Copy Markdown
Member Author

@dotnet/dotnet-analyzers this pull request is green now, could someone please review so it can get merged? It's been almost a year...

@github-actions

Copy link
Copy Markdown
Contributor

Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label.

@github-actions github-actions Bot added the stale label May 27, 2026
@rolfbjarne

Copy link
Copy Markdown
Member Author

This PR is not stale, it's just waiting for a review/approval.

@github-actions github-actions Bot removed the stale label May 28, 2026
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

5 participants