Skip to content

Commit

Permalink
Switch to preprocessor directives to avoid need for System.Runtime.In…
Browse files Browse the repository at this point in the history
…teropServices.RuntimeInformation package on net462
  • Loading branch information
Jevonius committed Apr 30, 2022
1 parent 9da21a7 commit 0076083
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Expand Up @@ -49,7 +49,12 @@ public void Reset()

private void AssertAdmin()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
#if NETCOREAPP2_0_OR_GREATER
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#else
bool isWindows = !RunningOnMono();
#endif
if (isWindows)
{
WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
try
Expand Down
1 change: 0 additions & 1 deletion src/Castle.Core/Castle.Core.csproj
Expand Up @@ -30,7 +30,6 @@

<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<Reference Include="System.Configuration" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
Expand Down
8 changes: 7 additions & 1 deletion src/Castle.Core/DynamicProxy/ProxyGenerator.cs
Expand Up @@ -556,7 +556,13 @@ public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, object targe

if (target != null)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Marshal.IsComObject(target))
#if NET6_0_OR_GREATER
bool doComHandling = OperatingSystem.IsWindows();
#else
bool doComHandling = true;
#endif

if (doComHandling && Marshal.IsComObject(target))
{
var interfaceId = interfaceToProxy.GUID;
if (interfaceId != Guid.Empty)
Expand Down

0 comments on commit 0076083

Please sign in to comment.