- Notifications
You must be signed in to change notification settings - Fork 416
Deprecate QuantityType to better support custom quantities#864
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2474ec1cd40484739679664bc2a57d980c05f50e1fd1001011f3ae127d82bc9878d8a229002c5f6f7547daa7528c4989f2eb2f1e1File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -117,7 +117,7 @@ private void GenerateStaticConstructor() | ||
| "); | ||
| Writer.WL($@" | ||
| Info = new QuantityInfo<{_unitEnumName}>(QuantityType.{_quantity.Name}, | ||
| Info = new QuantityInfo<{_unitEnumName}>(""{_quantity.Name}"", | ||
| new UnitInfo<{_unitEnumName}>[] {{"); | ||
| foreach (var unit in _quantity.Units) | ||
| @@ -147,10 +147,10 @@ private void GenerateStaticConstructor() | ||
| } | ||
| } | ||
| Writer.WL(@" | ||
| }, | ||
| BaseUnit, Zero, BaseDimensions); | ||
| } | ||
| Writer.WL($@" | ||
| }}, | ||
| BaseUnit, Zero, BaseDimensions, QuantityType.{_quantity.Name}); | ||
| }} | ||
| "); | ||
| } | ||
| @@ -236,6 +236,7 @@ private void GenerateStaticProperties() | ||
| /// <summary> | ||
| /// The <see cref=""QuantityType"" /> of this quantity. | ||
| /// </summary> | ||
| [Obsolete(""QuantityType will be removed in the future. Use Info property instead."")] | ||
| public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name}; | ||
| /// <summary> | ||
| @@ -792,7 +793,7 @@ public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comp | ||
| /// <returns>A hash code for the current {_quantity.Name}.</returns> | ||
| public override int GetHashCode() | ||
| {{ | ||
| return new {{ QuantityType, Value, Unit }}.GetHashCode(); | ||
| return new {{ Info.Name, Value, Unit }}.GetHashCode(); | ||
| }} | ||
| #endregion | ||
| @@ -1106,6 +1107,8 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) | ||
| return Unit; | ||
| else if(conversionType == typeof(QuantityType)) | ||
| return {_quantity.Name}.QuantityType; | ||
| else if(conversionType == typeof(QuantityInfo)) | ||
angularsen marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return {_quantity.Name}.Info; | ||
| else if(conversionType == typeof(BaseDimensions)) | ||
| return {_quantity.Name}.BaseDimensions; | ||
| else | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using CodeGen.JsonTypes; | ||
| using CodeGen.JsonTypes; | ||
| namespace CodeGen.Generators.UnitsNetGen | ||
| { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using CodeGen.Helpers; | ||
| using CodeGen.Helpers; | ||
| using CodeGen.JsonTypes; | ||
| namespace CodeGen.Generators.UnitsNetWrcGen | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| using System; | ||
| using System; | ||
| namespace UnitsNet.Tests.CustomQuantities | ||
| { | ||
| @@ -26,7 +26,7 @@ public HowMuch(double value, HowMuchUnit unit) | ||
| public QuantityType Type => QuantityType.Undefined; | ||
| public BaseDimensions Dimensions => BaseDimensions.Dimensionless; | ||
| public QuantityInfo QuantityInfo => new QuantityInfo(Type, | ||
| public QuantityInfo QuantityInfo => new QuantityInfo("HowMuch", | ||
generateui marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| new UnitInfo[] | ||
| { | ||
| new UnitInfo<HowMuchUnit>(HowMuchUnit.Some, BaseUnits.Undefined), | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.