Invoking a platform-specific API inside a local function annotated with a SupportedOSPlatformAttribute corresponding to the platform-specific API still leads to the CA1416 diagnostic being raised.
Steps To Reproduce
public class Class1
{
[SupportedOSPlatform("windows")]
private static void X()
{
_ = Registry.LocalMachine;
}
private static void Y()
{
[SupportedOSPlatform("windows")]
static void L()
{
// CA1416: This call site is reachable on all platforms. 'Registry.LocalMachine' is only supported on: 'windows'.
_ = Registry.LocalMachine;
}
}
[SupportedOSPlatform("windows")]
private static void Z()
{
static void L()
{
_ = Registry.LocalMachine;
}
}
}
Analyzer
Diagnostic ID: CA1416:
Validate platform compatibility
Analyzer source
NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers
Version: 8.0.0
Describe the bug
Invoking a platform-specific API inside a local function annotated with a SupportedOSPlatformAttribute corresponding to the platform-specific API still leads to the CA1416 diagnostic being raised.
Steps To Reproduce
Minimal working project https://github.com/Arthri/demo-roslyn-sop
Expected behavior
No
CA1416
warnings.Actual behavior
One
CA1416
raised inY
's local functionL
due to invocation of Registry methods.Additional context
none