Place static elements before non-static elements
MODIFY
WalletWasabi/Models/Height.cs
WalletWasabi/Models/Height.cs
@@ -60,13 +60,6 @@ namespace WalletWasabi.Models
: int.MaxValue;
}
- public HeightType Type { get; }
-
- /// <summary>
- /// Gets the height value according to the Height type.
- /// </summary>
- public int Value { get; }
-
/// <summary>
/// Gets a new Height instance for mempool
/// </summary>
@@ -77,6 +70,13 @@ namespace WalletWasabi.Models
/// </summary>
public static Height Unknown { get; } = new Height(HeightType.Unknown);
+ public HeightType Type { get; }
+
+ /// <summary>
+ /// Gets the height value according to the Height type.
+ /// </summary>
+ public int Value { get; }
+
/// <param name="heightOrHeightType">The height numerical value as its string representation
/// or well the strings "Mempool" or "Unknown" for the default initial height of those Heights.
/// </param>
@@ -130,27 +130,51 @@ namespace WalletWasabi.Models
/// <param name="height">Height value to convert to Int32.</param>
public static implicit operator int(Height height) => height.Value;
- /// <inheritdoc/>
- public override string ToString()
- {
- if (Type == HeightType.Chain)
- {
- return Value.ToString();
- }
+ #region MathOperations
- return Type.ToString();
- }
+ /// <summary>
+ /// Increments the height value by 1
+ /// </summary>
+ /// <param name="me">The instance to be used as base value.</param>
+ public static Height operator ++(Height me) => new Height(me.Value + 1);
- #region EqualityAndComparison
+ /// <summary>
+ /// Decrements the height value by 1
+ /// </summary>
+ /// <param name="me">The instance to be used as base value.</param>
+ public static Height operator --(Height me) => new Height(me.Value - 1);
- /// <inheritdoc/>
- public override bool Equals(object obj) => obj is Height height && this == height;
+ /// <summary>
+ /// Unary or binary operator for adding a value to height.
+ /// </summary>
+ /// <param name="value">The Int32 value.</param>
+ /// <param name="height">The height value to be added.</param>
+ public static int operator +(int value, Height height) => height.Value + value;
- /// <inheritdoc/>
- public bool Equals(Height other) => this == other;
+ /// <summary>
+ /// Unary or binary operator for substracting a value to height.
+ /// </summary>
+ /// <param name="value">The Int32 value.</param>
+ /// <param name="height">The height value to be substracted from.</param>
+ public static int operator -(int value, Height height) => value - height.Value;
- /// <inheritdoc/>
- public override int GetHashCode() => Value.GetHashCode();
+ /// <summary>
+ /// Unary or binary operator for adding a value to height.
+ /// </summary>
+ /// <param name="height">The height value to be added.</param>
+ /// <param name="value">The Int32 value.</param>
+ public static int operator +(Height height, int value) => height.Value + value;
+
+ /// <summary>
+ /// Unary or binary operator for substracting a value to height.
+ /// </summary>
+ /// <param name="height">The height value to be substracted from.</param>
+ /// <param name="value">The Int32 value.</param>
+ public static int operator -(Height height, int value) => height.Value - value;
+
+ #endregion MathOperations
+
+ #region EqualityAndComparison
/// <summary>
/// Performs a comparison and return if side are equal
@@ -168,13 +192,6 @@ namespace WalletWasabi.Models
/// <returns>true if lhs and rhs are not equal; otherwise false.</returns>
public static bool operator !=(Height x, Height y) => !(x == y);
- /// <summary>
- /// Performs a comparison and return if side are equal
- /// </summary>
- /// <param name="other">The value to compare.</param>
- /// <returns>true if this and other are equal; otherwise false.</returns>
- public bool Equals(int other) => Value == other;
-
/// <summary>
/// Performs a comparison and return if side are equal
/// </summary>
@@ -207,23 +224,6 @@ namespace WalletWasabi.Models
/// <returns>true if this and other are not equal; otherwise false.</returns>
public static bool operator !=(Height x, int y) => !(x == y);
- /// <summary>
- /// Performs a comparison and return if compared values are equal, greater or less than the other one
- /// </summary>
- /// <param name="other">The height value to compare against.</param>
- /// <returns>0 if this an other are equal, -1 if this is less than other and 1 if this is greater than other.</returns>
- public int CompareTo(Height other) => Value.CompareTo(other.Value);
-
- /// <summary>
- /// Performs a comparison and return if compared values are equal, greater or less than the other one
- /// </summary>
- /// <param name="other">The Int32 height value to compare against.</param>
- /// <returns>0 if this an other are equal, -1 if this is less than other and 1 if this is greater than other.</returns>
- public int CompareTo(int other)
- {
- return Value.CompareTo(other);
- }
-
/// <summary>
/// Performs a comparison and return if left-side value is greater than right-side value.
/// </summary>
@@ -320,50 +320,50 @@ namespace WalletWasabi.Models
/// <returns>true if left-hand value is less than or equal to right-side value; otherwise false.</returns>
public static bool operator <=(Height x, int y) => x.Value <= y;
- #endregion EqualityAndComparison
+ /// <inheritdoc/>
+ public override bool Equals(object obj) => obj is Height height && this == height;
- #region MathOperations
+ /// <inheritdoc/>
+ public bool Equals(Height other) => this == other;
- /// <summary>
- /// Increments the height value by 1
- /// </summary>
- /// <param name="me">The instance to be used as base value.</param>
- public static Height operator ++(Height me) => new Height(me.Value + 1);
+ /// <inheritdoc/>
+ public override int GetHashCode() => Value.GetHashCode();
/// <summary>
- /// Decrements the height value by 1
+ /// Performs a comparison and return if side are equal
/// </summary>
- /// <param name="me">The instance to be used as base value.</param>
- public static Height operator --(Height me) => new Height(me.Value - 1);
+ /// <param name="other">The value to compare.</param>
+ /// <returns>true if this and other are equal; otherwise false.</returns>
+ public bool Equals(int other) => Value == other;
/// <summary>
- /// Unary or binary operator for adding a value to height.
+ /// Performs a comparison and return if compared values are equal, greater or less than the other one
/// </summary>
- /// <param name="value">The Int32 value.</param>
- /// <param name="height">The height value to be added.</param>
- public static int operator +(int value, Height height) => height.Value + value;
+ /// <param name="other">The height value to compare against.</param>
+ /// <returns>0 if this an other are equal, -1 if this is less than other and 1 if this is greater than other.</returns>
+ public int CompareTo(Height other) => Value.CompareTo(other.Value);
/// <summary>
- /// Unary or binary operator for substracting a value to height.
+ /// Performs a comparison and return if compared values are equal, greater or less than the other one
/// </summary>
- /// <param name="value">The Int32 value.</param>
- /// <param name="height">The height value to be substracted from.</param>
- public static int operator -(int value, Height height) => value - height.Value;
+ /// <param name="other">The Int32 height value to compare against.</param>
+ /// <returns>0 if this an other are equal, -1 if this is less than other and 1 if this is greater than other.</returns>
+ public int CompareTo(int other)
+ {
+ return Value.CompareTo(other);
+ }
- /// <summary>
- /// Unary or binary operator for adding a value to height.
- /// </summary>
- /// <param name="height">The height value to be added.</param>
- /// <param name="value">The Int32 value.</param>
- public static int operator +(Height height, int value) => height.Value + value;
+ #endregion EqualityAndComparison
- /// <summary>
- /// Unary or binary operator for substracting a value to height.
- /// </summary>
- /// <param name="height">The height value to be substracted from.</param>
- /// <param name="value">The Int32 value.</param>
- public static int operator -(Height height, int value) => height.Value - value;
+ /// <inheritdoc/>
+ public override string ToString()
+ {
+ if (Type == HeightType.Chain)
+ {
+ return Value.ToString();
+ }
- #endregion MathOperations
+ return Type.ToString();
+ }
}
}

Place static elements before non-static elements