CsWinRT
CsWinRT copied to clipboard
Change #pragma warning solution to suppress SupportedOSPlatform attribute
Ideally we wouldn't need to suppress a CA1416 warning (like below):
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.
By using the #pragma warning:
if (ApiInformation.IsPropertyPresent("Windows.Devices.Display.DisplayMonitor", "IsDolbyVisionSupportedInHdrMode"))
{
#pragma warning disable CA1416 // Validate platform compatibility
Console.WriteLine("IsDolbyVisionSupported: " + displayMonitor.IsDolbyVisionSupportedInHdrMode);
#pragma warning restore CA1416 // Validate platform compatibility
}
We could update the analyzer to recognize the ApiInformation check so suppressing the warning isn't needed. Also see https://github.com/dotnet/runtime/issues/47593
We either need to build our own analyzer to recognize this, or work with the .NET analyzer to recognize ApiInformation.