Skip to content

Deprecate more usage of QuantityType #1019

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

Merged
merged 10 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,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."")]
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name};

/// <summary>
Expand Down Expand Up @@ -303,7 +303,8 @@ private void GenerateProperties()
/// <summary>
/// The <see cref=""QuantityType"" /> of this quantity.
/// </summary>
public QuantityType Type => {_quantity.Name}.QuantityType;
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
public QuantityType Type => QuantityType.{_quantity.Name};

/// <summary>
/// The <see cref=""BaseDimensions"" /> of this quantity.
Expand Down
4 changes: 4 additions & 0 deletions CodeGen/Generators/UnitsNetGen/QuantityTypeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public override string Generate()
Writer.WL(GeneratedFileHeader);
Writer.WL(@"
// ReSharper disable once CheckNamespace

using System;

namespace UnitsNet
{
/// <summary>
Expand All @@ -24,6 +27,7 @@ namespace UnitsNet
/// This is useful for populating options in the UI, such as creating a generic conversion
/// tool with inputValue, quantityName, fromUnit and toUnit selectors.
/// </summary>
[Obsolete(""QuantityType will be removed in the future. Use the QuantityInfo class instead."")]
public enum QuantityType
{
// Missing XML comment for public type or member
Expand Down
10 changes: 0 additions & 10 deletions CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ public static partial class Quantity
Writer.WL(@"
};

// Used by the QuantityInfo .ctor to map a name to a QuantityType. Will be removed when QuantityType
// will be removed.
internal static readonly IDictionary<string, QuantityType> QuantityTypeByName = new Dictionary<string, QuantityType>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was no longer used anywhere

{");
foreach (var quantity in _quantities)
Writer.WL($@"
{{ ""{quantity.Name}"", QuantityType.{quantity.Name} }},");
Writer.WL(@"
};

/// <summary>
/// Dynamically constructs a quantity of the given <see cref=""QuantityType""/> with the value in the quantity's base units.
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions CodeGen/Generators/UnitsNetWrcGen/QuantityGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.

using System;
Expand Down Expand Up @@ -194,6 +194,7 @@ private void GenerateStaticProperties()
/// <summary>
/// The <see cref=""QuantityType"" /> of this quantity.
/// </summary>
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name};

/// <summary>
Expand Down Expand Up @@ -235,6 +236,7 @@ private void GenerateProperties()
/// <summary>
/// The <see cref=""QuantityType"" /> of this quantity.
/// </summary>
[Obsolete(""QuantityType will be removed in the future. Use the Info property instead."")]
public QuantityType Type => {_quantity.Name}.QuantityType;

/// <summary>
Expand Down Expand Up @@ -585,7 +587,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();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching implementation to main library

}}

#endregion
Expand Down
6 changes: 5 additions & 1 deletion CodeGen/Generators/UnitsNetWrcGen/QuantityTypeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CodeGen.JsonTypes;
using CodeGen.JsonTypes;

namespace CodeGen.Generators.UnitsNetWrcGen
{
Expand All @@ -16,6 +16,9 @@ public override string Generate()
Writer.WL(GeneratedFileHeader);
Writer.WL(@"
// ReSharper disable once CheckNamespace

using System;

namespace UnitsNet
{
/// <summary>
Expand All @@ -24,6 +27,7 @@ namespace UnitsNet
/// This is useful for populating options in the UI, such as creating a generic conversion
/// tool with inputValue, quantityName, fromUnit and toUnit selectors.
/// </summary>
[Obsolete(""QuantityType will be removed in the future. Use the QuantityInfo class instead."")]
public enum QuantityType
{
Undefined = 0,");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading