Skip to content

Commit

Permalink
💥Change UnitParser ctor to require unit abbreviations cache (#1477)
Browse files Browse the repository at this point in the history
Ref #1200

- Throw if `null` is given
- Remove fallback to default unit abbreviations
  • Loading branch information
angularsen authored Dec 27, 2024
1 parent d81898a commit 8b3696b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions UnitsNet/CustomCode/UnitParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public sealed class UnitParser
/// <summary>
/// Create a parser using the given unit abbreviations cache.
/// </summary>
/// <param name="unitAbbreviationsCache"></param>
// TODO Change this to not fallback to built-in units abbreviations when given null, in v6: https://github.com/angularsen/UnitsNet/issues/1200
public UnitParser(UnitAbbreviationsCache? unitAbbreviationsCache)
/// <param name="unitAbbreviationsCache">The unit abbreviations to parse with.</param>
/// <exception cref="ArgumentNullException">No unit abbreviations cache was given.</exception>
public UnitParser(UnitAbbreviationsCache unitAbbreviationsCache)
{
_unitAbbreviationsCache = unitAbbreviationsCache ?? UnitsNetSetup.Default.UnitAbbreviations;
_unitAbbreviationsCache = unitAbbreviationsCache ?? throw new ArgumentNullException(nameof(unitAbbreviationsCache));
}

/// <summary>
Expand Down

0 comments on commit 8b3696b

Please sign in to comment.