Skip to content

Commit 0076083

Browse files
committed
Switch to preprocessor directives to avoid need for System.Runtime.InteropServices.RuntimeInformation package on net462
1 parent 9da21a7 commit 0076083

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/Castle.Core.Tests/Core.Tests/Logging/DiagnosticsLoggerTestCase.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ public void Reset()
4949

5050
private void AssertAdmin()
5151
{
52-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
52+
#if NETCOREAPP2_0_OR_GREATER
53+
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
54+
#else
55+
bool isWindows = !RunningOnMono();
56+
#endif
57+
if (isWindows)
5358
{
5459
WindowsPrincipal windowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
5560
try

src/Castle.Core/Castle.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

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

3635
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">

src/Castle.Core/DynamicProxy/ProxyGenerator.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,13 @@ public virtual object CreateInterfaceProxyWithTargetInterface(Type interfaceToPr
556556

557557
if (target != null)
558558
{
559-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Marshal.IsComObject(target))
559+
#if NET6_0_OR_GREATER
560+
bool doComHandling = OperatingSystem.IsWindows();
561+
#else
562+
bool doComHandling = true;
563+
#endif
564+
565+
if (doComHandling && Marshal.IsComObject(target))
560566
{
561567
var interfaceId = interfaceToProxy.GUID;
562568
if (interfaceId != Guid.Empty)

0 commit comments

Comments
 (0)