dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.43k stars 4.76k forks source link

Make HexConverter class public #105398

Open megasuperlexa opened 4 months ago

megasuperlexa commented 4 months ago

Rationale: currently I have to use Convert.FromHexString method which does not support Array.Pool which creates byte[] garbage in my app' hotpath. Using HexConverter.TryDecodeFromUtf16 would allow me to use externally managed byte array.

https://github.com/dotnet/runtime/blob/5e1081f6a0c86489e7fda575735ef49ff2ca3efa/src/libraries/Common/src/System/HexConverter.cs#L18

EgorBo commented 4 months ago

1) All api proposals should use the "API Proposal" template, see api-review-process.md 2) Convert.FromHexString has overloads to accept output buffers, why don't they work for you?

vcsjones commented 4 months ago

Convert.FromHexString has overloads to accept output buffers, why don't they work for you?

The non-allocating ones are new in .NET 9. But, the point remains that starting in .NET 9, you can use Convert.FromHexString that returns an OperationStatus and can write to an existing buffer.

https://learn.microsoft.com/en-us/dotnet/api/system.convert.fromhexstring?view=net-9.0#system-convert-fromhexstring(system-readonlyspan((system-char))-system-span((system-byte))-system-int32@-system-int32@)

dotnet-policy-service[bot] commented 4 months ago

Tagging subscribers to this area: @dotnet/area-system-runtime See info in area-owners.md if you want to be subscribed.