-
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
Change SupportedOSPlatformAttribute warning #47593
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@angelazhangmsft how could we know when it should point towards ApiInformation check? Are those APIs (or containing type/assembly) decorated with any distinguishing attribute? |
Seems we can use ContractVersionAttribute is that right? |
@terrajobst / @angelazhangmsft If I recall correctly on this, we concluded that this change was not necessary; is that correct? |
Yes the current plan is to go the route of the alternative suggestion (CsWinRT could remove the projection for this attribute and use the to-be-designed analyzer/attribute for contract checks.) |
Yes. The conclusion was that CsWinRT should stop projecting their version information as |
Thank you both! |
Description
Windows projects OS version as SupportedOSPlatformAttribute, and the version number is computed by the minimum OS that supports that contract. When an API isn’t guaranteed to be there, a warning message (see below) points people towards authoring a version check, which is undesirable for WinRT. We should change this warning message to point people towards ApiInformation checks.
Example: If I call this code in a .NET 5 console app with
SupportedOSPlatformVersion
of 10.0.17763.0:The following warning shows:
Severity Code Description Project File Line Source Suppression State Tool
Warning CA1416 This call site is reachable on: 'Windows' 10.0.17763.0 and later. 'DisplayMonitor.IsDolbyVisionSupportedInHdrMode.get' is only supported on: 'Windows' 10.0.19041.0 and later. Net5ConsoleApp C:\Users\angzhang\source\repos\Net5ConsoleApp\Net5ConsoleApp\Program.cs 23 IntelliSense Active Microsoft.CodeAnalysis.NetAnalyzers
Alternative
Alternatively, CsWinRT could remove the projection for this attribute and use the to-be-designed analyzer/attribute for contract checks.
The text was updated successfully, but these errors were encountered: