angularsen / UnitsNet

Makes life working with units of measurement just a little bit better.
https://www.nuget.org/packages/UnitsNet/
MIT No Attribution
2.65k stars 382 forks source link

Can not set QuantityName for Custom Units #1418

Closed Chef904 closed 2 months ago

Chef904 commented 2 months ago

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

angularsen commented 2 months ago

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

angularsen commented 2 months ago

Release UnitsNet/5.58.0 · angularsen/UnitsNet