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

Can not set QuantityName for Custom Units #1418

Closed
Chef904 opened this issue Aug 29, 2024 · 2 comments · Fixed by #1420
Closed

Can not set QuantityName for Custom Units #1418

Chef904 opened this issue Aug 29, 2024 · 2 comments · Fixed by #1420
Labels

Comments

@Chef904
Copy link

Chef904 commented Aug 29, 2024

I cannot set the QuantiyName for a custom Unit because the constructor is internal.

This is the code exampe in this repo:

public QuantityInfo QuantityInfo => new(
            nameof(HowMuch),
            typeof(HowMuchUnit),
            new UnitInfo[]
            {
                new UnitInfo<HowMuchUnit>(HowMuchUnit.Some, "Some", BaseUnits.Undefined, nameof(HowMuch)),
                new UnitInfo<HowMuchUnit>(HowMuchUnit.ATon, "Tons", BaseUnits.Undefined, nameof(HowMuch)),
                new UnitInfo<HowMuchUnit>(HowMuchUnit.AShitTon, "ShitTons", BaseUnits.Undefined, nameof(HowMuch)),
            },
            HowMuchUnit.Some,
            Zero,
            BaseDimensions.Dimensionless);

But in an other Assembly where i have my custom units, i cannot add the quantity Name to my UnitInfo:

grafik

@Chef904 Chef904 added the bug label Aug 29, 2024
angularsen added a commit that referenced this issue Aug 31, 2024
Related #1418
Port of #1420 

- Make `UnitInfo` ctor public, to accept quantity name for custom units
- Add null checks to ctors, and require quantity name in ctor that takes
one
- Mark ctor without quantity name obsolete
@angularsen
Copy link
Owner

Hi, thanks for reporting. This seems like an oversight, now fixed.

@angularsen
Copy link
Owner

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.

2 participants