Skip to content

Commit a3c32b6

Browse files
authored
🔥Remove static Default getters, obsoleted by UnitsNetSetup (#1475)
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.
1 parent 104c67a commit a3c32b6

File tree

4 files changed

+3
-30
lines changed

4 files changed

+3
-30
lines changed

Diff for: UnitsNet/CustomCode/QuantityParser.cs

-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ public class QuantityParser
3434
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;
3535
private readonly UnitParser _unitParser;
3636

37-
/// <summary>
38-
/// The default instance of <see cref="QuantityParser"/>, which uses <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitAbbreviations"/>.
39-
/// </summary>
40-
[Obsolete("Use UnitsNetSetup.Default.QuantityParser instead.")]
41-
public static QuantityParser Default => UnitsNetSetup.Default.QuantityParser;
42-
4337
/// <summary>
4438
/// Creates an instance of <see cref="QuantityParser"/>, optionally specifying an <see cref="UnitAbbreviationsCache"/>
4539
/// with unit abbreviations to use when parsing.

Diff for: UnitsNet/CustomCode/UnitAbbreviationsCache.cs

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ public sealed class UnitAbbreviationsCache
3131
/// </example>
3232
internal static readonly CultureInfo FallbackCulture = CultureInfo.InvariantCulture;
3333

34-
/// <summary>
35-
/// The static instance used internally for ToString() and Parse() of quantities and units.
36-
/// </summary>
37-
[Obsolete("Use UnitsNetSetup.Default.UnitAbbreviations instead.")]
38-
public static UnitAbbreviationsCache Default => UnitsNetSetup.Default.UnitAbbreviations;
39-
4034
private QuantityInfoLookup QuantityInfoLookup { get; }
4135

4236
/// <summary>

Diff for: UnitsNet/CustomCode/UnitParser.cs

+3-10
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,13 @@ namespace UnitsNet
1313
{
1414
/// <summary>
1515
/// Parses units given a unit abbreviations cache.
16-
/// The static instance <see cref="Default"/> is used internally to parse quantities and units using the
17-
/// default abbreviations cache for all units and abbreviations defined in the library.
16+
/// A static instance <see cref="UnitsNetSetup"/>.<see cref="UnitsNetSetup.Default"/>.<see cref="UnitsNetSetup.UnitParser"/> is used internally
17+
/// to parse quantities and units using the default abbreviations cache for all units and abbreviations defined in the library.
1818
/// </summary>
1919
public sealed class UnitParser
2020
{
2121
private readonly UnitAbbreviationsCache _unitAbbreviationsCache;
2222

23-
/// <summary>
24-
/// The default static instance used internally to parse quantities and units using the
25-
/// default abbreviations cache for all units and abbreviations defined in the library.
26-
/// </summary>
27-
[Obsolete("Use UnitsNetSetup.Default.UnitParser instead.")]
28-
public static UnitParser Default => UnitsNetSetup.Default.UnitParser;
29-
3023
/// <summary>
3124
/// Create a parser using the given unit abbreviations cache.
3225
/// </summary>
@@ -205,7 +198,7 @@ public bool TryParse([NotNullWhen(true)] string? unitAbbreviation, Type unitType
205198
{
206199
return false;
207200
}
208-
201+
209202
unit = matches[0].Unit;
210203
return true;
211204
}

Diff for: UnitsNet/UnitConverter.cs

-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Concurrent;
66
using System.Diagnostics.CodeAnalysis;
7-
using System.Globalization;
87
using System.Reflection;
98
using System.Linq;
109
using UnitsNet.InternalHelpers;
@@ -35,13 +34,6 @@ public delegate TQuantity ConversionFunction<TQuantity>(TQuantity inputValue)
3534
/// </summary>
3635
public sealed class UnitConverter
3736
{
38-
/// <summary>
39-
/// The static instance used by Units.NET to convert between units. Modify this to add/remove conversion functions at runtime, such
40-
/// as adding your own third-party units and quantities to convert between.
41-
/// </summary>
42-
[Obsolete("Use UnitsNetSetup.Default.UnitConverter instead.")]
43-
public static UnitConverter Default => UnitsNetSetup.Default.UnitConverter;
44-
4537
/// <summary>
4638
/// Creates a new <see cref="UnitConverter"/> instance.
4739
/// </summary>

0 commit comments

Comments
 (0)