Skip to content

Commit

Permalink
Merge pull request #234 from 0xced/netstandard1.6-cleanup
Browse files Browse the repository at this point in the history
Remove .NET Standard 1.6 code
  • Loading branch information
mariotoffia authored Nov 24, 2021
2 parents 095bcf3 + 9ca0777 commit c9a4fad
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 61 deletions.
7 changes: 0 additions & 7 deletions Ductus.FluentDocker/Ductus.FluentDocker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="SharpCompress" Version="0.29.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
Expand Down
4 changes: 0 additions & 4 deletions Ductus.FluentDocker/Executors/ProcessExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public CommandResponse<TE> Execute()
if (0 != Env.Count)
foreach (var key in Env.Keys)
{
#if NETSTANDARD1_6
startInfo.Environment[key] = Env[key];
#else
startInfo.EnvironmentVariables[key] = Env[key];
#endif
}

Logger.Log($"cmd: {_command} - arg: {_arguments}");
Expand Down
19 changes: 0 additions & 19 deletions Ductus.FluentDocker/Extensions/CommandExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,6 @@ public static bool IsEmulatedNative()
}


#if NETSTANDARD1_6
public static bool IsDockerDnsAvailable()
{
try
{
Dns.GetHostEntryAsync("host.docker.internal").Wait();
return true;
}
catch (Exception ex) when (ex.GetBaseException() is SocketException)
{
return false;
}
}
#else
public static bool IsDockerDnsAvailable()
{
try
Expand All @@ -187,7 +173,6 @@ public static bool IsDockerDnsAvailable()
return false;
}
}
#endif

public static bool IsNative()
{
Expand All @@ -199,11 +184,7 @@ public static IPAddress EmulatedNativeAddress(bool useCache = true)
if (useCache && null != _cachedDockerIpAddress)
return _cachedDockerIpAddress;

#if NETSTANDARD1_6
var hostEntry = Dns.GetHostEntryAsync("host.docker.internal").Result;
#else
var hostEntry = Dns.GetHostEntry("host.docker.internal");
#endif
if (hostEntry.AddressList.Length > 0)
{
// Prefer IPv4 addresses
Expand Down
22 changes: 0 additions & 22 deletions Ductus.FluentDocker/Extensions/ResourceExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Ductus.FluentDocker.Model.Common;
using Ductus.FluentDocker.Resources;
Expand Down Expand Up @@ -97,28 +96,7 @@ public static string ToFile(this EmbeddedUri resource, TemplateString targetPath

private static Assembly GetAssembly(string assemblyName)
{
#if NETSTANDARD1_6
return GetAssemblies().First(x => x.GetName().Name == assemblyName);
}

internal static IEnumerable<Assembly> GetAssemblies()
{
foreach (var library in Microsoft.Extensions.DependencyModel.DependencyContext.Default.RuntimeLibraries)
{
Assembly assembly;
try
{
assembly = Assembly.Load(new AssemblyName(library.Name));
}
catch (FileNotFoundException)
{
continue;
}
yield return assembly;
}
#else
return AppDomain.CurrentDomain.GetAssemblies().First(x => x.GetName().Name == assemblyName);
#endif
}
}
}
9 changes: 0 additions & 9 deletions Ductus.FluentDocker/Resources/ResourceQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Ductus.FluentDocker.Extensions;

namespace Ductus.FluentDocker.Resources
{
Expand Down Expand Up @@ -33,18 +32,10 @@ public ResourceQuery Recursive()

public IEnumerable<ResourceInfo> Query()
{
#if NETSTANDARD1_6
if (string.IsNullOrWhiteSpace(_assembly))
// TODO : Consider rework of Fluent API
throw new InvalidOperationException($"It is not possible to execute {nameof(Query)} without first executing {nameof(From)}.");
var assembly = ResourceExtensions.GetAssemblies()
.First(x => x.GetName().Name.Equals(_assembly, StringComparison.OrdinalIgnoreCase));
#else
var assembly = string.IsNullOrEmpty(_assembly)
? Assembly.GetCallingAssembly() :
AppDomain.CurrentDomain.GetAssemblies()
.First(x => x.GetName().Name.Equals(_assembly, StringComparison.OrdinalIgnoreCase));
#endif

var q = assembly.GetManifestResourceNames();

Expand Down

0 comments on commit c9a4fad

Please sign in to comment.