Add scoped UnitInfo overloads to UnitAbbreviationsCache#1651
Conversation
Added UnitInfo overload of MapUnitToAbbreviation, MapUnitToDefaultAbbreviation, GetDefaultAbbreviation and GetUnitAbbreviations
Code ReviewSummaryAdds XML doc typo — double
|
Code ReviewOverview: Adds ✅ What's good
🐛 Minor issues1. Double /// <inheritdoc cref="MapUnitToAbbreviation{TUnitType}(TUnitType,IEnumerable{string})"/>>
// ^^^This is valid XML but looks like a typo; the extra 2. Missing blank line before 3. Null handling — The 4. XML doc for OverallGood API addition that reduces unnecessary lookups. Fix the minor issues and this is ready. |
Code ReviewOverviewAdds Code QualityThe refactoring is clean. Routing Minor Issues
TestsNo tests are added. The refactoring is low-risk since behavior is preserved, but a test confirming the SummaryGood API addition. Fix the double- |
Code ReviewAdding Looks good
Issues
No functional concerns — just polish needed on the doc comments. |
Code ReviewOverviewAdds The motivation is reasonable — callers who already have a IssuesTypo in XML doc comments — both new /// <inheritdoc cref="MapUnitToAbbreviation{TUnitType}(TUnitType,IEnumerable{string})"/>>The trailing No tests — the new Missing blank line — between the closing brace of Behavior change for SummaryThe API direction is sound. Please fix the XML doc typos, add tests, and reconsider whether the |
PR Review: Unit abbreviations cache unit info overloadOverview: Adds Positive
IssuesDouble /// <inheritdoc cref="MapUnitToAbbreviation{TUnitType}(TUnitType,IEnumerable{string})"/>>The trailing Missing blank line before public IReadOnlyList<string> GetUnitAbbreviations(UnitKey unitKey, IFormatProvider? formatProvider = null)
{
return GetUnitAbbreviations(Quantities.GetUnitInfo(unitKey), formatProvider);
}
/// <summary> ← no blank line here
/// Retrieves the unit abbreviations...All other method pairs in this file have a blank line between them.
/// <inheritdoc cref="GetUnitAbbreviations(UnitKey, IFormatProvider)"/>
/// <param name="unitInfo">The info representing the unit.</param>
/// <param name="formatProvider">...</param>Overall: The refactoring is sound and the API addition is useful. Please fix the doc comment typos and the missing blank line before merging. |
Summary
Adds
UnitInfoconvenience overloads toUnitAbbreviationsCachefor the same method groups that already acceptUnitKey:GetDefaultAbbreviation(UnitInfo, ...)GetUnitAbbreviations(UnitInfo, ...)MapUnitToAbbreviation(UnitInfo, ...)MapUnitToDefaultAbbreviation(UnitInfo, ...)This avoids caller-side
unitInfo.UnitKeyextraction when the caller already has aUnitInfo, while keeping the existingUnitKey, typed enum, and(Type, int)overloads.Maintainer Updates
ArgumentNullException(nameof(unitInfo))handling for the new public overloads.UnitInfo.UnitKeythrough the cache'sQuantityInfoLookupbefore reading or mapping abbreviations.UnitInfoinputs.UnitInfovalues outside that set.Validation
dotnet test UnitsNet.Tests --filter "FullyQualifiedName~UnitAbbreviationsCacheTests" --no-restore --verbosity minimal.