From 3e2069d706b5a8086fd55652d32cbec2c910fa9c Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 25 Jul 2025 15:50:44 +0200 Subject: [PATCH 1/7] testing --- .../System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs | 3 +++ .../src/System/SearchValues/IndexOfAnyAsciiSearcher.cs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs index 6ab37cfc49436f..1bcacf2891dbb0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace System.Buffers.Text { @@ -19,6 +20,8 @@ internal static bool IsValid(TBase64Validatable validatab #if NET while (!base64Text.IsEmpty) { + if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Span is empty or not initialized properly. " + base64Text.Length); + int index = validatable.IndexOfAnyExcept(base64Text); if ((uint)index >= (uint)base64Text.Length) { diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs index 7f8393f483179e..9646358cffcada 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs @@ -288,6 +288,8 @@ private static TResult IndexOfAnyCore { + if (searchSpaceLength != 0 && Unsafe.IsNullRef(ref searchSpace)) throw new InvalidOperationException("Span is empty or not initialized properly. " + searchSpaceLength); + ref short currentSearchSpace = ref searchSpace; if (searchSpaceLength < Vector128.Count) From a648389f33f42f5879ab4fa66baeb56d1c8ec373 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 28 Jul 2025 15:34:15 +0200 Subject: [PATCH 2/7] repro --- .../Base64Helper/Base64ValidatorHelper.cs | 4 +- src/mono/sample/wasm/browser/Program.cs | 112 +++++++++++++++++- .../wasm/browser/Wasm.Browser.Sample.csproj | 15 +++ src/mono/sample/wasm/browser/main.js | 19 +-- src/mono/wasm/build/WasmApp.Common.targets | 2 - 5 files changed, 131 insertions(+), 21 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs index 1bcacf2891dbb0..c2bc135a0b5e8c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs @@ -12,6 +12,8 @@ internal static bool IsValid(TBase64Validatable validatab where TBase64Validatable : IBase64Validatable where T : struct { + if (!base64Text.IsEmpty && Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Base64Helper1: Span is empty or not initialized properly. " + base64Text.Length); + int length = 0, paddingCount = 0; T lastChar = default; @@ -20,7 +22,7 @@ internal static bool IsValid(TBase64Validatable validatab #if NET while (!base64Text.IsEmpty) { - if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Span is empty or not initialized properly. " + base64Text.Length); + if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Base64Helper2: Span is empty or not initialized properly. " + base64Text.Length+ " "+length); int index = validatable.IndexOfAnyExcept(base64Text); if ((uint)index >= (uint)base64Text.Length) diff --git a/src/mono/sample/wasm/browser/Program.cs b/src/mono/sample/wasm/browser/Program.cs index ce542da6201921..cb88156a27eb35 100644 --- a/src/mono/sample/wasm/browser/Program.cs +++ b/src/mono/sample/wasm/browser/Program.cs @@ -2,20 +2,124 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Text; using System.Runtime.InteropServices.JavaScript; using System.Runtime.InteropServices; +using System.Linq; +using System.Text; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; namespace Sample { + public interface IBase64Validatable + { + } + + public readonly struct Base64CharValidatable : IBase64Validatable + { + private static readonly string s_validBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + } + public partial class Test { - public static int Main(string[] args) + /* + public static bool IsValid(TBase64Validatable validatable, ReadOnlySpan base64Text, out int decodedLength) + where TBase64Validatable : IBase64Validatable + where T : struct + { + int length = 0, paddingCount = 0; + T lastChar = default; + + if (!base64Text.IsEmpty) + { + if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) + { + decodedLength = 0; + return false; + } + } + + decodedLength = base64Text.Length; + return true; + } + + public static bool IsValid(ReadOnlySpan base64Text, out int decodedLength) => + IsValid(default(Base64CharValidatable), base64Text, out decodedLength); + + public unsafe static int Main(string[] args) { - DisplayMeaning(42); + try + { + var text = "YQ=="; + var chars = text.ToArray(); + var span = (ReadOnlySpan)chars; + var t = IsValid(span, out int decodedLength); + Console.WriteLine($"{text} -> {t}:{decodedLength} {span.Length}"); + } + catch (Exception ex) + { + Console.WriteLine(ex); + return -1; + } + return 0; + }*/ + + public unsafe static int Main(string[] args) + { + try + { + var text = "YQ=="; + var chars = text.ToArray(); + var span = (ReadOnlySpan)chars; + var t = Base64.IsValid(span, out int decodedLength); + Console.WriteLine($"{text} -> {t}:{decodedLength} {span.Length}"); + } + catch (Exception ex) + { + Console.WriteLine(ex); + return -1; + } return 0; } - [JSImport("Sample.Test.displayMeaning", "main.js")] - internal static partial void DisplayMeaning(int meaning); + /* + [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.Text.Base64Helper", "System.Private.CoreLib")] + [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.Text.Base64", "System.Private.CoreLib")] + [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.IndexOfAnyAsciiSearcher", "System.Private.CoreLib")] + [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.IndexOfAnyAsciiSearcher.AsciiState", "System.Private.CoreLib")] + [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.IndexOfAnyAsciiSearcher.AnyByteState", "System.Private.CoreLib")] + public unsafe static int Main(string[] args) + { + try + { + Console.WriteLine("Hello from Sample.Test.Main 1"); + var utf8WithByteToBeIgnored = "YQ=="; + var expectedLength = 1; + var utf8BytesWithByteToBeIgnored = utf8WithByteToBeIgnored.ToArray(); + + //Console.WriteLine("Hello from Sample.Test.Main 2"); + //Console.WriteLine(Base64.IsValid((ReadOnlySpan)utf8BytesWithByteToBeIgnored)); + //Console.WriteLine("Hello from Sample.Test.Main 3"); + var utf8BytesWithByteToBeIgnored2 = utf8WithByteToBeIgnored.ToArray(); + var utf8BytesWithByteToBeIgnored2RS = (ReadOnlySpan)utf8BytesWithByteToBeIgnored2; + fixed (char* charsPtr = &MemoryMarshal.GetReference(utf8BytesWithByteToBeIgnored2RS)) + { + Console.WriteLine($"Hello from Sample.Test.Main 4 {(IntPtr)charsPtr}"); + Console.WriteLine(Base64.IsValid(utf8BytesWithByteToBeIgnored2RS, out int decodedLength)); + Console.WriteLine($"expectedLength: {expectedLength}, decodedLength: {decodedLength} {utf8BytesWithByteToBeIgnored2.Length}"); + + Console.WriteLine("Hello from Sample.Test.Main E"); + } + } + catch (Exception ex) + { + Console.WriteLine($"Exception: {ex}"); + Console.WriteLine($"Exception: {ex.Message}"); + Console.WriteLine($"Exception: {ex.StackTrace}"); + return -1; + } + return 0; + }*/ } } diff --git a/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj b/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj index 365ba7276cb0b9..215e0ec9387f00 100644 --- a/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj +++ b/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj @@ -3,4 +3,19 @@ + + + + true + false + false + true + false + true + false + + diff --git a/src/mono/sample/wasm/browser/main.js b/src/mono/sample/wasm/browser/main.js index 20fd268d65b9ac..118c752f84c97b 100644 --- a/src/mono/sample/wasm/browser/main.js +++ b/src/mono/sample/wasm/browser/main.js @@ -3,25 +3,16 @@ import { dotnet, exit } from './_framework/dotnet.js' -function displayMeaning(meaning) { - document.getElementById("out").innerHTML = `${meaning}`; -} - try { - const { setModuleImports } = await dotnet + const { runMain } = await dotnet .withElementOnExit() + .withDiagnosticTracing(true) + .withEnvironmentVariable("MONO_LOG_LEVEL", "debug") + .withEnvironmentVariable("MONO_LOG_MASK", "all") .withExitOnUnhandledError() .create(); - setModuleImports("main.js", { - Sample: { - Test: { - displayMeaning - } - } - }); - - await dotnet.run(); + await runMain(); } catch (err) { exit(2, err); diff --git a/src/mono/wasm/build/WasmApp.Common.targets b/src/mono/wasm/build/WasmApp.Common.targets index 8d96474284200b..c36f7676c3f600 100644 --- a/src/mono/wasm/build/WasmApp.Common.targets +++ b/src/mono/wasm/build/WasmApp.Common.targets @@ -596,8 +596,6 @@ <_MonoAotCrossCompilerPath>@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier',$(RuntimeIdentifier))) - From 6745476a045d53dc00035b2a2f9942378c4afe5f Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 28 Jul 2025 17:32:52 +0200 Subject: [PATCH 3/7] more --- .../tests/System.Memory.Tests.csproj | 6 + .../Base64Helper/Base64ValidatorHelper.cs | 20 +++- .../System/Buffers/Text/Base64Validator.cs | 8 +- .../SearchValues/IndexOfAnyAsciiSearcher.cs | 2 - src/mono/sample/wasm/browser/Program.cs | 112 +----------------- .../wasm/browser/Wasm.Browser.Sample.csproj | 15 --- src/mono/sample/wasm/browser/main.js | 19 ++- src/mono/wasm/build/WasmApp.Common.targets | 2 + 8 files changed, 46 insertions(+), 138 deletions(-) diff --git a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj index 2de051c81fbdba..712b700d633f62 100644 --- a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj +++ b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj @@ -4,6 +4,12 @@ true true $(NetCoreAppCurrent) + true + + true + IL2091 diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs index c2bc135a0b5e8c..0fd9196f46788c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs @@ -12,7 +12,7 @@ internal static bool IsValid(TBase64Validatable validatab where TBase64Validatable : IBase64Validatable where T : struct { - if (!base64Text.IsEmpty && Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Base64Helper1: Span is empty or not initialized properly. " + base64Text.Length); + if (!base64Text.IsEmpty && Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Base64Helper1: Span is empty or not initialized properly. " + base64Text.Length+dummy); int length = 0, paddingCount = 0; T lastChar = default; @@ -22,8 +22,6 @@ internal static bool IsValid(TBase64Validatable validatab #if NET while (!base64Text.IsEmpty) { - if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Base64Helper2: Span is empty or not initialized properly. " + base64Text.Length+ " "+length); - int index = validatable.IndexOfAnyExcept(base64Text); if ((uint)index >= (uint)base64Text.Length) { @@ -144,9 +142,16 @@ internal interface IBase64Validatable bool IsEncodingPad(T value); bool ValidateAndDecodeLength(T lastChar, int length, int paddingCount, out int decodedLength); } - +#pragma warning disable CS0414 internal readonly struct Base64CharValidatable : IBase64Validatable { + // to make structure size 4 instead of 1 as workaround for WASM AOT problem with empty structs + private readonly int dummy; + public Base64CharValidatable() + { + dummy = 0; + } + #if NET private static readonly SearchValues s_validBase64Chars = SearchValues.Create("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); @@ -172,6 +177,13 @@ public bool ValidateAndDecodeLength(char lastChar, int length, int paddingCount, internal readonly struct Base64ByteValidatable : IBase64Validatable { + // to make structure size 4 instead of 1 as workaround for WASM AOT problem with empty structs + private readonly int dummy; + public Base64ByteValidatable() + { + dummy = 0; + } + #if NET private static readonly SearchValues s_validBase64Chars = SearchValues.Create(default(Base64EncoderByte).EncodingMap); diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs index c2e4ad82a4ba0d..7b9b9ebc170c15 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs @@ -17,7 +17,7 @@ public static partial class Base64 /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n'. /// public static bool IsValid(ReadOnlySpan base64Text) => - Base64Helper.IsValid(default(Base64CharValidatable), base64Text, out _); + Base64Helper.IsValid(default(Base64CharValidatable), base64Text, 123, out _); /// Validates that the specified span of text is comprised of valid base-64 encoded data. /// A span of text to validate. @@ -30,7 +30,7 @@ public static bool IsValid(ReadOnlySpan base64Text) => /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n'. /// public static bool IsValid(ReadOnlySpan base64Text, out int decodedLength) => - Base64Helper.IsValid(default(Base64CharValidatable), base64Text, out decodedLength); + Base64Helper.IsValid(default(Base64CharValidatable), base64Text, 123, out decodedLength); /// Validates that the specified span of UTF-8 text is comprised of valid base-64 encoded data. /// A span of UTF-8 text to validate. @@ -41,7 +41,7 @@ public static bool IsValid(ReadOnlySpan base64Text, out int decodedLength) /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n' (as bytes). /// public static bool IsValid(ReadOnlySpan base64TextUtf8) => - Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, out _); + Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, 123, out _); /// Validates that the specified span of UTF-8 text is comprised of valid base-64 encoded data. /// A span of UTF-8 text to validate. @@ -53,7 +53,7 @@ public static bool IsValid(ReadOnlySpan base64TextUtf8) => /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n' (as bytes). /// public static bool IsValid(ReadOnlySpan base64TextUtf8, out int decodedLength) => - Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, out decodedLength); + Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, 123, out decodedLength); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs index 9646358cffcada..7f8393f483179e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs @@ -288,8 +288,6 @@ private static TResult IndexOfAnyCore { - if (searchSpaceLength != 0 && Unsafe.IsNullRef(ref searchSpace)) throw new InvalidOperationException("Span is empty or not initialized properly. " + searchSpaceLength); - ref short currentSearchSpace = ref searchSpace; if (searchSpaceLength < Vector128.Count) diff --git a/src/mono/sample/wasm/browser/Program.cs b/src/mono/sample/wasm/browser/Program.cs index cb88156a27eb35..ce542da6201921 100644 --- a/src/mono/sample/wasm/browser/Program.cs +++ b/src/mono/sample/wasm/browser/Program.cs @@ -2,124 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Buffers.Text; using System.Runtime.InteropServices.JavaScript; using System.Runtime.InteropServices; -using System.Linq; -using System.Text; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; namespace Sample { - public interface IBase64Validatable - { - } - - public readonly struct Base64CharValidatable : IBase64Validatable - { - private static readonly string s_validBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - } - public partial class Test { - /* - public static bool IsValid(TBase64Validatable validatable, ReadOnlySpan base64Text, out int decodedLength) - where TBase64Validatable : IBase64Validatable - where T : struct - { - int length = 0, paddingCount = 0; - T lastChar = default; - - if (!base64Text.IsEmpty) - { - if (Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) - { - decodedLength = 0; - return false; - } - } - - decodedLength = base64Text.Length; - return true; - } - - public static bool IsValid(ReadOnlySpan base64Text, out int decodedLength) => - IsValid(default(Base64CharValidatable), base64Text, out decodedLength); - - public unsafe static int Main(string[] args) + public static int Main(string[] args) { - try - { - var text = "YQ=="; - var chars = text.ToArray(); - var span = (ReadOnlySpan)chars; - var t = IsValid(span, out int decodedLength); - Console.WriteLine($"{text} -> {t}:{decodedLength} {span.Length}"); - } - catch (Exception ex) - { - Console.WriteLine(ex); - return -1; - } - return 0; - }*/ - - public unsafe static int Main(string[] args) - { - try - { - var text = "YQ=="; - var chars = text.ToArray(); - var span = (ReadOnlySpan)chars; - var t = Base64.IsValid(span, out int decodedLength); - Console.WriteLine($"{text} -> {t}:{decodedLength} {span.Length}"); - } - catch (Exception ex) - { - Console.WriteLine(ex); - return -1; - } + DisplayMeaning(42); return 0; } - /* - [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.Text.Base64Helper", "System.Private.CoreLib")] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.Text.Base64", "System.Private.CoreLib")] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.IndexOfAnyAsciiSearcher", "System.Private.CoreLib")] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.IndexOfAnyAsciiSearcher.AsciiState", "System.Private.CoreLib")] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Buffers.IndexOfAnyAsciiSearcher.AnyByteState", "System.Private.CoreLib")] - public unsafe static int Main(string[] args) - { - try - { - Console.WriteLine("Hello from Sample.Test.Main 1"); - var utf8WithByteToBeIgnored = "YQ=="; - var expectedLength = 1; - var utf8BytesWithByteToBeIgnored = utf8WithByteToBeIgnored.ToArray(); - - //Console.WriteLine("Hello from Sample.Test.Main 2"); - //Console.WriteLine(Base64.IsValid((ReadOnlySpan)utf8BytesWithByteToBeIgnored)); - //Console.WriteLine("Hello from Sample.Test.Main 3"); - var utf8BytesWithByteToBeIgnored2 = utf8WithByteToBeIgnored.ToArray(); - var utf8BytesWithByteToBeIgnored2RS = (ReadOnlySpan)utf8BytesWithByteToBeIgnored2; - fixed (char* charsPtr = &MemoryMarshal.GetReference(utf8BytesWithByteToBeIgnored2RS)) - { - Console.WriteLine($"Hello from Sample.Test.Main 4 {(IntPtr)charsPtr}"); - Console.WriteLine(Base64.IsValid(utf8BytesWithByteToBeIgnored2RS, out int decodedLength)); - Console.WriteLine($"expectedLength: {expectedLength}, decodedLength: {decodedLength} {utf8BytesWithByteToBeIgnored2.Length}"); - - Console.WriteLine("Hello from Sample.Test.Main E"); - } - } - catch (Exception ex) - { - Console.WriteLine($"Exception: {ex}"); - Console.WriteLine($"Exception: {ex.Message}"); - Console.WriteLine($"Exception: {ex.StackTrace}"); - return -1; - } - return 0; - }*/ + [JSImport("Sample.Test.displayMeaning", "main.js")] + internal static partial void DisplayMeaning(int meaning); } } diff --git a/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj b/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj index 215e0ec9387f00..365ba7276cb0b9 100644 --- a/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj +++ b/src/mono/sample/wasm/browser/Wasm.Browser.Sample.csproj @@ -3,19 +3,4 @@ - - - - true - false - false - true - false - true - false - - diff --git a/src/mono/sample/wasm/browser/main.js b/src/mono/sample/wasm/browser/main.js index 118c752f84c97b..20fd268d65b9ac 100644 --- a/src/mono/sample/wasm/browser/main.js +++ b/src/mono/sample/wasm/browser/main.js @@ -3,16 +3,25 @@ import { dotnet, exit } from './_framework/dotnet.js' +function displayMeaning(meaning) { + document.getElementById("out").innerHTML = `${meaning}`; +} + try { - const { runMain } = await dotnet + const { setModuleImports } = await dotnet .withElementOnExit() - .withDiagnosticTracing(true) - .withEnvironmentVariable("MONO_LOG_LEVEL", "debug") - .withEnvironmentVariable("MONO_LOG_MASK", "all") .withExitOnUnhandledError() .create(); - await runMain(); + setModuleImports("main.js", { + Sample: { + Test: { + displayMeaning + } + } + }); + + await dotnet.run(); } catch (err) { exit(2, err); diff --git a/src/mono/wasm/build/WasmApp.Common.targets b/src/mono/wasm/build/WasmApp.Common.targets index c36f7676c3f600..8d96474284200b 100644 --- a/src/mono/wasm/build/WasmApp.Common.targets +++ b/src/mono/wasm/build/WasmApp.Common.targets @@ -596,6 +596,8 @@ <_MonoAotCrossCompilerPath>@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier',$(RuntimeIdentifier))) + From c1941f9c03d7741078cb95f2944f10b66a4e6bc0 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 28 Jul 2025 17:34:35 +0200 Subject: [PATCH 4/7] more --- src/libraries/System.Memory/tests/System.Memory.Tests.csproj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj index 712b700d633f62..caeabbd3565c07 100644 --- a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj +++ b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj @@ -5,11 +5,6 @@ true $(NetCoreAppCurrent) true - - true - IL2091 From 283d5a494d95e559f5721c1fe74ecd67ff6526a8 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 28 Jul 2025 17:35:58 +0200 Subject: [PATCH 5/7] more --- .../System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs index 0fd9196f46788c..0798b31c1b2da3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs @@ -12,7 +12,7 @@ internal static bool IsValid(TBase64Validatable validatab where TBase64Validatable : IBase64Validatable where T : struct { - if (!base64Text.IsEmpty && Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Base64Helper1: Span is empty or not initialized properly. " + base64Text.Length+dummy); + if (!base64Text.IsEmpty && Unsafe.IsNullRef(ref MemoryMarshal.GetReference(base64Text))) throw new InvalidOperationException("Base64Helper1: Span is empty or not initialized properly. " + base64Text.Length); int length = 0, paddingCount = 0; T lastChar = default; From 931b251e847b87f1cb39a884b53d7ea5df7081e5 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 28 Jul 2025 17:36:59 +0200 Subject: [PATCH 6/7] more --- .../src/System/Buffers/Text/Base64Validator.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs index 7b9b9ebc170c15..c2e4ad82a4ba0d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs @@ -17,7 +17,7 @@ public static partial class Base64 /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n'. /// public static bool IsValid(ReadOnlySpan base64Text) => - Base64Helper.IsValid(default(Base64CharValidatable), base64Text, 123, out _); + Base64Helper.IsValid(default(Base64CharValidatable), base64Text, out _); /// Validates that the specified span of text is comprised of valid base-64 encoded data. /// A span of text to validate. @@ -30,7 +30,7 @@ public static bool IsValid(ReadOnlySpan base64Text) => /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n'. /// public static bool IsValid(ReadOnlySpan base64Text, out int decodedLength) => - Base64Helper.IsValid(default(Base64CharValidatable), base64Text, 123, out decodedLength); + Base64Helper.IsValid(default(Base64CharValidatable), base64Text, out decodedLength); /// Validates that the specified span of UTF-8 text is comprised of valid base-64 encoded data. /// A span of UTF-8 text to validate. @@ -41,7 +41,7 @@ public static bool IsValid(ReadOnlySpan base64Text, out int decodedLength) /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n' (as bytes). /// public static bool IsValid(ReadOnlySpan base64TextUtf8) => - Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, 123, out _); + Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, out _); /// Validates that the specified span of UTF-8 text is comprised of valid base-64 encoded data. /// A span of UTF-8 text to validate. @@ -53,7 +53,7 @@ public static bool IsValid(ReadOnlySpan base64TextUtf8) => /// where whitespace is defined as the characters ' ', '\t', '\r', or '\n' (as bytes). /// public static bool IsValid(ReadOnlySpan base64TextUtf8, out int decodedLength) => - Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, 123, out decodedLength); + Base64Helper.IsValid(default(Base64ByteValidatable), base64TextUtf8, out decodedLength); } } From e6f5f7d9eda121dfc7386ea14b2fb3e03cfddb63 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Mon, 28 Jul 2025 17:57:51 +0200 Subject: [PATCH 7/7] whitespace --- .../System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs index 0798b31c1b2da3..c26e5b274da1d4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64ValidatorHelper.cs @@ -146,7 +146,7 @@ internal interface IBase64Validatable internal readonly struct Base64CharValidatable : IBase64Validatable { // to make structure size 4 instead of 1 as workaround for WASM AOT problem with empty structs - private readonly int dummy; + private readonly int dummy; public Base64CharValidatable() { dummy = 0; @@ -178,7 +178,7 @@ public bool ValidateAndDecodeLength(char lastChar, int length, int paddingCount, internal readonly struct Base64ByteValidatable : IBase64Validatable { // to make structure size 4 instead of 1 as workaround for WASM AOT problem with empty structs - private readonly int dummy; + private readonly int dummy; public Base64ByteValidatable() { dummy = 0;