Convert byte array to hex: retarget net10.0, ToHexStringLower, namespace fix - #2216
Open
vladimir-pecanac-main wants to merge 1 commit into
Conversation
…ace fix Retargets all four projects in collections-arrays/ConvertByteArrayToHex from net7.0 to net10.0 and moves the package set forward: xunit 2.9.3, xunit.runner.visualstudio 4.0.0, Microsoft.NET.Test.Sdk 18.10.1, coverlet.collector 10.0.1, BenchmarkDotNet 0.15.8. Drops the CommunityToolkit.HighPerformance reference from the benchmark project, which no source file in the folder uses. ToHexWithConvert() now calls Convert.ToHexStringLower() for the lowercase case instead of Convert.ToHexString(...).ToLowerInvariant(), which saves a second string allocation, and the lower benchmark class gains a method that measures the old path beside the new one. Fixes the namespace typo in LookupTables.cs (ConvertByteArrayHexLibrary, missing the To) and drops both stray using directives it forced, in ConversionHelpers.cs and in ConvertByteArrayLookupTablesTests.cs. Build: 0 warnings, 0 errors. Tests: 69 of 69 passing on SDK 10.0.302 / runtime 10.0.10.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Retargets
collections-arrays/ConvertByteArrayToHexto .NET 10 and fixes what the retarget exposed.Retarget and packages
net7.0->net10.0(Library,Console,Benchmark,UnitTests).AllowUnsafeBlocksstays on the library for the .NET Standard 2.0 lookup method.xunit2.4.2 -> 2.9.3,xunit.runner.visualstudio2.4.5 -> 4.0.0,Microsoft.NET.Test.Sdk17.6.0 -> 18.10.1,coverlet.collector6.0.0 -> 10.0.1,BenchmarkDotNet0.13.5 -> 0.15.8. Each version was re-queried against the NuGet flat-container index on the day this PR opened and is the newest non-prerelease entry.CommunityToolkit.HighPerformance8.2.0 from the benchmark project: no.csfile in the folder references it.Code
ConversionHelpers.ToHexWithConvert()takes the lowercase branch throughConvert.ToHexStringLower()(.NET 9 and later) instead ofConvert.ToHexString(...).ToLowerInvariant(), which removes a second string allocation.ConvertByteArrayToHexLowerBenchmarksgainsConvertToLowerHexUsingConvertAndToLowerInvariantso the old path is still measured beside the new one.LookupTables.csdeclarednamespace ConvertByteArrayHexLibrary;, missing theTo, which forced a strayusingin two files. The namespace is corrected and bothusing ConvertByteArrayHexLibrary;lines are dropped (src/ConvertByteArrayToHexLibrary/ConversionHelpers.csandtest/ConvertByteArrayToHexUnitTests/ConvertByteArrayLookupTablesTests.cs).Verification
dotnet build -c Release: 0 warnings, 0 errors.dotnet test: 69 of 69 passing. SDK 10.0.302, runtime 10.0.10. Both benchmark classes were re-run on net10.0 for the article's benchmark table.