Support For Getting base-64 String as Byte Array (dotnet/corefx#41467)
authorAnton Landor <55381413+AntonLandor@users.noreply.github.com>
Tue, 12 Nov 2019 22:42:27 +0000 (23:42 +0100)
committerAhson Khan <ahson_ahmedk@yahoo.com>
Tue, 12 Nov 2019 22:42:27 +0000 (14:42 -0800)
commit32d4012957a36059a3235e93560fc33f54c793ee
tree2c3238d058104b57438c42bbdf9e65d08b04b14a
parentc4a528c756ec5aa68d34b6acdbea78c8bdb4569a
Support For Getting base-64 String as Byte Array (dotnet/corefx#41467)

* Implemented support for getting Base64 as an equivalent byte array

* New implementation for base-64 support as suggested in review. Added new test cases for it.

* Changed comment

in -> and

Co-Authored-By: Ahson Khan <ahkha@microsoft.com>
* Updated minimum length for TryGetBytesFromBase64 to match minimum length of base-64 string

Co-Authored-By: Günther Foidl <gue@korporal.at>
* Added old Convert.FromBase64String implementation for older platforms. arrayReturnToPool is now cleared before return. Added test cases for edge cases and full branch coverage. Changed magic number to predefined constant.

* Changed catch-all to only catch FormatException. Removed try-finally since it is most likely unnecessary. Now only clears the sliced buffer.

* Changed back to a try-finally solution for readability.

* Using JsonConstants.StackallocThreshold instead of magic number

Co-Authored-By: Ahson Khan <ahkha@microsoft.com>
* Added test to validate TryGetBytesFromBase64(...) gives the corrresulting bytes.

* Allocate to JsonConstants.StackallocThreshold when doing stackalloc

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
Commit migrated from https://github.com/dotnet/corefx/commit/6a591b2d24869657094816418c46593337550a32
src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonElement.cs
src/libraries/System.Text.Json/src/System/Text/Json/Node/JsonString.cs
src/libraries/System.Text.Json/tests/JsonElementWithNodeParentTests.cs
src/libraries/System.Text.Json/tests/Resources/Strings.resx