Skip to content
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
5 changes: 5 additions & 0 deletions src/mono/mono/metadata/marshal-shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,11 @@ mono_marshal_shared_emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *ty
mono_mb_emit_byte (mb, CEE_STIND_I);
break;
}
case MONO_MARSHAL_CONV_OBJECT_IUNKNOWN: {
char *msg = g_strdup_printf ("Marshaling not supported for COM type MONO_MARSHAL_CONV_OBJECT_IUNKNOWN.");
mono_marshal_shared_mb_emit_exception_marshal_directive (mb, msg);
break;
}

default: {
g_error ("marshalling conversion %d not implemented", conv);
Expand Down
43 changes: 43 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,44 @@ void GenerateSourceFiles(string outputPath, int baseArg)
return (buildArgs, output);
}

private void EnsureComInteropCompiles(BuildArgs buildArgs, RunHost host, string id)
{
string programText = @"
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;

public class Test
{
public static int Main(string[] args)
{
var s = new STGMEDIUM();
ReleaseStgMedium(ref s);
return 42;
}

[DllImport(""ole32.dll"")]
internal static extern void ReleaseStgMedium(ref STGMEDIUM medium);
}

";

buildArgs = ExpandBuildArgs(buildArgs);

(string libraryDir, string output) = BuildProject(buildArgs,
id: id,
new BuildProjectOptions(
InitProject: () =>
{
File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), programText);
},
Publish: buildArgs.AOT,
DotnetWasmFromRuntimePack: true));

Assert.Contains("Generated app bundle at " + libraryDir, output);
}

private void EnsureWasmAbiRulesAreFollowed(BuildArgs buildArgs, RunHost host, string id)
{
string programText = @"
Expand Down Expand Up @@ -885,6 +923,11 @@ public void EnsureWasmAbiRulesAreFollowedInAOT(BuildArgs buildArgs, RunHost host
public void EnsureWasmAbiRulesAreFollowedInInterpreter(BuildArgs buildArgs, RunHost host, string id) =>
EnsureWasmAbiRulesAreFollowed(buildArgs, host, id);

[Theory]
[BuildAndRun(host: RunHost.Chrome, aot: true)]
public void EnsureComInteropCompilesInAOT(BuildArgs buildArgs, RunHost host, string id) =>
EnsureComInteropCompiles(buildArgs, host, id);

[Theory]
[BuildAndRun(host: RunHost.Chrome, aot: false)]
public void UCOWithSpecialCharacters(BuildArgs buildArgs, RunHost host, string id)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/Wasm.Build.Tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ being generated.

- Running:

Linux/macOS: `$ make -C src/mono/wasm run-build-tests`
Linux/macOS: `$ make -C src/mono/(browser|wasi) run-build-tests`
Windows: `.\dotnet.cmd build .\src\mono\wasm\Wasm.Build.Tests\Wasm.Build.Tests.csproj -c Release -t:Test -p:TargetOS=browser -p:TargetArchitecture=wasm`

- Specific tests can be run via `XUnitClassName`, and `XUnitMethodName`
Expand Down