Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overridden abbrev #833

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tmilnthorp
Copy link
Collaborator

@tmilnthorp tmilnthorp commented Sep 8, 2020

Fixes #832

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2020

Codecov Report

Merging #833 into master will increase coverage by 0.00%.
The diff coverage is 96.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #833   +/-   ##
=======================================
  Coverage   80.54%   80.55%           
=======================================
  Files         281      281           
  Lines       41925    41936   +11     
=======================================
+ Hits        33770    33783   +13     
+ Misses       8155     8153    -2     
Impacted Files Coverage Δ
UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs 100.00% <ø> (ø)
UnitsNet/CustomCode/UnitAbbreviationsCache.cs 86.40% <94.73%> (+1.85%) ⬆️
UnitsNet/CustomCode/UnitParser.cs 88.23% <100.00%> (+1.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce7cc46...5be4cf7. Read the comment docs.

UnitsNet.Tests/UnitAbbreviationsCacheTests.cs Outdated Show resolved Hide resolved
abbreviations.UnionWith(lookup!.GetAbbreviationsForUnit(unitValue));

if(formatProvider != FallbackCulture)
abbreviations.UnionWith(GetUnitAbbreviations(unitType, unitValue, FallbackCulture));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance, I'm not sure about this union.

If you call GetUnitAbbreviations(typeof(LengthUnit), 1, russianCulture) then from this public method signature, isn't it unexpected to also receive English abbreviations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good question :) Should it? Currently you can get English abbreviations from GetUnitAbbreviations, but only if no Russian ones exist.

The parser obviously will not fall back without it. It's either that, or the parser logic will need to include the fallback logic. I wanted to keep everything contained.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure. How about adding a new parameter bool includeFallbackCulture = false and call it with true from our own usages where we need to?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should not do a union here indiscriminately. What do you think of my proposal of a new argument?

@stale
Copy link

stale bot commented Nov 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added wontfix and removed wontfix labels Nov 8, 2020
@stale
Copy link

stale bot commented Jan 14, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 14, 2021
@angularsen angularsen added pinned Issues that should not be auto-closed due to inactivity. and removed wontfix labels Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned Issues that should not be auto-closed due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overrides of unit abbreviations in non-default cultures causes Quantity.Parse to fail
3 participants