Skip to content

UnitConverter.ConvertByAbbreviation method throws AmbitiousUnitParseException when trying to convert "psi" #484

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

Closed
YektaMirkan opened this issue Sep 25, 2018 · 9 comments

Comments

@YektaMirkan
Copy link

I use ConvertByAbbreviation to convert values. But there is a problem with "psi". It seems like both PoundForcePerSquareInch and Psi have the same abbreviation. So it throws AmbitiousUnitParseException when trying to convert from or to "psi" with this exception message: "Cannot parse 'psi' since it could be either of these: 32, 33 ".

Example:
UnitConverter.ConvertByAbbreviation(1, "Pressure", "bar", "psi");

@angularsen
Copy link
Owner

Ah, yes, this is unfortunate. We can't remove Psi or change its abbreviation as that would be a breaking change, I believe Psi is marked as Obsolete and will be removed in a major version bump. I can't immediately think of a good workaround for you, I'm afraid. We do have plans to release a minor breaking change soon to address binary size issues. We can fix this then, but I would not expect it to happen very soon as most of us struggle to find the time needed to push that version release forward.

@angularsen
Copy link
Owner

See #180 for the list of breaking changes that are wanted in a release, but we will probably address the lowest hanging fruit first just to get something out the door.

@angularsen
Copy link
Owner

If you want to help out and move the new version along faster, let me know and I'll try to picks some work items from the wishlist and draft up a target changeset for the vNext so we can have a scope that is realistic to complete in a short time.

@gojanpaolo
Copy link
Contributor

@angularsen Should we ignore obsolete units in the parsing implementation?

@angularsen
Copy link
Owner

angularsen commented Sep 26, 2018

@gojanpaolo Good idea, that could actually work with a little bit of reflection code. It would be a breaking change though, unless we only inserted that piece of logic when the ambiguous parsing exception occurs. We could also extend UnitSystem class to be able to remove abbreviations at runtime, since you can already add abbreviations at runtime.

@gojanpaolo
Copy link
Contributor

@angularsen I see. Yes, implementing remove abbreviations at runtime would be a better solution.

@YektaMirkan
Copy link
Author

@angularsen I want to help but I'm too busy nowadays. I can join you from November if you still need help.

@angularsen
Copy link
Owner

@YektaMirkan I think we will be done before November, but for your information here is the roadmap and progress: #487

@angularsen
Copy link
Owner

This is fixed in v4 branch. Psi is removed in favor of PoundForcePerSquareInch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants