Skip to content

Change #pragma warning solution to suppress SupportedOSPlatform attribute #718

@angelazhangmsft

Description

@angelazhangmsft

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 dotnet/runtime#47593

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlight-upRelated to light-up/adaptive-code scenarios

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions