Skip to content

Commit

Permalink
Remove unnecessary conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlock committed Feb 10, 2025
1 parent b3dc686 commit 64a4c7b
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions tracer/src/Datadog.FleetInstaller/GacInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,16 @@
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
#if NETFRAMEWORK
using System.Runtime.Remoting;
using System.Security.Permissions;
#endif
using PInvoke;

namespace Datadog.FleetInstaller;

internal static class GacInstaller
{
#if NETFRAMEWORK
private static readonly string MsCorLibDirectory
= Path.GetDirectoryName(Assembly.GetAssembly(typeof(object))!.Location.Replace('/', '\\'))!;
#endif

/// <summary>
/// Publish the tracer files to the GAC.
Expand Down Expand Up @@ -81,15 +77,13 @@ private static unsafe bool TryGacInstall(ILogger log, IEnumerable<(string Assemb
{
try
{
#if NETFRAMEWORK
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
var fusionDllPath = Path.Combine(MsCorLibDirectory, "fusion.dll");
if (LoadLibrary(fusionDllPath) == IntPtr.Zero)
{
log.WriteError($"Error loading fusion.dll from '{fusionDllPath}': path not found");
return false;
}
#endif

var retValue = Fusion.CreateAssemblyCache(out var ppAsmCache, 0);
if (retValue != HResult.Code.S_OK)
Expand Down Expand Up @@ -142,9 +136,7 @@ private static unsafe bool TryGacUninstall(ILogger log, IEnumerable<(string Asse
{
try
{
#if NETFRAMEWORK
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
#endif

var retValue = Fusion.CreateAssemblyCache(out var ppAsmCache, 0);
if (retValue != HResult.Code.S_OK)
Expand Down Expand Up @@ -200,11 +192,6 @@ private static unsafe bool TryGacUninstall(ILogger log, IEnumerable<(string Asse
}
}

// #if NETCOREAPP
// [LibraryImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16)]
// private static partial IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPWStr)] string filename);
// #else
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPWStr)] string filename);
// #endif
}

0 comments on commit 64a4c7b

Please sign in to comment.