Add Base64.IsValid and allow Base64.DecodeXx methods to skip whitespace (#85938)
authorStephen Toub <stoub@microsoft.com>
Tue, 9 May 2023 12:32:08 +0000 (08:32 -0400)
committerGitHub <noreply@github.com>
Tue, 9 May 2023 12:32:08 +0000 (08:32 -0400)
commitb2d730cc26f2f06909609692d6598555a2b372f6
tree903b6338721697514e4c68fdf9d852dd51a02ea9
parent5b90c47e8a1093ec86f31ad8d579948d5bdc1f42
Add Base64.IsValid and allow Base64.DecodeXx methods to skip whitespace (#85938)

* Allow Base64Decoder to ignore space chars, add IsValid methods and tests

* Some cleanup of Base64.IsValid changes

This includes making FromBase64Transform significantly faster via SearchValues.

* Address PR feedback and some more cleanup

---------

Co-authored-by: Heath Baron-Morgan <heathbm@outlook.com>
src/libraries/System.Memory/tests/Base64/Base64DecoderUnitTests.cs
src/libraries/System.Memory/tests/Base64/Base64TestBase.cs [new file with mode: 0644]
src/libraries/System.Memory/tests/Base64/Base64TestHelper.cs
src/libraries/System.Memory/tests/Base64/Base64ValidationUnitTests.cs [new file with mode: 0644]
src/libraries/System.Memory/tests/System.Memory.Tests.csproj
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Decoder.cs
src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Encoder.cs
src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Validator.cs [new file with mode: 0644]
src/libraries/System.Runtime/ref/System.Runtime.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Base64Transforms.cs