2
0
Эх сурвалжийг харах

Merge pull request #900 from am11/feature/interop/net5.0

Add custom resolver for libcoreclr.so
Charlie Kindel 4 жил өмнө
parent
commit
e2e5cc200f

+ 11 - 2
.github/workflows/codeql-analysis.yml

@@ -33,8 +33,17 @@ jobs:
 
     # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
     # If this step fails, then you should remove it and run the build manually (see below)
-    - name: Autobuild
-      uses: github/codeql-action/autobuild@v1
+    # - name: Autobuild
+    #  uses: github/codeql-action/autobuild@v1
+
+    - name: Setup .NET Core
+      uses: actions/setup-dotnet@v1
+      with:
+        dotnet-version: 5.0.100-rc.1.20452.10
+    - name: Install dependencies
+      run: dotnet restore
+    - name: Build
+      run: dotnet build --configuration Release --no-restore
 
     # ℹ️ Command-line programs to run using the OS shell.
     # 📚 https://git.io/JvXDl

+ 2 - 2
.github/workflows/dotnet-core.yml

@@ -16,10 +16,10 @@ jobs:
     - name: Setup .NET Core
       uses: actions/setup-dotnet@v1
       with:
-        dotnet-version: 3.1.200
+        dotnet-version: 5.0.100-rc.1.20452.10
     - name: Install dependencies
       run: dotnet restore
     - name: Build
       run: dotnet build --configuration Release --no-restore
     - name: Test
-      run: dotnet test --no-restore --verbosity normal
+      run: dotnet test --no-restore --verbosity normal UnitTests/

+ 2 - 2
.github/workflows/publish.yml

@@ -13,7 +13,7 @@ jobs:
       - name: Setup dotnet
         uses: actions/setup-dotnet@v1
         with:
-          dotnet-version: 3.1.200
+          dotnet-version: 5.0.100-rc.1.20452.10
 
       # Publish
       - name: publish on version change
@@ -48,4 +48,4 @@ jobs:
           # NUGET_SOURCE: https://api.nuget.org
 
           # Flag to toggle pushing symbols along with nuget package to the server, disabled by default
-          INCLUDE_SYMBOLS: false
+          INCLUDE_SYMBOLS: false

+ 12 - 1
Terminal.Gui/ConsoleDrivers/CursesDriver/UnmanagedLibrary.cs

@@ -170,7 +170,7 @@ namespace Unix.Terminal {
 			if (ptr == IntPtr.Zero) {
 				throw new MissingMethodException (string.Format ("The native method \"{0}\" does not exist", methodName));
 			}
-            		return Marshal.GetDelegateForFunctionPointer<T>(ptr);  // non-generic version is obsolete
+			return Marshal.GetDelegateForFunctionPointer<T>(ptr);  // non-generic version is obsolete
 		}
 
 		/// <summary>
@@ -258,6 +258,17 @@ namespace Unix.Terminal {
 		/// </summary>
 		static class CoreCLR
 		{
+#if NET5_0
+			// Custom resolver to support true single-file apps
+			// (those which run directly from bundle; in-memory).
+			//     -1 on Unix means self-referencing binary (libcoreclr.so)
+			//     0 means fallback to CoreCLR's internal resolution
+			// Note: meaning of -1 stay the same even for non-single-file form factors.
+			static CoreCLR() =>  NativeLibrary.SetDllImportResolver(typeof(CoreCLR).Assembly,
+				(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) =>
+					libraryName == "libcoreclr.so" ? (IntPtr)(-1) : IntPtr.Zero);
+#endif
+
 			[DllImport ("libcoreclr.so")]
 			internal static extern IntPtr dlopen (string filename, int flags);
 

+ 1 - 1
Terminal.Gui/Terminal.Gui.csproj

@@ -1,6 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
+    <TargetFrameworks>net472;netstandard2.0;net5.0</TargetFrameworks>
     <RootNamespace>Terminal.Gui</RootNamespace>
     <AssemblyName>Terminal.Gui</AssemblyName>
     <DocumentationFile>bin\Release\Terminal.Gui.xml</DocumentationFile>

+ 2 - 0
Terminal.Gui/Views/TextView.cs

@@ -30,6 +30,8 @@ using System.Linq;
 using System.Text;
 using NStack;
 
+using Rune = System.Rune;
+
 namespace Terminal.Gui {
 	class TextModel {
 		List<List<Rune>> lines = new List<List<Rune>> ();

+ 1 - 1
UICatalog/UICatalog.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <TargetFramework>net5.0</TargetFramework>
     <StartupObject>UICatalog.UICatalogApp</StartupObject>
     <AssemblyVersion>1.0.0.1</AssemblyVersion>
     <LangVersion>8.0</LangVersion>

+ 1 - 1
UnitTests/UnitTests.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <TargetFramework>net5.0</TargetFramework>
     <IsPackable>false</IsPackable>
   </PropertyGroup>