-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
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:
Console.WriteLine("IsDolbyVisionSupported: " + displayMonitor.IsDolbyVisionSupportedInHdrMode);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.