-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Platform Compatibility Analyzer] Nested APIs shouldn't be allowed to expand the platform set #43971
Comments
Talked with @buyaa-n and since this proposal would require a new ruleID, we think it should go through API review, so I'm moving it to the runtime repo. |
@buyaa-n will help group this issue with these two others into one proposal: |
Category: Interoperability This analyzer might be implemented as part of #45851 and should cover the following main scenarios:
|
Examples:
[SupportedOSPlatform("ios")]
class Some
{
[SupportedOSPlatform("windows")] // Warn: 'Api' cannot widen the set of supported platforms of its containing symbol `Some`.
public static void Api() {}
}
[UnsupportedOSPlatform("browser")] // Warn: `Inconsistent platform 'browser' found in the Supported platforms list`
[SupportedOSPlatform("windows")]
[UnsupportedOSPlatform("windows10.0.19041")]
public void Api1();
// Fixer might suggest remove `[UnsupportedOSPlatform("browser")] `
[SupportedOSPlatform("browser")] // No warning
[SupportedOSPlatform("windows")]
[UnsupportedOSPlatform("windows10.0.19041")]
public void Api1();
Fixer can suggest removing the invalid attribute |
Makes sense. Two thoughts:
|
Throughout .NET 6, we've seen less evidence that we need to have an analyzer warning about this. Our rules for this scenario have continued to be refined, and we have intentionally opened up some scenarios where nested APIs can expand the parent set of platforms--particularly when dealing with cross-platform/platform-neutral libraries. As a result, I'm going to close this issue; we can revisit after .NET 6 if appropriate. |
Repro
Expected
Work Items
Each of these should produce separate diagnostic ids:
The text was updated successfully, but these errors were encountered: