diff --git a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj
index 2de051c81fbdba..caeabbd3565c07 100644
--- a/src/libraries/System.Memory/tests/System.Memory.Tests.csproj
+++ b/src/libraries/System.Memory/tests/System.Memory.Tests.csproj
@@ -4,6 +4,7 @@
true
true
$(NetCoreAppCurrent)
+ true
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..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
@@ -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
{
@@ -11,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;
@@ -139,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+/");
@@ -167,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);