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

[Support] Parsing PJ #1142

Closed
akasolace opened this issue Oct 14, 2022 · 6 comments · Fixed by #1143
Closed

[Support] Parsing PJ #1142

akasolace opened this issue Oct 14, 2022 · 6 comments · Fixed by #1143
Labels

Comments

@akasolace
Copy link
Contributor

First of all, thank you for making this library open-source.

In my energy conversion app, I am using the function Energy.TryParseUnit().

I had already encountered not recognized abbreviations that I could fix using MapUnitToDefaultAbbreviation, for example:

UnitAbbreviationsCache.Default.MapUnitToDefaultAbbreviation(VolumeUnit.CubicKilometer, "bcm");

But now I have encountered unit PetaJoule "PJ" and the parsing is throwing an error. I have tried something like the following but it does not work
UnitAbbreviationsCache.Default.MapUnitToDefaultAbbreviation(new Energy(1000, EnergyUnit.Gigajoule), "joule");

Any help would be welcome.

Thank you

@akasolace akasolace added the bug label Oct 14, 2022
@Brunni
Copy link
Contributor

Brunni commented Oct 25, 2022

Hi. As far as I can see, Petajoule is currently not available as EnergyUnit, right?

https://github.com/angularsen/UnitsNet/blob/master/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs

So I guess we would need to create a PR to add PJ.

Of course, the question is then about TeraJoule, ExaJoule etc. https://en.wikipedia.org/wiki/Orders_of_magnitude_(energy)

@akasolace
Copy link
Contributor Author

akasolace commented Oct 25, 2022

@Brunni I think I have a PR ready (#1143). However, I could not run the test because the project cannot build despite having installed .NET 5.0. (VS Studio is asking me to install many other framework like 4.0, 4.7.2, to build the project) I am using visual studio 2022 preview are you aware of any issue regarding using the outdated framework with the latest VS studio?

image

@angularsen
Copy link
Owner

angularsen commented Oct 31, 2022

@akasolace Try removing net40;net47 temporarily from UnitsNet.csproj and any other projects, if you don't have these frameworks installed.

    <TargetFrameworks>netstandard2.0;net40;net47</TargetFrameworks>

In v5 #982 , we drop support for the older .NET frameworks.

Remove targets: net40, net47, Windows Runtime Component.

@akasolace
Copy link
Contributor Author

@angularsen indeed removing net4.0 allowed me to build and run the test that were all successful.
I removed the draft status to my PR #1143 , but it does not pass the CI (see https://ci.appveyor.com/project/angularsen/unitsnet/builds/45180101). Please let me know what I should do next to finalize this PR .... thank you

@angularsen
Copy link
Owner

I'm not sure what wrong exactly, but master branch built just fine now and also we have recently switched to Azure DevOps: https://dev.azure.com/unitsnet/Units.NET

@angularsen
Copy link
Owner

v5 was merged into master, so net40 and net47 targets are no longer present.

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

Successfully merging a pull request may close this issue.

3 participants