Repository navigation
Keep the netstandard2.0 public API available on .NET - #1736
Open
tmilnthorp wants to merge 2 commits into
Open
tmilnthorp wants to merge 2 commits into
tmilnthorp wants to merge 2 commits into
Conversation
A library compiled against the netstandard2.0 assembly can run in an app that loads one of the .NET assemblies, where several public members were missing and calls failed with MissingMethodException: - IQuantityInfo and IQuantityInstanceInfo<TQuantity> were internal on .NET - IQuantityOfType<TQuantity>.QuantityInfo did not exist on .NET - The Temperature tolerance Equals overloads in AffineQuantityExtensions only existed on netstandard2.0 These now exist on all target frameworks. IQuantityOfType.QuantityInfo is obsolete on .NET like IQuantity.QuantityInfo, and is implemented once by IQuantity<TSelf, TUnitType>. Enable package validation to catch such differences in CI. The remaining suppressions are the static abstract members and generic math constraints, which require .NET 7 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1736 +/- ##
======================================
Coverage 98% 98%
======================================
Files 515 515
Lines 24092 24093 +1
======================================
+ Hits 23692 23693 +1
Misses 400 400
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
On .NET, calls with Temperature arguments now bind to the Temperature overloads, which left the generic overloads untested. Call them from a generic context to cover them again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG
This branch has not been deployed
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.
Part of #1735.
Summary
The netstandard2.0 assembly exposed public members that were missing from the .NET assemblies. A netstandard2.0 library calling them failed with
MissingMethodExceptionwhen used from a .NET app. This PR makes those members available on every target framework and turns on package validation so CI catches future differences.Changes
IQuantityInfoandIQuantityInstanceInfo<TQuantity>are now public on all target frameworks. They used to be internal on .NET.IQuantityOfType<TQuantity>.QuantityInfo: now exists on all target frameworks.[Obsolete]with the same message asIQuantity.QuantityInfo, pointing toTSelf.Info.IQuantity<TSelf, TUnitType>implements it once as a default interface member, so generated quantities don't change.TemperaturetoleranceEquals: the twoAffineQuantityExtensionsoverloads were netstandard2.0-only and now exist everywhere. On .NET, calls withTemperaturearguments resolve to these non-generic overloads instead of the generic ones. Both compute the same comparison.<EnablePackageValidation>true</EnablePackageValidation>inUnitsNet.csproj.CompatibilitySuppressions.xmllists the intended exceptions, with a comment explaining them: the static abstract members (Info,Create,From,Zero) and theIAdditiveIdentityconstraints. These require .NET 7+ and can't exist on netstandard2.0.Not in this PR
ILogarithmicQuantity<TSelf>.LogarithmicScalingFactoris still an instance property on netstandard2.0 and a static abstract property on .NET. Package validation doesn't flag it, because it matches members by name. Fixing it means breaking either the netstandard2.0 or the .NET API, so it needs a decision first. #1735 lists the options.Testing
IQuantityOfType<T>.QuantityInfoandTemperature.Equals(other, tolerance):MissingMethodExceptionon master, work with this PR.LogarithmicScalingFactor: still fails, as described above.dotnet packpasses. Before this change it reported 14 errors.QuantityInfo_IQuantityOfTypeReference_ReturnsQuantityInfo.UnitsNet.Testson net10.0: 52,559 passed, 2 failed. The failures areFeetInchesTests.TryParseFeetIncheswithde-CH, which fail the same way on master (see Fix feet/inches parsing with apostrophe grouping #1724).🤖 Generated with Claude Code
https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG