Skip to content

Commit

Permalink
Prepare v2.1.1 release, Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ied206 committed Feb 14, 2022
2 parents c62d830 + c43eb94 commit edbeb93
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 91 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*.cs]

# IDE0066: switch 문을 식으로 변환
dotnet_diagnostic.IDE0066.severity = silent

# IDE0063: 간단한 'using' 문 사용
dotnet_diagnostic.IDE0063.severity = silent

# IDE0060: 사용하지 않는 매개 변수를 제거하세요.
dotnet_diagnostic.IDE0060.severity = suggestion
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,6 @@ healthchecksdb
MigrationBackup/

# End of https://www.gitignore.io/api/csharp

# Visual Studio Code
.vscode/
3 changes: 0 additions & 3 deletions Joveler.DynLoader.Tests/GhostErrorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace Joveler.DynLoader.Tests
{
Expand Down
18 changes: 13 additions & 5 deletions Joveler.DynLoader.Tests/Joveler.DynLoader.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<!-- Windowws x86 & x64 -->
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<!-- Windowws ARM64 -->
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT' and '$(PROCESSOR_ARCHITECTURE)' == 'ARM64'">net6.0</TargetFrameworks>
<!-- POSIX -->
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net6.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -15,9 +19,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 6 additions & 7 deletions Joveler.DynLoader.Tests/PlatformConventionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

Expand Down Expand Up @@ -167,14 +166,14 @@ public void StringPtr()

// StringToHGlobalAuto
IntPtr fromUniPtr = defaultInstance.StringToHGlobalAuto(str);
try
try
{
fromUniStr = Marshal.PtrToStringUni(fromUniPtr);
Assert.IsTrue(str.Equals(fromUniStr, StringComparison.Ordinal));
}
finally
{
Marshal.FreeHGlobal(fromUniPtr);
}
finally
{
Marshal.FreeHGlobal(fromUniPtr);
}
IntPtr fromAnsiPtr = customInstance.StringToHGlobalAuto(str);
try
Expand Down Expand Up @@ -267,7 +266,7 @@ public void StringPtr()
Marshal.FreeHGlobal(ansiUtf8Ptr);
Marshal.FreeHGlobal(utf16Ptr);
}

}
#endregion
}
Expand Down
2 changes: 0 additions & 2 deletions Joveler.DynLoader.Tests/SimpleFIleMagicManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Joveler.DynLoader.Tests
{
Expand Down
2 changes: 1 addition & 1 deletion Joveler.DynLoader.Tests/SimpleFileMagicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SimpleFileMagicTests
private static SimpleFileMagic[] _magicLibs;

[ClassInitialize]
public static void Init(TestContext ctx)
public static void Init(TestContext _)
{
_magicLibs = new SimpleFileMagic[] { TestSetup.ExplicitMagic, TestSetup.ImplicitMagic };
_magicLibs = _magicLibs.Where(m => m != null).ToArray();
Expand Down
6 changes: 1 addition & 5 deletions Joveler.DynLoader.Tests/SimpleZLibManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Joveler.DynLoader.Tests
namespace Joveler.DynLoader.Tests
{
public class SimpleZLibManager : LoadManagerBase<SimpleZLib>
{
Expand Down
2 changes: 1 addition & 1 deletion Joveler.DynLoader.Tests/SimpleZLibTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SimpleZLibTests
private static SimpleZLib[] _zlibs;

[ClassInitialize]
public static void Init(TestContext ctx)
public static void Init(TestContext _)
{
_zlibs = new SimpleZLib[] { TestSetup.ExplicitZLib, TestSetup.ImplicitZLib };
_zlibs = _zlibs.Where(z => z != null).ToArray();
Expand Down
22 changes: 12 additions & 10 deletions Joveler.DynLoader.Tests/TestSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace Joveler.DynLoader.Tests
[TestClass]
public class TestSetup
{
public static string BaseDir { get; private set; }
public static string SampleDir { get; private set; }
public static string PackagedZLibPath { get; private set; }
public static SimpleZLib ExplicitZLib { get; private set; }
Expand All @@ -47,8 +46,11 @@ public class TestSetup
[AssemblyInitialize]
public static void AssemblyInitalize(TestContext ctx)
{
BaseDir = Path.GetFullPath(Path.Combine(TestHelper.GetProgramAbsolutePath(), "..", "..", ".."));
SampleDir = Path.Combine(BaseDir, "Samples");
#if NETFRAMEWORK
string libBaseDir = Path.GetFullPath(TestHelper.GetProgramAbsolutePath());
#else
string libBaseDir = Path.GetFullPath(Path.Combine(TestHelper.GetProgramAbsolutePath(), "..", "..", ".."));
#endif

const string zlibDllName = "zlibwapi.dll";
const string magicDllName = "libmagic-1.dll";
Expand Down Expand Up @@ -82,9 +84,9 @@ public static void AssemblyInitalize(TestContext ctx)

string libDir;
#if NETFRAMEWORK
libDir = arch;
libDir = Path.Combine(libBaseDir, arch);
#elif NETCOREAPP
libDir = "runtimes";
libDir = Path.Combine(libBaseDir, "runtimes");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
libDir = Path.Combine(libDir, "win-");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Expand Down Expand Up @@ -121,15 +123,15 @@ public static void AssemblyInitalize(TestContext ctx)
ExplicitZLib = new SimpleZLib();
ExplicitZLib.LoadLibrary(PackagedZLibPath);
if (implicitLoadZLib)
{
{
ImplicitZLib = new SimpleZLib();
ImplicitZLib.LoadLibrary();
}

ExplicitMagic = new SimpleFileMagic();
ExplicitMagic.LoadLibrary(PackagedMagicPath);
if (implicitLoadMagic)
{
{
ImplicitMagic = new SimpleFileMagic();
ImplicitMagic.LoadLibrary();
}
Expand All @@ -150,9 +152,9 @@ public static void AssemblyCleanup()
ImplicitMagic?.Dispose();
PlatformLib?.Dispose();
}
#endregion
#endregion

#region TestHelper
#region TestHelper
public class TestHelper
{
public static string GetProgramAbsolutePath()
Expand All @@ -163,6 +165,6 @@ public static string GetProgramAbsolutePath()
return path;
}
}
#endregion
#endregion
}
}
Binary file not shown.
Binary file not shown.
13 changes: 9 additions & 4 deletions Joveler.DynLoader.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29326.143
# Visual Studio Version 17
VisualStudioVersion = 17.0.32126.317
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Joveler.DynLoader", "Joveler.DynLoader\Joveler.DynLoader.csproj", "{1E5FDB28-DD9A-4D54-A2C7-6A0E24E86457}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Joveler.DynLoader", "Joveler.DynLoader\Joveler.DynLoader.csproj", "{1E5FDB28-DD9A-4D54-A2C7-6A0E24E86457}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Joveler.DynLoader.Tests", "Joveler.DynLoader.Tests\Joveler.DynLoader.Tests.csproj", "{92528796-6097-46FB-9719-30FAB6F1E445}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Joveler.DynLoader.Tests", "Joveler.DynLoader.Tests\Joveler.DynLoader.Tests.csproj", "{92528796-6097-46FB-9719-30FAB6F1E445}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{255CE323-464B-49E3-9ABE-C5054340B9B6}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
25 changes: 1 addition & 24 deletions Joveler.DynLoader/DynLoaderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,8 @@ public abstract class DynLoaderBase : IDisposable
/// Create an instance of DynLoaderBase and set platform conventions.
/// </summary>
protected DynLoaderBase()
{
{
// Set platform conventions.
#if NETFRAMEWORK
UnicodeConvention = UnicodeConvention.Utf16;
PlatformLongSize = PlatformLongSize.Long32;
if (Environment.Is64BitProcess)
{
PlatformDataModel = PlatformDataModel.LLP64;
PlatformBitness = PlatformBitness.Bit64;
}
else
{
PlatformDataModel = PlatformDataModel.ILP32;
PlatformBitness = PlatformBitness.Bit32;
}
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
UnicodeConvention = UnicodeConvention.Utf16;
Expand Down Expand Up @@ -104,7 +90,6 @@ protected DynLoaderBase()
PlatformBitness = PlatformBitness.Bit64;
break;
}
#endif
}

/// <summary>
Expand Down Expand Up @@ -168,9 +153,7 @@ public void LoadLibrary(string libPath)
// No need to check _hModule.IsInvalid here.
_hModule = new NetSafeLibHandle(libPath);
#else
#if !NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
#endif
{
// https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order
string libDir = Path.GetDirectoryName(libPath);
Expand Down Expand Up @@ -200,7 +183,6 @@ public void LoadLibrary(string libPath)
throw new DllNotFoundException($"{exceptMsg}: {errorMsg} (0x{errorCode:X8})");
}
}
#if !NETFRAMEWORK
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
_hModule = new LinuxSafeLibHandle(libPath);
Expand Down Expand Up @@ -235,7 +217,6 @@ public void LoadLibrary(string libPath)
{
throw new PlatformNotSupportedException();
}
#endif
#endif

// Load functions
Expand Down Expand Up @@ -284,9 +265,7 @@ protected T GetFuncPtr<T>(string funcSymbol) where T : Delegate
#if NETCOREAPP3_1
funcPtr = NativeLibrary.GetExport(_hModule.DangerousGetHandle(), funcSymbol);
#else
#if !NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
#endif
{
funcPtr = NativeMethods.Win32.GetProcAddress(_hModule, funcSymbol);

Expand All @@ -295,7 +274,6 @@ protected T GetFuncPtr<T>(string funcSymbol) where T : Delegate
if (funcPtr == IntPtr.Zero)
throw new EntryPointNotFoundException($"Unable to find an entry point named '{funcSymbol}' in DLL.", new Win32Exception());
}
#if !NETFRAMEWORK
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
funcPtr = NativeMethods.Linux.DLSym(_hModule, funcSymbol);
Expand Down Expand Up @@ -332,7 +310,6 @@ protected T GetFuncPtr<T>(string funcSymbol) where T : Delegate
{
throw new PlatformNotSupportedException();
}
#endif
#endif

return Marshal.GetDelegateForFunctionPointer<T>(funcPtr);
Expand Down
12 changes: 10 additions & 2 deletions Joveler.DynLoader/Joveler.DynLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;netcoreapp3.1</TargetFrameworks>
<PackageId>Joveler.DynLoader</PackageId>
<Title>Joveler.DynLoader</Title>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<Authors>Hajin Jang</Authors>
<Company>Joveler</Company>
<Description>Cross-platform native dynamic library loader for .NET.
Expand All @@ -15,10 +15,18 @@ Supports Windows, Linux, and macOS.</Description>
<PackageProjectUrl>https://github.com/ied206/Joveler.DynLoader</PackageProjectUrl>
<PackageIcon>images\Logo.png</PackageIcon>
<RepositoryUrl>https://github.com/ied206/Joveler.DynLoader</RepositoryUrl>
<PackageReleaseNotes>- Avoid calling virtual methods from constructors in DynLoaderBase.</PackageReleaseNotes>
<PackageReleaseNotes>- Official support for ARM64 macOS.
- Unify .NET Framework 4.5.1 codebase and .NET Standard 2.0 codebase.</PackageReleaseNotes>
<PackageTags>native pinvoke interop dynamic library loader dll so dylib</PackageTags>
</PropertyGroup>
<!-- PackageReference -->
<ItemGroup>
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" Condition=" '$(TargetFramework)' == 'net451' " />
</ItemGroup>
<!-- NuGet Pacakge -->
<ItemGroup>
<!-- NuGet Pacakge Icon -->
<None Include="..\.editorconfig" Link=".editorconfig" />
<None Include="..\Image\Logo.png" Pack="true" PackagePath="images\" />
</ItemGroup>
</Project>
Loading

0 comments on commit edbeb93

Please sign in to comment.