Skip to content
Closed

testing #118048

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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TestRuntime>true</TestRuntime>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<XunitShowProgress>true</XunitShowProgress>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -11,6 +12,8 @@ internal static bool IsValid<T, TBase64Validatable>(TBase64Validatable validatab
where TBase64Validatable : IBase64Validatable<T>
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;

Expand Down Expand Up @@ -139,9 +142,16 @@ internal interface IBase64Validatable<T>
bool IsEncodingPad(T value);
bool ValidateAndDecodeLength(T lastChar, int length, int paddingCount, out int decodedLength);
}

#pragma warning disable CS0414
internal readonly struct Base64CharValidatable : IBase64Validatable<char>
{
// 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<char> s_validBase64Chars = SearchValues.Create("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");

Expand All @@ -167,6 +177,13 @@ public bool ValidateAndDecodeLength(char lastChar, int length, int paddingCount,

internal readonly struct Base64ByteValidatable : IBase64Validatable<byte>
{
// 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<byte> s_validBase64Chars = SearchValues.Create(default(Base64EncoderByte).EncodingMap);

Expand Down
Loading