feat(#161): Drop netstandard2.0 target, support net8.0+ only#164
Open
leecampbell-codeagent wants to merge 7 commits intoHdrHistogram:mainfrom
Open
Conversation
5 tasks
c8cf9a6 to
f97a0dc
Compare
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.
Brief: Issue #161 — Drop netstandard2.0 target, support net8.0+ only
Summary
Remove
netstandard2.0from the main library's<TargetFrameworks>, retaining onlynet10.0;net9.0;net8.0.This eliminates all conditional compilation guards that existed solely to support the older target, simplifies
Bitwise.csto useBitOperations.LeadingZeroCountunconditionally, and cleans up a branching code path inHistogramLogReader.cs.The three per-framework Release
PropertyGroupconditions in the csproj are collapsed into a single unconditionalPropertyGroupas part of this change.The spec file
build-system.mdmust be updated to reflect the new target list.Previous NuGet releases remain available on NuGet.org for consumers on .NET Framework or older runtimes.
Category
choreThis is a maintenance and simplification task.
The hardware-intrinsic
LeadingZeroCountpath (#if NET5_0_OR_GREATER) is already compiled in for all net8.0+ builds; removing the fallback does not change the compiled output for any net8.0, net9.0, or net10.0 consumer.No performance improvement is delivered to existing net8.0+ consumers — the change reduces build artefacts, removes dead code, and simplifies the codebase.
Affected Files (confirmed by exploration)
HdrHistogram/HdrHistogram.csprojnetstandard2.0from<TargetFrameworks>(line 4); delete the netstandard2.0PropertyGroupcondition (lines 36-39); collapse the three per-framework ReleasePropertyGroupconditions (lines 24-34) into a singleCondition="'$(Configuration)' == 'Release'"blockHdrHistogram/Utilities/Bitwise.cs#if NET5_0_OR_GREATERguards (lines 25-29, 32-44); inlineIntrinsicNumberOfLeadingZerosbody directly intoNumberOfLeadingZeros; delete the entireBitwise.Imperativeclass (lines 55-109)HdrHistogram/HistogramLogReader.cs#if NETSTANDARD2_0block inIsComment()(lines 241-248); keep thecharoverload unconditionallyspec/tech-standards/build-system.mdnetstandard2.0from the TargetFrameworks code block (line 25) and from the target table (line 33)HdrHistogram.Benchmarking/LeadingZeroCount/LeadingZeroCountBenchmarkBase.csImperativeImplementationbenchmark method (references deletedBitwise.Imperativeclass)No other files in the codebase contain
#if NETSTANDARDor#if NET5_0_OR_GREATERblocks.Unit-test and benchmarking projects already target
net10.0;net9.0;net8.0only — no changes needed there.Acceptance Criteria
net10.0;net9.0;net8.0only;netstandard2.0is absent fromHdrHistogram.csproj#if NETSTANDARDor#if NET5_0_OR_GREATERconditional compilation remains anywhere in the libraryBitwise.Imperativeclass is fully removedBitwise.NumberOfLeadingZeroscallsSystem.Numerics.BitOperations.LeadingZeroCountunconditionallyHistogramLogReader.IsCommentusesline.StartsWith('#')(char overload) unconditionallyPropertyGroupconditions are collapsed into a singleCondition="'$(Configuration)' == 'Release'"blockLeadingZeroCountBenchmarkBase.csno longer referencesBitwise.Imperative; the benchmarking project compiles cleanlyspec/tech-standards/build-system.mdno longer referencesnetstandard2.0Test Strategy
Existing tests
No unit tests directly target
BitwiseorHistogramLogReader.IsCommentin isolation.The existing suite exercises both paths indirectly via histogram recording and log-reading tests.
Run the full unit-test suite across all three target frameworks after the changes:
All tests must pass; no new test failures are acceptable.
New tests (optional but recommended)
Consider adding a focused unit test in
HdrHistogram.UnitTests/that assertsBitwise.NumberOfLeadingZerosreturns correct values for a range of inputs (including 0, 1, powers-of-two, andlong.MaxValue).This is low-risk but provides a regression anchor if
Bitwise.csis touched again.There is no need to add tests for
IsComment— it is a private static helper with trivial logic.Risks and Open Questions
Benchmark class references
Bitwise.Imperative— deleting the class will break theImperativeImplementationbenchmark at compile time.The benchmark must be updated in the same PR (listed in Affected Files above).
NuGet package surface — removing a target framework is a breaking change for consumers on netstandard2.0.
This is explicitly accepted: "Previous NuGet releases will remain available."
The PR description should note this prominently and suggest a major-version bump or release notes entry.
No other conditional compilation found — the grep over the codebase confirmed only two files contain the relevant
#ifblocks.Low risk of missing anything.
Task breakdown
Task List: Issue #161 — Drop netstandard2.0 target, support net8.0+ only
Implementation Changes
HdrHistogram/HdrHistogram.csprojline 4 — Removenetstandard2.0from<TargetFrameworks>, leavingnet10.0;net9.0;net8.0.<TargetFrameworks>value contains nonetstandard2.0token.HdrHistogram/HdrHistogram.csprojlines 24–34 — Collapse the three per-framework ReleasePropertyGroupblocks (one each fornet8.0,net9.0,net10.0) into a singlePropertyGroup Condition="'$(Configuration)' == 'Release'"block with a single<DocumentationFile>element that resolves via$(TargetFramework).PropertyGroupexists; it contains no$(TargetFramework)literals in the condition string.HdrHistogram/HdrHistogram.csprojlines 36–39 — Delete thenetstandard2.0PropertyGroupblock (the one settingDefineConstantstoRELEASE;NETSTANDARD2_0).NETSTANDARD2_0is no longer needed once the target is removed.PropertyGroupreferencingnetstandard2.0orNETSTANDARD2_0remains in the file.HdrHistogram/Utilities/Bitwise.cslines 23–44 — SimplifyNumberOfLeadingZeros(long)to callSystem.Numerics.BitOperations.LeadingZeroCount((ulong)value)directly; remove the#if NET5_0_OR_GREATER/#else/#endifguards and delete the privateIntrinsicNumberOfLeadingZeroshelper.BitOperations.LeadingZeroCount; the conditional dispatch is dead code.NumberOfLeadingZerosbody is a singlereturn System.Numerics.BitOperations.LeadingZeroCount((ulong)value);statement; no#ifdirectives remain in the method or immediately around it.HdrHistogram/Utilities/Bitwise.cslines 55–109 — Delete the entireBitwise.Imperativenested public static class (including theLookuptable,NumberOfLeadingZeros,NumberOfLeadingZerosLong, andLog2methods).class ImperativeorBitwise.Imperativeidentifier exists anywhere in the solution.HdrHistogram/HistogramLogReader.cslines 241–248 — Remove the#if NETSTANDARD2_0/#else/#endifblock insideIsComment(string line), keeping onlyreturn line.StartsWith('#');.charoverload ofStartsWithis available on all net8.0+ targets; the string-overload fallback is dead code.IsCommentcontains no#ifdirectives; the method body isreturn line.StartsWith('#');.HdrHistogram.Benchmarking/LeadingZeroCount/LeadingZeroCountBenchmarkBase.cs— Remove the"Imperative"entry from the validation dictionary (line 56) and delete theImperativeImplementation()benchmark method (lines 124–133).Bitwise.Imperativewhich will no longer exist; leaving them causes a compile error.dotnet build HdrHistogram.Benchmarking/ -c Releaseexits with code 0; no reference toBitwise.Imperativeremains in the file.Unit Tests
HdrHistogram.UnitTests/— Add a focused unit test classBitwiseTests(e.g.HdrHistogram.UnitTests/Utilities/BitwiseTests.cs) that assertsBitwise.NumberOfLeadingZerosreturns correct results for representative inputs:0,1,2, powers of two up to 2⁶², andlong.MaxValue.Bitwise; this provides a regression anchor if the method is ever touched again.dotnet test -c Releasereports the new tests as passing on all three target frameworks.Run the full unit-test suite — Execute
dotnet test -c Releaseacross all three target frameworks (net8.0, net9.0, net10.0).BitwiseorHistogramLogReader.Documentation
spec/tech-standards/build-system.mdline 25 — Removenetstandard2.0from the<TargetFrameworks>code block example.net10.0;net9.0;net8.0.spec/tech-standards/build-system.mdline 33 — Delete the| \netstandard2.0` | Broad compatibility (.NET Framework 4.6.1+, .NET Core 2.0+) |` row from the target table.netstandard2.0remains anywhere inbuild-system.md.Acceptance Criteria Cross-Reference
net10.0;net9.0;net8.0only;netstandard2.0absent from.csproj#if NETSTANDARDor#if NET5_0_OR_GREATERconditional compilation in libraryBitwise.Imperativeclass fully removedBitwise.NumberOfLeadingZeroscallsBitOperations.LeadingZeroCountunconditionallyHistogramLogReader.IsCommentusesline.StartsWith('#')unconditionallyPropertyGroupconditions collapsed into oneLeadingZeroCountBenchmarkBase.csno longer referencesBitwise.Imperative; benchmarking project compilesspec/tech-standards/build-system.mdno longer referencesnetstandard2.0Closes #161