You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is particularly agonizing for APIs such as the host/services builders.
The below should not show warnings, but it does:
usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.Extensions.Hosting;usingMicrosoft.Extensions.Logging;if(!OperatingSystem.IsWindows())return1;awaitHost.CreateDefaultBuilder(args).ConfigureServices((hostContext,services)=>{services.AddLogging(builder =>{// ⚠️ CA1416: This call site is reachable on all platforms. 'EventLoggerFactoryExtensions.AddEventLog(// ILoggingBuilder, Action<EventLogSettings>)' is only supported on: 'windows'.builder.AddEventLog(eventLogSettings =>{// ⚠️ CA1416: This call site is reachable on all platforms. 'EventLogSettings.SourceName' is only// supported on: 'windows'.eventLogSettings.SourceName="Foo";});});}).Build().RunAsync();return0;
The workaround makes it clear that this is an inconsistency in the analyzer's behavior; an implicit "SupportedOSPlatform" should be applied to all statements following if (!OperatingSystem.IsWindows()) return 1; without manually stating this:
Closing as duplicate of #4282, which is closed as by design
The flow analysis could not evaluate a lambda expression unless it is explicitly invoked. Please check the issue for details
The workaround makes it clear that this is an inconsistency in the analyzer's behavior; an implicit "SupportedOSPlatform" should be applied to all statements following if (!OperatingSystem.IsWindows()) return 1; without manually stating this:
The suggested workaround is to add a Debug.Assert at the start of the lambda for the expected OS information.
Analyzer
Diagnostic ID: CA1416: Validate platform compatibility
Analyzer source
Version: SDK 8.0.300
This is particularly agonizing for APIs such as the host/services builders.
The below should not show warnings, but it does:
The workaround makes it clear that this is an inconsistency in the analyzer's behavior; an implicit "SupportedOSPlatform" should be applied to all statements following
if (!OperatingSystem.IsWindows()) return 1;
without manually stating this:The text was updated successfully, but these errors were encountered: