Change #pragma warning solution to suppress SupportedOSPlatform attribute
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 665
- Forks
- 134
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 32
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the analyzer logic that reports CA1416 and read the related dotnet/runtime issue #47593. The proposed change is complete when an ApiInformation property check is recognized as establishing platform support, so the surrounding #pragma suppression is no longer needed; verify the behavior with the analyzer's existing tests if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100