Skip to content

Commit f3d3b8c

Browse files
authored
Deprecate more usage of QuantityType (#1019)
1 parent 7f67ffb commit f3d3b8c

File tree

234 files changed

+707
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+707
-479
lines changed

CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ private void GenerateStaticProperties()
249249
/// <summary>
250250
/// The <see cref=""QuantityType"" /> of this quantity.
251251
/// </summary>
252-
[Obsolete(""QuantityType will be removed in the future. Use Info property instead."")]
252+
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
253253
public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name};
254254
255255
/// <summary>
@@ -303,7 +303,8 @@ private void GenerateProperties()
303303
/// <summary>
304304
/// The <see cref=""QuantityType"" /> of this quantity.
305305
/// </summary>
306-
public QuantityType Type => {_quantity.Name}.QuantityType;
306+
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
307+
public QuantityType Type => QuantityType.{_quantity.Name};
307308
308309
/// <summary>
309310
/// The <see cref=""BaseDimensions"" /> of this quantity.

CodeGen/Generators/UnitsNetGen/QuantityTypeGenerator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public override string Generate()
1616
Writer.WL(GeneratedFileHeader);
1717
Writer.WL(@"
1818
// ReSharper disable once CheckNamespace
19+
20+
using System;
21+
1922
namespace UnitsNet
2023
{
2124
/// <summary>
@@ -24,6 +27,7 @@ namespace UnitsNet
2427
/// This is useful for populating options in the UI, such as creating a generic conversion
2528
/// tool with inputValue, quantityName, fromUnit and toUnit selectors.
2629
/// </summary>
30+
[Obsolete(""QuantityType will be removed in the future. Use the QuantityInfo class instead."")]
2731
public enum QuantityType
2832
{
2933
// Missing XML comment for public type or member

CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ public static partial class Quantity
4343
Writer.WL(@"
4444
};
4545
46-
// Used by the QuantityInfo .ctor to map a name to a QuantityType. Will be removed when QuantityType
47-
// will be removed.
48-
internal static readonly IDictionary<string, QuantityType> QuantityTypeByName = new Dictionary<string, QuantityType>
49-
{");
50-
foreach (var quantity in _quantities)
51-
Writer.WL($@"
52-
{{ ""{quantity.Name}"", QuantityType.{quantity.Name} }},");
53-
Writer.WL(@"
54-
};
55-
5646
/// <summary>
5747
/// Dynamically constructs a quantity of the given <see cref=""QuantityType""/> with the value in the quantity's base units.
5848
/// </summary>

CodeGen/Generators/UnitsNetWrcGen/QuantityGenerator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed under MIT No Attribution, see LICENSE file at the root.
1+
// Licensed under MIT No Attribution, see LICENSE file at the root.
22
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
33

44
using System;
@@ -194,6 +194,7 @@ private void GenerateStaticProperties()
194194
/// <summary>
195195
/// The <see cref=""QuantityType"" /> of this quantity.
196196
/// </summary>
197+
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
197198
public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name};
198199
199200
/// <summary>
@@ -235,6 +236,7 @@ private void GenerateProperties()
235236
/// <summary>
236237
/// The <see cref=""QuantityType"" /> of this quantity.
237238
/// </summary>
239+
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
238240
public QuantityType Type => {_quantity.Name}.QuantityType;
239241
240242
/// <summary>
@@ -585,7 +587,7 @@ public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comp
585587
/// <returns>A hash code for the current {_quantity.Name}.</returns>
586588
public override int GetHashCode()
587589
{{
588-
return new {{ QuantityType, Value, Unit }}.GetHashCode();
590+
return new {{ Info.Name, Value, Unit }}.GetHashCode();
589591
}}
590592
591593
#endregion

CodeGen/Generators/UnitsNetWrcGen/QuantityTypeGenerator.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CodeGen.JsonTypes;
1+
using CodeGen.JsonTypes;
22

33
namespace CodeGen.Generators.UnitsNetWrcGen
44
{
@@ -16,6 +16,9 @@ public override string Generate()
1616
Writer.WL(GeneratedFileHeader);
1717
Writer.WL(@"
1818
// ReSharper disable once CheckNamespace
19+
20+
using System;
21+
1922
namespace UnitsNet
2023
{
2124
/// <summary>
@@ -24,6 +27,7 @@ namespace UnitsNet
2427
/// This is useful for populating options in the UI, such as creating a generic conversion
2528
/// tool with inputValue, quantityName, fromUnit and toUnit selectors.
2629
/// </summary>
30+
[Obsolete(""QuantityType will be removed in the future. Use the QuantityInfo class instead."")]
2731
public enum QuantityType
2832
{
2933
Undefined = 0,");

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)