diff --git a/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs b/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs index f23e5a1390..00d314ff7b 100644 --- a/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs +++ b/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs @@ -325,10 +325,10 @@ public void MapUnitToAbbreviation_DoesNotAffectOtherCacheInstances() var culture = AmericanCulture; var unit = AreaUnit.SquareMeter; - var cache1 = new UnitAbbreviationsCache(); + var cache1 = UnitAbbreviationsCache.CreateDefault(); cache1.MapUnitToAbbreviation(unit, culture, "m^2"); - var cache2 = new UnitAbbreviationsCache(); + var cache2 = UnitAbbreviationsCache.CreateDefault(); cache2.MapUnitToAbbreviation(unit, culture, "m2"); Assert.Equal(new[] { "m²", "m^2" }, cache1.GetUnitAbbreviations(unit, culture)); @@ -340,7 +340,7 @@ public void MapUnitToAbbreviation_DoesNotAffectOtherCacheInstances() [Fact] public void MapUnitToAbbreviation_AddCustomUnit_DoesNotOverrideDefaultAbbreviationForAlreadyMappedUnits() { - var cache = new UnitAbbreviationsCache(); + var cache = UnitAbbreviationsCache.CreateDefault(); cache.MapUnitToAbbreviation(AreaUnit.SquareMeter, AmericanCulture, "m^2"); Assert.Equal("m²", cache.GetDefaultAbbreviation(AreaUnit.SquareMeter, AmericanCulture)); diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index ee56cf7925..e19ad7f1d1 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -39,12 +39,10 @@ public sealed class UnitAbbreviationsCache private ConcurrentDictionary> AbbreviationsMap { get; } = new(); /// - /// Create an instance of the cache and load all the abbreviations defined in the library. + /// Create an empty instance of the cache, with no default abbreviations loaded. /// - // TODO Change this to create an empty cache in v6: https://github.com/angularsen/UnitsNet/issues/1200 - [Obsolete("Use CreateDefault() instead to create an instance that loads the built-in units. The default ctor will change to create an empty cache in UnitsNet v6.")] public UnitAbbreviationsCache() - : this(new QuantityInfoLookup(Quantity.ByName.Values)) + : this(new QuantityInfoLookup([])) { } @@ -59,16 +57,6 @@ internal UnitAbbreviationsCache(QuantityInfoLookup quantityInfoLookup) QuantityInfoLookup = quantityInfoLookup; } - /// - /// Create an instance with empty cache. - /// - /// - /// Workaround until v6 changes the default ctor to create an empty cache.
- ///
- /// Instance with empty cache. - // TODO Remove in v6: https://github.com/angularsen/UnitsNet/issues/1200 - public static UnitAbbreviationsCache CreateEmpty() => new(new QuantityInfoLookup(new List())); - /// /// Create an instance of the cache and load all the built-in unit abbreviations defined in the library. ///