Skip to content

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

Merged
rolfbjarne merged 14 commits into
dotnet:mainfrom
rolfbjarne:roslyn-analyzers-pr-7644
Jul 8, 2026
Merged

rolfbjarne merged 14 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 <[email protected]>
@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 <[email protected]>
@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
rolfbjarne and others added 3 commits July 7, 2026 10:58
…MSTest [TestMethod]

The analyzer unit test project was migrated from xUnit to MSTest.Sdk on
main. The three tests added by this PR still used xUnit's [Fact], which
no longer resolves under MSTest.Sdk, breaking the build with CS0246
('Fact'/'FactAttribute' not found) at PlatformCompatibilityAnalyzerTests.cs
lines 4161, 4189 and 4229.

Switch them to [TestMethod] to match the migrated infrastructure. The
WorkItem attribute is already aliased to Test.Utilities.WorkItemAttribute
in the project, so [TestMethod, WorkItem(...)] binds correctly.

Co-authored-by: Copilot <[email protected]>
@rolfbjarne
rolfbjarne merged commit 6eb37e8 into dotnet:main Jul 8, 2026
25 checks passed
@rolfbjarne
rolfbjarne deleted the roslyn-analyzers-pr-7644 branch July 8, 2026 18:36
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 9, 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

7 participants