From bb1420ea472f1f6457683cc8f2ffb48e9bf6074b Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sun, 29 Dec 2024 02:39:48 +0100 Subject: [PATCH] Un-obsolete static Default getters (#1481) Per [discussion ](https://github.com/angularsen/UnitsNet/pull/1475#issuecomment-2564377424) in v6, we no longer want to remove these. Already reverted in v6 with #1480 --- UnitsNet/CustomCode/QuantityParser.cs | 6 ++++-- UnitsNet/CustomCode/UnitAbbreviationsCache.cs | 7 +++++-- UnitsNet/CustomCode/UnitParser.cs | 7 ++++--- UnitsNet/UnitConverter.cs | 8 +++++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs index a221d39028..ae5e603398 100644 --- a/UnitsNet/CustomCode/QuantityParser.cs +++ b/UnitsNet/CustomCode/QuantityParser.cs @@ -35,9 +35,11 @@ public class QuantityParser private readonly UnitParser _unitParser; /// - /// The default instance of , which uses ... + /// The default singleton instance for parsing quantities. /// - [Obsolete("Use UnitsNetSetup.Default.QuantityParser instead.")] + /// + /// Convenience shortcut for ... + /// public static QuantityParser Default => UnitsNetSetup.Default.QuantityParser; /// diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index c863ab8ab6..304a32cda3 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -32,9 +32,12 @@ public sealed class UnitAbbreviationsCache internal static readonly CultureInfo FallbackCulture = CultureInfo.InvariantCulture; /// - /// The static instance used internally for ToString() and Parse() of quantities and units. + /// The default singleton instance with the default configured unit abbreviations, used for ToString() and parsing of quantities and units. /// - [Obsolete("Use UnitsNetSetup.Default.UnitAbbreviations instead.")] + /// + /// Convenience shortcut for ...
+ /// You can add custom unit abbreviations at runtime, and this will affect all usages globally in the application. + ///
public static UnitAbbreviationsCache Default => UnitsNetSetup.Default.UnitAbbreviations; private QuantityInfoLookup QuantityInfoLookup { get; } diff --git a/UnitsNet/CustomCode/UnitParser.cs b/UnitsNet/CustomCode/UnitParser.cs index 8d127afb01..74fa0cb652 100644 --- a/UnitsNet/CustomCode/UnitParser.cs +++ b/UnitsNet/CustomCode/UnitParser.cs @@ -20,10 +20,11 @@ public sealed class UnitParser private readonly UnitAbbreviationsCache _unitAbbreviationsCache; /// - /// 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. + /// The default singleton instance for parsing units from the default configured unit abbreviations. /// - [Obsolete("Use UnitsNetSetup.Default.UnitParser instead.")] + /// + /// Convenience shortcut for ... + /// public static UnitParser Default => UnitsNetSetup.Default.UnitParser; /// diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 3dc50b5497..56d9f7e8b1 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -36,10 +36,12 @@ public delegate TQuantity ConversionFunction(TQuantity inputValue) public sealed class UnitConverter { /// - /// 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. + /// The default singleton instance for converting values from one unit to another.
+ /// Modify this to add/remove conversion functions at runtime, such as adding your own third-party units and quantities to convert between. ///
- [Obsolete("Use UnitsNetSetup.Default.UnitConverter instead.")] + /// + /// Convenience shortcut for ... + /// public static UnitConverter Default => UnitsNetSetup.Default.UnitConverter; ///