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
6 changes: 5 additions & 1 deletion src/mono/mono/component/marshal-ilgen-stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ stub_emit_marshal_ilgen (EmitMarshalContext* m, int argnum, MonoType* t,
case MONO_TYPE_U8:
case MONO_TYPE_FNPTR:
return lightweight_cb->emit_marshal_scalar (m, argnum, t, spec, conv_arg, conv_arg_type, action);
default:
default: {
if (m_class_is_enumtype (m_type_data_get_klass_unchecked (t)))
return lightweight_cb->emit_marshal_scalar (m, argnum, t, spec, conv_arg, conv_arg_type, action);

emit_throw_exception (lightweight_cb, m->mb, "System", "ApplicationException",
g_strdup("Cannot marshal nonblittlable types without marshal-ilgen."));
break;
}
}

return 0;
}
Expand Down
13 changes: 13 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/NativeBuildTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,18 @@ public void NativeBuildIsRequired(Configuration config, bool aot)
(string _, string output) = PublishProject(info, config, new PublishOptions(ExpectSuccess: false, AOT: aot));
Assert.Contains("WasmBuildNative is required", output);
}

[Fact]
public async Task ZipArchiveInteropTest()
{
Configuration config = Configuration.Debug;
ProjectInfo info = CopyTestAsset(config, false, TestAsset.WasmBasicTestApp, "ZipArchiveInteropTest", extraProperties: "<WasmBuildNative>true</WasmBuildNative>");
BuildProject(info, config, new BuildOptions(AssertAppBundle: false));
RunResult result = await RunForBuildWithDotnetRun(new BrowserRunOptions(config, TestScenario: "ZipArchiveInteropTest"));
Assert.Collection(
result.TestOutput,
m => Assert.Equal("Zip file created successfully.", m)
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;
using System.IO.Compression;
using System.Globalization;
using System.Threading.Tasks;
using System.Resources;
using System.Runtime.InteropServices.JavaScript;
using System.Text;

public partial class ZipArchiveInteropTest
{
[JSExport]
public static async Task Run()
{
using var zipFileStream = new MemoryStream();
using var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create);

var entry = zipArchive.CreateEntry("sample.txt");
using (var entryStream = entry.Open())
{
await entryStream.WriteAsync(Encoding.UTF8.GetBytes("Sample text content"));
}

TestOutput.WriteLine("Zip file created successfully.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ try {
case "LibraryInitializerTest":
exit(0);
break;
case "ZipArchiveInteropTest":
exports.ZipArchiveInteropTest.Run();
exit(0);
break;
case "AppSettingsTest":
exports.AppSettingsTest.Run();
exit(0);
Expand Down
Loading