Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix handling of non-ASCII assembly paths on .NET Framework #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions netfx_loader/ClrLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public static IntPtr CreateAppDomain(
[DllExport("pyclr_get_function", CallingConvention.Cdecl)]
public static IntPtr GetFunction(
IntPtr domain,
[MarshalAs(UnmanagedType.LPStr)] string assemblyPath,
[MarshalAs(UnmanagedType.LPStr)] string typeName,
[MarshalAs(UnmanagedType.LPStr)] string function
[MarshalAs(UnmanagedType.LPUTF8Str)] string assemblyPath,
[MarshalAs(UnmanagedType.LPUTF8Str)] string typeName,
[MarshalAs(UnmanagedType.LPUTF8Str)] string function
)
{
try
Expand Down
35 changes: 27 additions & 8 deletions tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import pytest
from subprocess import check_call
import os
Expand All @@ -24,7 +25,7 @@ def build_example(tmpdir_factory, framework):
return out


def test_mono(example_netstandard):
def test_mono(example_netstandard: Path):
from clr_loader import get_mono

mono = get_mono()
Expand All @@ -33,7 +34,7 @@ def test_mono(example_netstandard):
run_tests(asm)


def test_mono_debug(example_netstandard):
def test_mono_debug(example_netstandard: Path):
from clr_loader import get_mono

mono = get_mono(
Expand All @@ -46,23 +47,26 @@ def test_mono_debug(example_netstandard):

run_tests(asm)

def test_mono_signal_chaining(example_netstandard):

def test_mono_signal_chaining(example_netstandard: Path):
from clr_loader import get_mono

mono = get_mono(set_signal_chaining=True)
asm = mono.get_assembly(example_netstandard / "example.dll")

run_tests(asm)

def test_mono_set_dir(example_netstandard):

def test_mono_set_dir(example_netstandard: Path):
from clr_loader import get_mono

mono = get_mono(assembly_dir="/usr/lib", config_dir="/etc")
asm = mono.get_assembly(example_netstandard / "example.dll")

run_tests(asm)

def test_coreclr(example_netcore):

def test_coreclr(example_netcore: Path):
from clr_loader import get_coreclr

coreclr = get_coreclr(runtime_config=example_netcore / "example.runtimeconfig.json")
Expand All @@ -71,7 +75,7 @@ def test_coreclr(example_netcore):
run_tests(asm)


def test_coreclr_autogenerated_runtimeconfig(example_netstandard):
def test_coreclr_autogenerated_runtimeconfig(example_netstandard: Path):
from multiprocessing import get_context

p = get_context("spawn").Process(
Expand All @@ -82,7 +86,7 @@ def test_coreclr_autogenerated_runtimeconfig(example_netstandard):
p.close()


def _do_test_coreclr_autogenerated_runtimeconfig(example_netstandard):
def _do_test_coreclr_autogenerated_runtimeconfig(example_netstandard: Path):
from clr_loader import get_coreclr

coreclr = get_coreclr()
Expand All @@ -94,9 +98,24 @@ def _do_test_coreclr_autogenerated_runtimeconfig(example_netstandard):
@pytest.mark.skipif(
sys.platform != "win32", reason=".NET Framework only exists on Windows"
)
def test_netfx(example_netstandard):
def test_netfx(example_netstandard: Path):
from clr_loader import get_netfx

netfx = get_netfx()
asm = netfx.get_assembly(example_netstandard / "example.dll")

run_tests(asm)


@pytest.mark.skipif(
sys.platform != "win32", reason=".NET Framework only exists on Windows"
)
def test_netfx_chinese_path(example_netstandard: Path, tmpdir_factory):
from clr_loader import get_netfx

tmp_path = Path(tmpdir_factory.mktemp("example-中国"))
shutil.copytree(example_netstandard, tmp_path, dirs_exist_ok=True)

netfx = get_netfx()
asm = netfx.get_assembly(os.path.join(example_netstandard, "example.dll"))

Expand Down