Skip to content

Commit 78c154d

Browse files
committed
💥Change UnitParser ctor to require unit abbreviations cache
Ref #1200 - Throw if `null` is given - Remove fallback to default unit abbreviations
1 parent d81898a commit 78c154d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

UnitsNet/CustomCode/UnitParser.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public sealed class UnitParser
2323
/// <summary>
2424
/// Create a parser using the given unit abbreviations cache.
2525
/// </summary>
26-
/// <param name="unitAbbreviationsCache"></param>
27-
// TODO Change this to not fallback to built-in units abbreviations when given null, in v6: https://github.com/angularsen/UnitsNet/issues/1200
28-
public UnitParser(UnitAbbreviationsCache? unitAbbreviationsCache)
26+
/// <param name="unitAbbreviationsCache">The unit abbreviations to parse with.</param>
27+
/// <exception cref="ArgumentNullException">No unit abbreviations cache was given.</exception>
28+
public UnitParser(UnitAbbreviationsCache unitAbbreviationsCache)
2929
{
30-
_unitAbbreviationsCache = unitAbbreviationsCache ?? UnitsNetSetup.Default.UnitAbbreviations;
30+
_unitAbbreviationsCache = unitAbbreviationsCache ?? throw new ArgumentNullException(nameof(unitAbbreviationsCache));
3131
}
3232

3333
/// <summary>

0 commit comments

Comments
 (0)