Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformCompatibilityAnalyzer should report a warning for UnsupportedOSPlatform attribute in interface implementation #7579

Open
Youssef1313 opened this issue Feb 17, 2025 · 1 comment

Comments

@Youssef1313
Copy link
Member

Youssef1313 commented Feb 17, 2025

Analyzer

Diagnostic ID: CA1416: Validate platform compatibility

Describe the bug

If an implementation of an interface member has UnsupportedOSPlatform, while the interface member itself doesn't, this should be a warning. For example:

public interface IMyInterface
{
    public string MyProperty { get; }
}

public class MyImpl : IMyInterface
{
    [UnsupportedOSPlatform("browser")]
    public string MyProperty
    {
        get
        {
            // ...
        }
    }
}

Because, MyProperty can still be accessed via the interface without a warning, masking an issue.

@Evangelink
Copy link
Member

It's possible that different implementations have different constraints so we may have different expectations but it might still be a good option for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants