Skip to content

Fix overridden abbrev#833

Closed
tmilnthorp wants to merge 4 commits into
angularsen:masterfrom
tmilnthorp:FixOverriddenAbbrev
Closed

Fix overridden abbrev#833
tmilnthorp wants to merge 4 commits into
angularsen:masterfrom
tmilnthorp:FixOverriddenAbbrev

Conversation

@tmilnthorp
Copy link
Copy Markdown
Collaborator

@tmilnthorp tmilnthorp commented Sep 8, 2020

Fixes #832

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 8, 2020

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80%. Comparing base (ce7cc46) to head (5be4cf7).
⚠️ Report is 834 commits behind head on master.

Files with missing lines Patch % Lines
UnitsNet/CustomCode/UnitAbbreviationsCache.cs 94% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master    #833   +/-   ##
======================================
  Coverage      80%     80%           
======================================
  Files         281     281           
  Lines       41925   41936   +11     
======================================
+ Hits        33770   33783   +13     
+ Misses       8155    8153    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread UnitsNet.Tests/UnitAbbreviationsCacheTests.cs Outdated
abbreviations.UnionWith(lookup!.GetAbbreviationsForUnit(unitValue));

if(formatProvider != FallbackCulture)
abbreviations.UnionWith(GetUnitAbbreviations(unitType, unitValue, FallbackCulture));
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
@angularsen angularsen closed this May 2, 2026
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