Skip to content
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 #pragma warning solution to suppress SupportedOSPlatform attribute #718

Open
angelazhangmsft opened this issue Feb 3, 2021 · 1 comment
Labels
enhancement New feature or request light-up Related to light-up/adaptive-code scenarios
Milestone

Comments

@angelazhangmsft
Copy link
Contributor

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

@angelazhangmsft angelazhangmsft added the enhancement New feature or request label Feb 3, 2021
@AdamBraden
Copy link
Contributor

We either need to build our own analyzer to recognize this, or work with the .NET analyzer to recognize ApiInformation.

@AdamBraden AdamBraden added this to the Future milestone Feb 9, 2021
@angelazhangmsft angelazhangmsft added the light-up Related to light-up/adaptive-code scenarios label Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request light-up Related to light-up/adaptive-code scenarios
Projects
None yet
Development

No branches or pull requests

2 participants