Open kant2002 opened 2 days ago
Wouldn't it make sense to create a helper class which encapsulates
#if NET8_0_OR_GREATER
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException();
}
#endif
and is used everywhere this code is now? Something like
internal static class PlatformHelper
{
public void ThrowNotSupportedIfBrowser()
{
#if NET8_0_OR_GREATER
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException();
}
#endif
}
}
Wouldn't it make sense to create a helper class
There is already a Csla.Runtime
namespace/directory in the Csla
project. It has an IRuntimeInfo
service and implementation.
Perhaps that would be the place for any such helper code?
Wouldn't it make sense to create a helper class
There is already a
Csla.Runtime
namespace/directory in theCsla
project. It has anIRuntimeInfo
service and implementation.Perhaps that would be the place for any such helper code?
Even better.
Dataflow analysis work on method body. if we put this If inside helper method, then we have to annotate everything with SupportedPlatform/UnsupportedPlatform
For example
PlatformHelper.ThrowNotSupportedIfBrowser()
// Data flow does not know that all code below unreacheable on browser.
// This will produce warning that WebClient is not supported on the browser platform.
var client = new WebClient();
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException();
}
// Data flow analysis is happy and say hello to you. He knows that this code
// never reachable on browser.
var client = new WebClient();
Closes #1894