Add custom resolver for libcoreclr.so

This commit is contained in:
Adeel
2020-09-22 12:58:19 +03:00
parent b4b58d7c64
commit 19955faa8b
8 changed files with 32 additions and 10 deletions

View File

@@ -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

View File

@@ -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/

View File

@@ -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

View File

@@ -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);

View File

@@ -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>

View File

@@ -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>> ();

View File

@@ -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>

View File

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