Skip to content

Commit

Permalink
🔥Remove static Default getters, obsoleted by UnitsNetSetup (#1475)
Browse files Browse the repository at this point in the history
Ref #1200 

Remove static `Default` getter property for `UnitConverter`,
`UnitAbbreviationsCache`, `QuantityParser`, `UnitParser`. These just
pointed to the singleton `UnitsNetSetup.Default` and were made obsolete
in v5.
  • Loading branch information
angularsen authored Dec 27, 2024
1 parent 104c67a commit a3c32b6
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 30 deletions.
6 changes: 0 additions & 6 deletions UnitsNet/CustomCode/QuantityParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public class QuantityParser
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;
private readonly UnitParser _unitParser;

/// <summary>
/// The default instance of <see cref="QuantityParser"/>, which uses <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitAbbreviations"/>.
/// </summary>
[Obsolete("Use UnitsNetSetup.Default.QuantityParser instead.")]
public static QuantityParser Default => UnitsNetSetup.Default.QuantityParser;

/// <summary>
/// Creates an instance of <see cref="QuantityParser"/>, optionally specifying an <see cref="UnitAbbreviationsCache"/>
/// with unit abbreviations to use when parsing.
Expand Down
6 changes: 0 additions & 6 deletions UnitsNet/CustomCode/UnitAbbreviationsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public sealed class UnitAbbreviationsCache
/// </example>
internal static readonly CultureInfo FallbackCulture = CultureInfo.InvariantCulture;

/// <summary>
/// The static instance used internally for ToString() and Parse() of quantities and units.
/// </summary>
[Obsolete("Use UnitsNetSetup.Default.UnitAbbreviations instead.")]
public static UnitAbbreviationsCache Default => UnitsNetSetup.Default.UnitAbbreviations;

private QuantityInfoLookup QuantityInfoLookup { get; }

/// <summary>
Expand Down
13 changes: 3 additions & 10 deletions UnitsNet/CustomCode/UnitParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,13 @@ namespace UnitsNet
{
/// <summary>
/// Parses units given a unit abbreviations cache.
/// The static instance <see cref="Default"/> is used internally to parse quantities and units using the
/// default abbreviations cache for all units and abbreviations defined in the library.
/// A static instance <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitParser"/> is used internally
/// to parse quantities and units using the default abbreviations cache for all units and abbreviations defined in the library.
/// </summary>
public sealed class UnitParser
{
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;

/// <summary>
/// The default static instance used internally to parse quantities and units using the
/// default abbreviations cache for all units and abbreviations defined in the library.
/// </summary>
[Obsolete("Use UnitsNetSetup.Default.UnitParser instead.")]
public static UnitParser Default => UnitsNetSetup.Default.UnitParser;

/// <summary>
/// Create a parser using the given unit abbreviations cache.
/// </summary>
Expand Down Expand Up @@ -205,7 +198,7 @@ public bool TryParse([NotNullWhen(true)] string? unitAbbreviation, Type unitType
{
return false;
}

unit = matches[0].Unit;
return true;
}
Expand Down
8 changes: 0 additions & 8 deletions UnitsNet/UnitConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Linq;
using UnitsNet.InternalHelpers;
Expand Down Expand Up @@ -35,13 +34,6 @@ public delegate TQuantity ConversionFunction<TQuantity>(TQuantity inputValue)
/// </summary>
public sealed class UnitConverter
{
/// <summary>
/// The static instance used by Units.NET to convert between units. Modify this to add/remove conversion functions at runtime, such
/// as adding your own third-party units and quantities to convert between.
/// </summary>
[Obsolete("Use UnitsNetSetup.Default.UnitConverter instead.")]
public static UnitConverter Default => UnitsNetSetup.Default.UnitConverter;

/// <summary>
/// Creates a new <see cref="UnitConverter"/> instance.
/// </summary>
Expand Down

0 comments on commit a3c32b6

Please sign in to comment.