diff --git a/Build/build-functions.psm1 b/Build/build-functions.psm1
index b4521037e3..3ba81899ca 100644
--- a/Build/build-functions.psm1
+++ b/Build/build-functions.psm1
@@ -7,7 +7,7 @@ $nuget = "$root\Tools\NuGet.exe"
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$msbuild = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
if ($msbuild) {
- $msbuild = join-path $msbuild 'MSBuild\15.0\Bin\MSBuild.exe'
+ $msbuild = join-path $msbuild 'MSBuild\Current\Bin\MSBuild.exe'
}
function Remove-ArtifactsDir {
diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
index caff760f4a..4d3942f9d5 100644
--- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
+++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs
@@ -51,6 +51,8 @@ public override string Generate()
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -186,7 +188,7 @@ private void GenerateInstanceConstructors()
/// No unit was found for the given .
public {_quantity.Name}({_valueType} value, UnitSystem unitSystem)
{{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -338,7 +340,7 @@ public static string GetAbbreviation({_unitEnumName} unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation({_unitEnumName} unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation({_unitEnumName} unit, IFormatProvider? provider)
{{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}}
@@ -441,7 +443,7 @@ private void GenerateStaticParseMethods()
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static {_quantity.Name} Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static {_quantity.Name} Parse(string str, IFormatProvider? provider)
{{
return QuantityParser.Default.Parse<{_quantity.Name}, {_unitEnumName}>(
str,
@@ -457,7 +459,7 @@ private void GenerateStaticParseMethods()
///
/// Length.Parse(""5.5 m"", new CultureInfo(""en-US""));
///
- public static bool TryParse([CanBeNull] string str, out {_quantity.Name} result)
+ public static bool TryParse(string? str, out {_quantity.Name} result)
{{
return TryParse(str, null, out result);
}}
@@ -472,7 +474,7 @@ public static bool TryParse([CanBeNull] string str, out {_quantity.Name} result)
/// Length.Parse(""5.5 m"", new CultureInfo(""en-US""));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out {_quantity.Name} result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out {_quantity.Name} result)
{{
return QuantityParser.Default.TryParse<{_quantity.Name}, {_unitEnumName}>(
str,
@@ -505,7 +507,7 @@ public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static {_unitEnumName} ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static {_unitEnumName} ParseUnit(string str, IFormatProvider? provider)
{{
return UnitParser.Default.Parse<{_unitEnumName}>(str, provider);
}}
@@ -526,7 +528,7 @@ public static bool TryParseUnit(string str, out {_unitEnumName} unit)
/// Length.TryParseUnit(""m"", new CultureInfo(""en-US""));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out {_unitEnumName} unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out {_unitEnumName} unit)
{{
return UnitParser.Default.TryParse<{_unitEnumName}>(str, provider, out unit);
}}
@@ -818,7 +820,7 @@ public double As({_unitEnumName} unit)
///
public double As(UnitSystem unitSystem)
{{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -861,7 +863,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public {_quantity.Name} ToUnit(UnitSystem unitSystem)
{{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -960,7 +962,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{{
return ToString(""g"", provider);
}}
@@ -972,7 +974,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@""This method is deprecated and will be removed at a future release. Please use ToString(""""s2"""") or ToString(""""s2"""", provider) where 2 is an example of the number passed to significantDigitsAfterRadix."")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -987,7 +989,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(""This method is deprecated and will be removed at a future release. Please use string.Format()."")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -1015,15 +1017,15 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{{
- return QuantityFormatter.Format<{_unitEnumName}>(this, format, formatProvider);
+ return QuantityFormatter.Format<{_unitEnumName}>(this, format, provider);
}}
#endregion
-");
+" );
}
private void GenerateIConvertibleMethods()
diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs
index 25d9143e49..066543d2de 100644
--- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs
+++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs
@@ -22,6 +22,8 @@ public override string Generate()
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
namespace UnitsNet
{
///
@@ -60,7 +62,7 @@ public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValu
/// Unit enum value.
/// The resulting quantity if successful, otherwise default.
/// True if successful with assigned the value, otherwise false.
- public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity quantity)
+ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quantity)
{
switch (unit)
{");
@@ -92,7 +94,7 @@ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity quantit
/// Quantity string representation, such as ""1.5 kg"". Must be compatible with given quantity type.
/// The resulting quantity if successful, otherwise default.
/// The parsed quantity.
- public static bool TryParse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString, out IQuantity quantity)
+ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, string quantityString, out IQuantity? quantity)
{
quantity = default(IQuantity);
diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs
index 97f64c4805..c69d65fabf 100644
--- a/UnitsNet/CustomCode/Quantities/Length.extra.cs
+++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs
@@ -47,7 +47,7 @@ public static Length FromFeetInches(double feet, double inches)
///
/// Optionally specify the culture format numbers and localize unit abbreviations. Defaults to thread's culture.
/// Parsed length.
- public static Length ParseFeetInches([NotNull] string str, IFormatProvider formatProvider = null)
+ public static Length ParseFeetInches([NotNull] string str, IFormatProvider? formatProvider = null)
{
if (str == null) throw new ArgumentNullException(nameof(str));
if (!TryParseFeetInches(str, out Length result, formatProvider))
@@ -69,7 +69,7 @@ public static Length ParseFeetInches([NotNull] string str, IFormatProvider forma
///
/// Parsed length.
/// Optionally specify the culture format numbers and localize unit abbreviations. Defaults to thread's culture.
- public static bool TryParseFeetInches([CanBeNull] string str, out Length result, IFormatProvider formatProvider = null)
+ public static bool TryParseFeetInches(string? str, out Length result, IFormatProvider? formatProvider = null)
{
if (str == null)
{
@@ -213,7 +213,7 @@ public override string ToString()
/// Optional culture to format number and localize unit abbreviations.
/// If null, defaults to .
///
- public string ToString([CanBeNull] IFormatProvider cultureInfo)
+ public string ToString(IFormatProvider? cultureInfo)
{
cultureInfo = cultureInfo ?? CultureInfo.CurrentUICulture;
diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs
index 418adf58f8..b28c958182 100644
--- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs
+++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs
@@ -129,7 +129,7 @@ public override string ToString()
/// Optional culture to format number and localize unit abbreviations.
/// If null, defaults to .
///
- public string ToString([CanBeNull] IFormatProvider cultureInfo)
+ public string ToString(IFormatProvider? cultureInfo)
{
cultureInfo = cultureInfo ?? CultureInfo.CurrentUICulture;
diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs
index 74fe89d86d..7b3693d270 100644
--- a/UnitsNet/CustomCode/Quantity.cs
+++ b/UnitsNet/CustomCode/Quantity.cs
@@ -47,15 +47,15 @@ static Quantity()
/// Unit value is not a know unit enum type.
public static IQuantity From(QuantityValue value, Enum unit)
{
- if (TryFrom(value, unit, out IQuantity quantity))
- return quantity;
+ if (TryFrom(value, unit, out IQuantity? quantity))
+ return quantity!;
throw new ArgumentException(
$"Unit value {unit} of type {unit.GetType()} is not a known unit enum type. Expected types like UnitsNet.Units.LengthUnit. Did you pass in a third-party enum type defined outside UnitsNet library?");
}
///
- public static bool TryFrom(double value, Enum unit, out IQuantity quantity)
+ public static bool TryFrom(double value, Enum unit, out IQuantity? quantity)
{
// Implicit cast to QuantityValue would prevent TryFrom from being called,
// so we need to explicitly check this here for double arguments.
@@ -79,18 +79,19 @@ public static bool TryFrom(double value, Enum unit, out IQuantity quantity)
/// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type.
/// The parsed quantity.
/// Type must be of type UnitsNet.IQuantity -or- Type is not a known quantity type.
- public static IQuantity Parse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString)
+ public static IQuantity Parse(IFormatProvider? formatProvider, Type quantityType, string quantityString)
{
if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType))
throw new ArgumentException($"Type {quantityType} must be of type UnitsNet.IQuantity.");
- if (TryParse(formatProvider, quantityType, quantityString, out IQuantity quantity)) return quantity;
+ if (TryParse(formatProvider, quantityType, quantityString, out IQuantity? quantity))
+ return quantity!;
throw new ArgumentException($"Quantity string could not be parsed to quantity {quantityType}.");
}
///
- public static bool TryParse(Type quantityType, string quantityString, out IQuantity quantity) =>
+ public static bool TryParse(Type quantityType, string quantityString, out IQuantity? quantity) =>
TryParse(null, quantityType, quantityString, out quantity);
///
diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs
index afe9db276f..a0054f5779 100644
--- a/UnitsNet/CustomCode/QuantityParser.cs
+++ b/UnitsNet/CustomCode/QuantityParser.cs
@@ -42,7 +42,7 @@ static QuantityParser()
[SuppressMessage("ReSharper", "UseStringInterpolation")]
internal TQuantity Parse([NotNull] string str,
- [CanBeNull] IFormatProvider formatProvider,
+ IFormatProvider? formatProvider,
[NotNull] QuantityFromDelegate fromDelegate)
where TQuantity : IQuantity
where TUnitType : Enum
@@ -59,28 +59,28 @@ internal TQuantity Parse([NotNull] string str,
var regex = CreateRegexForQuantity(formatProvider);
- if (!ExtractValueAndUnit(regex, str, out var valueString, out var unitString))
+ if (!TryExtractValueAndUnit(regex, str, out var valueString, out var unitString))
{
var ex = new FormatException("Unable to parse quantity. Expected the form \"{value} {unit abbreviation}\", such as \"5.5 m\". The spacing is optional.");
ex.Data["input"] = str;
throw ex;
}
- return ParseWithRegex(valueString, unitString, fromDelegate, formatProvider);
+ return ParseWithRegex(valueString!, unitString!, fromDelegate, formatProvider);
}
[SuppressMessage("ReSharper", "UseStringInterpolation")]
- internal bool TryParse([NotNull] string str,
- [CanBeNull] IFormatProvider formatProvider,
+ internal bool TryParse(string? str,
+ IFormatProvider? formatProvider,
[NotNull] QuantityFromDelegate fromDelegate,
out TQuantity result)
- where TQuantity : IQuantity
- where TUnitType : Enum
+ where TQuantity : struct, IQuantity
+ where TUnitType : struct, Enum
{
result = default;
if(string.IsNullOrWhiteSpace(str)) return false;
- str = str.Trim();
+ str = str!.Trim();
var numFormat = formatProvider != null
? (NumberFormatInfo) formatProvider.GetFormat(typeof(NumberFormatInfo))
@@ -91,7 +91,7 @@ internal bool TryParse([NotNull] string str,
var regex = CreateRegexForQuantity(formatProvider);
- if (!ExtractValueAndUnit(regex, str, out var valueString, out var unitString))
+ if (!TryExtractValueAndUnit(regex, str, out var valueString, out var unitString))
return false;
return TryParseWithRegex(valueString, unitString, fromDelegate, formatProvider, out result);
@@ -102,11 +102,11 @@ internal bool TryParse([NotNull] string str,
///
[SuppressMessage("ReSharper", "UseStringInterpolation")]
internal bool TryParse([NotNull] string str,
- [CanBeNull] IFormatProvider formatProvider,
+ IFormatProvider? formatProvider,
[NotNull] QuantityFromDelegate fromDelegate,
- out IQuantity result)
- where TQuantity : IQuantity
- where TUnitType : Enum
+ out IQuantity? result)
+ where TQuantity : struct, IQuantity
+ where TUnitType : struct, Enum
{
if (TryParse(str, formatProvider, fromDelegate, out TQuantity parsedQuantity))
{
@@ -120,7 +120,7 @@ internal bool TryParse([NotNull] string str,
internal string CreateRegexPatternForUnit(
TUnitType unit,
- IFormatProvider formatProvider,
+ IFormatProvider? formatProvider,
bool matchEntireString = true)
where TUnitType : Enum
{
@@ -147,7 +147,7 @@ private static string GetRegexPatternForUnitAbbreviations(IEnumerable ab
private TQuantity ParseWithRegex(string valueString,
string unitString,
QuantityFromDelegate fromDelegate,
- IFormatProvider formatProvider)
+ IFormatProvider? formatProvider)
where TQuantity : IQuantity
where TUnitType : Enum
{
@@ -160,13 +160,13 @@ private TQuantity ParseWithRegex(string valueString,
/// Parse a string given a particular regular expression.
///
/// Error parsing string.
- private bool TryParseWithRegex(string valueString,
- string unitString,
+ private bool TryParseWithRegex(string? valueString,
+ string? unitString,
QuantityFromDelegate fromDelegate,
- IFormatProvider formatProvider,
+ IFormatProvider? formatProvider,
out TQuantity result)
- where TQuantity : IQuantity
- where TUnitType : Enum
+ where TQuantity : struct, IQuantity
+ where TUnitType : struct, Enum
{
result = default;
@@ -180,7 +180,7 @@ private bool TryParseWithRegex(string valueString,
return true;
}
- private static bool ExtractValueAndUnit(Regex regex, string str, out string valueString, out string unitString)
+ private static bool TryExtractValueAndUnit(Regex regex, string str, out string? valueString, out string? unitString)
{
var match = regex.Match(str);
@@ -210,7 +210,7 @@ private static bool ExtractValueAndUnit(Regex regex, string str, out string valu
return true;
}
- private string CreateRegexPatternForQuantity(IFormatProvider formatProvider) where TUnitType : Enum
+ private string CreateRegexPatternForQuantity(IFormatProvider? formatProvider) where TUnitType : Enum
{
var unitAbbreviations = _unitAbbreviationsCache.GetAllUnitAbbreviationsForQuantity(typeof(TUnitType), formatProvider);
var pattern = GetRegexPatternForUnitAbbreviations(unitAbbreviations);
@@ -219,7 +219,7 @@ private string CreateRegexPatternForQuantity(IFormatProvider formatPr
return $"^{pattern}$";
}
- private Regex CreateRegexForQuantity([CanBeNull] IFormatProvider formatProvider) where TUnitType : Enum
+ private Regex CreateRegexForQuantity(IFormatProvider? formatProvider) where TUnitType : Enum
{
var pattern = CreateRegexPatternForQuantity(formatProvider);
return new Regex(pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase);
diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs
index d10b08b5fe..a0b52ff101 100644
--- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs
+++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs
@@ -192,7 +192,7 @@ private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatPro
/// The type of unit enum.
/// The default unit abbreviation string.
[PublicAPI]
- public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider formatProvider = null) where TUnitType : Enum
+ public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider? formatProvider = null) where TUnitType : Enum
{
var unitType = typeof(TUnitType);
@@ -204,7 +204,7 @@ public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider
throw new NotImplementedException($"No abbreviation is specified for {unitType.Name}.{unit}");
}
- var abbreviations = lookup.GetAbbreviationsForUnit(unit);
+ var abbreviations = lookup!.GetAbbreviationsForUnit(unit);
if(abbreviations.Count == 0)
{
if(formatProvider != FallbackCulture)
@@ -226,7 +226,7 @@ public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider
/// The format provider to use for lookup. Defaults to if null.
/// The default unit abbreviation string.
[PublicAPI]
- public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider = null)
+ public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider? formatProvider = null)
{
if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup))
{
@@ -236,7 +236,7 @@ public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvid
throw new NotImplementedException($"No abbreviation is specified for {unitType.Name} with numeric value {unitValue}.");
}
- var abbreviations = lookup.GetAbbreviationsForUnit(unitValue);
+ var abbreviations = lookup!.GetAbbreviationsForUnit(unitValue);
if(abbreviations.Count == 0)
{
if(formatProvider != FallbackCulture)
@@ -256,7 +256,7 @@ public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvid
/// The format provider to use for lookup. Defaults to if null.
/// Unit abbreviations associated with unit.
[PublicAPI]
- public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider formatProvider = null) where TUnitType : Enum
+ public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider? formatProvider = null) where TUnitType : Enum
{
return GetUnitAbbreviations(typeof(TUnitType), Convert.ToInt32(unit), formatProvider);
}
@@ -269,14 +269,14 @@ public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider
/// The format provider to use for lookup. Defaults to if null.
/// Unit abbreviations associated with unit.
[PublicAPI]
- public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvider formatProvider = null)
+ public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvider? formatProvider = null)
{
formatProvider = formatProvider ?? CultureInfo.CurrentUICulture;
if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup))
return formatProvider != FallbackCulture ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) : new string[] { };
- var abbreviations = lookup.GetAbbreviationsForUnit(unitValue);
+ var abbreviations = lookup!.GetAbbreviationsForUnit(unitValue);
if(abbreviations.Count == 0)
return formatProvider != FallbackCulture ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) : new string[] { };
@@ -290,17 +290,17 @@ public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvid
/// The format provider to use for lookup. Defaults to if null.
/// Unit abbreviations associated with unit.
[PublicAPI]
- public string[] GetAllUnitAbbreviationsForQuantity(Type unitEnumType, IFormatProvider formatProvider = null)
+ public string[] GetAllUnitAbbreviationsForQuantity(Type unitEnumType, IFormatProvider? formatProvider = null)
{
formatProvider = formatProvider ?? CultureInfo.CurrentUICulture;
if(!TryGetUnitValueAbbreviationLookup(unitEnumType, formatProvider, out var lookup))
return formatProvider != FallbackCulture ? GetAllUnitAbbreviationsForQuantity(unitEnumType, FallbackCulture) : new string[] { };
- return lookup.GetAllUnitAbbreviationsForQuantity();
+ return lookup!.GetAllUnitAbbreviationsForQuantity();
}
- internal bool TryGetUnitValueAbbreviationLookup(Type unitType, IFormatProvider formatProvider, out UnitValueAbbreviationLookup unitToAbbreviations)
+ internal bool TryGetUnitValueAbbreviationLookup(Type unitType, IFormatProvider? formatProvider, out UnitValueAbbreviationLookup? unitToAbbreviations)
{
unitToAbbreviations = null;
diff --git a/UnitsNet/CustomCode/UnitParser.cs b/UnitsNet/CustomCode/UnitParser.cs
index ef254232a4..2becb1fd4d 100644
--- a/UnitsNet/CustomCode/UnitParser.cs
+++ b/UnitsNet/CustomCode/UnitParser.cs
@@ -48,7 +48,7 @@ static UnitParser()
///
///
[PublicAPI]
- public TUnitType Parse(string unitAbbreviation, [CanBeNull] IFormatProvider formatProvider = null) where TUnitType : Enum
+ public TUnitType Parse(string unitAbbreviation, IFormatProvider? formatProvider = null) where TUnitType : Enum
{
return (TUnitType)Parse(unitAbbreviation, typeof(TUnitType), formatProvider);
}
@@ -67,7 +67,7 @@ public TUnitType Parse(string unitAbbreviation, [CanBeNull] IFormatPr
/// No units match the abbreviation.
/// More than one unit matches the abbreviation.
[PublicAPI]
- public Enum Parse([NotNull] string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider = null)
+ public Enum Parse([NotNull] string unitAbbreviation, Type unitType, IFormatProvider? formatProvider = null)
{
if (unitAbbreviation == null) throw new ArgumentNullException(nameof(unitAbbreviation));
unitAbbreviation = unitAbbreviation.Trim();
@@ -75,7 +75,7 @@ public Enum Parse([NotNull] string unitAbbreviation, Type unitType, [CanBeNull]
if(!_unitAbbreviationsCache.TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var abbreviations))
throw new UnitNotFoundException($"No abbreviations defined for unit type [{unitType}] for culture [{formatProvider}].");
- var unitIntValues = abbreviations.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: true);
+ var unitIntValues = abbreviations!.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: true);
if (unitIntValues.Count == 0)
{
@@ -139,7 +139,7 @@ internal static string NormalizeUnitString(string unitAbbreviation)
/// Type of unit enum.
/// True if successful.
[PublicAPI]
- public bool TryParse(string unitAbbreviation, out TUnitType unit) where TUnitType : Enum
+ public bool TryParse(string unitAbbreviation, out TUnitType unit) where TUnitType : struct, Enum
{
return TryParse(unitAbbreviation, null, out unit);
}
@@ -153,14 +153,14 @@ public bool TryParse(string unitAbbreviation, out TUnitType unit) whe
/// Type of unit enum.
/// True if successful.
[PublicAPI]
- public bool TryParse(string unitAbbreviation, [CanBeNull] IFormatProvider formatProvider, out TUnitType unit) where TUnitType : Enum
+ public bool TryParse(string? unitAbbreviation, IFormatProvider? formatProvider, out TUnitType unit) where TUnitType : struct, Enum
{
unit = default;
if(!TryParse(unitAbbreviation, typeof(TUnitType), formatProvider, out var unitObj))
return false;
- unit = (TUnitType)unitObj;
+ unit = (TUnitType)unitObj!;
return true;
}
@@ -172,7 +172,7 @@ public bool TryParse(string unitAbbreviation, [CanBeNull] IFormatProv
/// The unit enum value as out result.
/// True if successful.
[PublicAPI]
- public bool TryParse(string unitAbbreviation, Type unitType, out Enum unit)
+ public bool TryParse(string unitAbbreviation, Type unitType, out Enum? unit)
{
return TryParse(unitAbbreviation, unitType, null, out unit);
}
@@ -186,7 +186,7 @@ public bool TryParse(string unitAbbreviation, Type unitType, out Enum unit)
/// The unit enum value as out result.
/// True if successful.
[PublicAPI]
- public bool TryParse(string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider, out Enum unit)
+ public bool TryParse(string? unitAbbreviation, Type unitType, IFormatProvider? formatProvider, out Enum? unit)
{
if (unitAbbreviation == null)
{
@@ -200,7 +200,7 @@ public bool TryParse(string unitAbbreviation, Type unitType, [CanBeNull] IFormat
if(!_unitAbbreviationsCache.TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var abbreviations))
return false;
- var unitIntValues = abbreviations.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: true);
+ var unitIntValues = abbreviations!.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: true);
if (unitIntValues.Count == 0)
{
diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
index 39e69008d1..ed7f90771b 100644
--- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -92,7 +94,7 @@ public Acceleration(double value, AccelerationUnit unit)
/// No unit was found for the given .
public Acceleration(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -260,7 +262,7 @@ public static string GetAbbreviation(AccelerationUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(AccelerationUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(AccelerationUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -452,7 +454,7 @@ public static Acceleration Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Acceleration Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Acceleration Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -468,7 +470,7 @@ public static Acceleration Parse(string str, [CanBeNull] IFormatProvider provide
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Acceleration result)
+ public static bool TryParse(string? str, out Acceleration result)
{
return TryParse(str, null, out result);
}
@@ -483,7 +485,7 @@ public static bool TryParse([CanBeNull] string str, out Acceleration result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Acceleration result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Acceleration result)
{
return QuantityParser.Default.TryParse(
str,
@@ -516,7 +518,7 @@ public static AccelerationUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static AccelerationUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static AccelerationUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -537,7 +539,7 @@ public static bool TryParseUnit(string str, out AccelerationUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out AccelerationUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out AccelerationUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -742,7 +744,7 @@ public double As(AccelerationUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -785,7 +787,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Acceleration ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -889,7 +891,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -901,7 +903,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -916,7 +918,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -944,11 +946,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
index 18abeba8bd..94b3ca9fd8 100644
--- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -94,7 +96,7 @@ public AmountOfSubstance(double value, AmountOfSubstanceUnit unit)
/// No unit was found for the given .
public AmountOfSubstance(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -272,7 +274,7 @@ public static string GetAbbreviation(AmountOfSubstanceUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(AmountOfSubstanceUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(AmountOfSubstanceUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -482,7 +484,7 @@ public static AmountOfSubstance Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static AmountOfSubstance Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static AmountOfSubstance Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -498,7 +500,7 @@ public static AmountOfSubstance Parse(string str, [CanBeNull] IFormatProvider pr
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out AmountOfSubstance result)
+ public static bool TryParse(string? str, out AmountOfSubstance result)
{
return TryParse(str, null, out result);
}
@@ -513,7 +515,7 @@ public static bool TryParse([CanBeNull] string str, out AmountOfSubstance result
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out AmountOfSubstance result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out AmountOfSubstance result)
{
return QuantityParser.Default.TryParse(
str,
@@ -546,7 +548,7 @@ public static AmountOfSubstanceUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static AmountOfSubstanceUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static AmountOfSubstanceUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -567,7 +569,7 @@ public static bool TryParseUnit(string str, out AmountOfSubstanceUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out AmountOfSubstanceUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out AmountOfSubstanceUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -772,7 +774,7 @@ public double As(AmountOfSubstanceUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -815,7 +817,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public AmountOfSubstance ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -923,7 +925,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -935,7 +937,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -950,7 +952,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -978,11 +980,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
index f0a38498f0..899d516ff6 100644
--- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -83,7 +85,7 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit)
/// No unit was found for the given .
public AmplitudeRatio(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -206,7 +208,7 @@ public static string GetAbbreviation(AmplitudeRatioUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(AmplitudeRatioUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(AmplitudeRatioUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -317,7 +319,7 @@ public static AmplitudeRatio Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static AmplitudeRatio Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static AmplitudeRatio Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -333,7 +335,7 @@ public static AmplitudeRatio Parse(string str, [CanBeNull] IFormatProvider provi
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out AmplitudeRatio result)
+ public static bool TryParse(string? str, out AmplitudeRatio result)
{
return TryParse(str, null, out result);
}
@@ -348,7 +350,7 @@ public static bool TryParse([CanBeNull] string str, out AmplitudeRatio result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out AmplitudeRatio result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out AmplitudeRatio result)
{
return QuantityParser.Default.TryParse(
str,
@@ -381,7 +383,7 @@ public static AmplitudeRatioUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static AmplitudeRatioUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static AmplitudeRatioUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -402,7 +404,7 @@ public static bool TryParseUnit(string str, out AmplitudeRatioUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out AmplitudeRatioUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out AmplitudeRatioUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -615,7 +617,7 @@ public double As(AmplitudeRatioUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -658,7 +660,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public AmplitudeRatio ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -744,7 +746,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -756,7 +758,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -771,7 +773,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -799,11 +801,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
index 64efe5550d..7299ad8473 100644
--- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -93,7 +95,7 @@ public Angle(double value, AngleUnit unit)
/// No unit was found for the given .
public Angle(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -266,7 +268,7 @@ public static string GetAbbreviation(AngleUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(AngleUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(AngleUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -467,7 +469,7 @@ public static Angle Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Angle Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Angle Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -483,7 +485,7 @@ public static Angle Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Angle result)
+ public static bool TryParse(string? str, out Angle result)
{
return TryParse(str, null, out result);
}
@@ -498,7 +500,7 @@ public static bool TryParse([CanBeNull] string str, out Angle result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Angle result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Angle result)
{
return QuantityParser.Default.TryParse(
str,
@@ -531,7 +533,7 @@ public static AngleUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static AngleUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static AngleUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -552,7 +554,7 @@ public static bool TryParseUnit(string str, out AngleUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out AngleUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out AngleUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -757,7 +759,7 @@ public double As(AngleUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -800,7 +802,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Angle ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -906,7 +908,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -918,7 +920,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -933,7 +935,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -961,11 +963,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
index 9cee071934..895523d500 100644
--- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -82,7 +84,7 @@ public ApparentEnergy(double value, ApparentEnergyUnit unit)
/// No unit was found for the given .
public ApparentEnergy(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -200,7 +202,7 @@ public static string GetAbbreviation(ApparentEnergyUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ApparentEnergyUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ApparentEnergyUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -302,7 +304,7 @@ public static ApparentEnergy Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ApparentEnergy Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ApparentEnergy Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -318,7 +320,7 @@ public static ApparentEnergy Parse(string str, [CanBeNull] IFormatProvider provi
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ApparentEnergy result)
+ public static bool TryParse(string? str, out ApparentEnergy result)
{
return TryParse(str, null, out result);
}
@@ -333,7 +335,7 @@ public static bool TryParse([CanBeNull] string str, out ApparentEnergy result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ApparentEnergy result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ApparentEnergy result)
{
return QuantityParser.Default.TryParse(
str,
@@ -366,7 +368,7 @@ public static ApparentEnergyUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ApparentEnergyUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ApparentEnergyUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -387,7 +389,7 @@ public static bool TryParseUnit(string str, out ApparentEnergyUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ApparentEnergyUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ApparentEnergyUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -592,7 +594,7 @@ public double As(ApparentEnergyUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -635,7 +637,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ApparentEnergy ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -719,7 +721,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -731,7 +733,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -746,7 +748,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -774,11 +776,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
index 951f5b4370..269c94cd4d 100644
--- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -83,7 +85,7 @@ public ApparentPower(double value, ApparentPowerUnit unit)
/// No unit was found for the given .
public ApparentPower(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -206,7 +208,7 @@ public static string GetAbbreviation(ApparentPowerUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ApparentPowerUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ApparentPowerUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -317,7 +319,7 @@ public static ApparentPower Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ApparentPower Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ApparentPower Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -333,7 +335,7 @@ public static ApparentPower Parse(string str, [CanBeNull] IFormatProvider provid
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ApparentPower result)
+ public static bool TryParse(string? str, out ApparentPower result)
{
return TryParse(str, null, out result);
}
@@ -348,7 +350,7 @@ public static bool TryParse([CanBeNull] string str, out ApparentPower result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ApparentPower result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ApparentPower result)
{
return QuantityParser.Default.TryParse(
str,
@@ -381,7 +383,7 @@ public static ApparentPowerUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ApparentPowerUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ApparentPowerUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -402,7 +404,7 @@ public static bool TryParseUnit(string str, out ApparentPowerUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ApparentPowerUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ApparentPowerUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -607,7 +609,7 @@ public double As(ApparentPowerUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -650,7 +652,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ApparentPower ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -736,7 +738,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -748,7 +750,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -763,7 +765,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -791,11 +793,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs
index 07241d5540..d5f3d94ed7 100644
--- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -93,7 +95,7 @@ public Area(double value, AreaUnit unit)
/// No unit was found for the given .
public Area(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -266,7 +268,7 @@ public static string GetAbbreviation(AreaUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(AreaUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(AreaUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -467,7 +469,7 @@ public static Area Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Area Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Area Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -483,7 +485,7 @@ public static Area Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Area result)
+ public static bool TryParse(string? str, out Area result)
{
return TryParse(str, null, out result);
}
@@ -498,7 +500,7 @@ public static bool TryParse([CanBeNull] string str, out Area result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Area result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Area result)
{
return QuantityParser.Default.TryParse(
str,
@@ -531,7 +533,7 @@ public static AreaUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static AreaUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static AreaUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -552,7 +554,7 @@ public static bool TryParseUnit(string str, out AreaUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out AreaUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -757,7 +759,7 @@ public double As(AreaUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -800,7 +802,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Area ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -906,7 +908,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -918,7 +920,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -933,7 +935,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -961,11 +963,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
index b4e3655c0d..e5b4215ceb 100644
--- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -80,7 +82,7 @@ public AreaDensity(double value, AreaDensityUnit unit)
/// No unit was found for the given .
public AreaDensity(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -188,7 +190,7 @@ public static string GetAbbreviation(AreaDensityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(AreaDensityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(AreaDensityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -272,7 +274,7 @@ public static AreaDensity Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static AreaDensity Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static AreaDensity Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -288,7 +290,7 @@ public static AreaDensity Parse(string str, [CanBeNull] IFormatProvider provider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out AreaDensity result)
+ public static bool TryParse(string? str, out AreaDensity result)
{
return TryParse(str, null, out result);
}
@@ -303,7 +305,7 @@ public static bool TryParse([CanBeNull] string str, out AreaDensity result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out AreaDensity result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out AreaDensity result)
{
return QuantityParser.Default.TryParse(
str,
@@ -336,7 +338,7 @@ public static AreaDensityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static AreaDensityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static AreaDensityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -357,7 +359,7 @@ public static bool TryParseUnit(string str, out AreaDensityUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out AreaDensityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaDensityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -562,7 +564,7 @@ public double As(AreaDensityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -605,7 +607,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public AreaDensity ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -685,7 +687,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -697,7 +699,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -712,7 +714,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -740,11 +742,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
index 1d4d806463..8d9872efab 100644
--- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -85,7 +87,7 @@ public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit)
/// No unit was found for the given .
public AreaMomentOfInertia(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -218,7 +220,7 @@ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -347,7 +349,7 @@ public static AreaMomentOfInertia Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static AreaMomentOfInertia Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static AreaMomentOfInertia Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -363,7 +365,7 @@ public static AreaMomentOfInertia Parse(string str, [CanBeNull] IFormatProvider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out AreaMomentOfInertia result)
+ public static bool TryParse(string? str, out AreaMomentOfInertia result)
{
return TryParse(str, null, out result);
}
@@ -378,7 +380,7 @@ public static bool TryParse([CanBeNull] string str, out AreaMomentOfInertia resu
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out AreaMomentOfInertia result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out AreaMomentOfInertia result)
{
return QuantityParser.Default.TryParse(
str,
@@ -411,7 +413,7 @@ public static AreaMomentOfInertiaUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static AreaMomentOfInertiaUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static AreaMomentOfInertiaUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -432,7 +434,7 @@ public static bool TryParseUnit(string str, out AreaMomentOfInertiaUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out AreaMomentOfInertiaUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaMomentOfInertiaUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -637,7 +639,7 @@ public double As(AreaMomentOfInertiaUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -680,7 +682,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public AreaMomentOfInertia ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -770,7 +772,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -782,7 +784,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -797,7 +799,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -825,11 +827,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
index c3539d1999..c7e6ad0c0e 100644
--- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -108,7 +110,7 @@ public BitRate(decimal value, BitRateUnit unit)
/// No unit was found for the given .
public BitRate(decimal value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -343,7 +345,7 @@ public static string GetAbbreviation(BitRateUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(BitRateUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -652,7 +654,7 @@ public static BitRate Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static BitRate Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static BitRate Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -668,7 +670,7 @@ public static BitRate Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out BitRate result)
+ public static bool TryParse(string? str, out BitRate result)
{
return TryParse(str, null, out result);
}
@@ -683,7 +685,7 @@ public static bool TryParse([CanBeNull] string str, out BitRate result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out BitRate result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out BitRate result)
{
return QuantityParser.Default.TryParse(
str,
@@ -716,7 +718,7 @@ public static BitRateUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static BitRateUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static BitRateUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -737,7 +739,7 @@ public static bool TryParseUnit(string str, out BitRateUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out BitRateUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRateUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -942,7 +944,7 @@ public double As(BitRateUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -985,7 +987,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public BitRate ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -1115,7 +1117,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -1127,7 +1129,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -1142,7 +1144,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -1170,11 +1172,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
index 13c1919e53..ec856aa869 100644
--- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -82,7 +84,7 @@ public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUn
/// No unit was found for the given .
public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -200,7 +202,7 @@ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -302,7 +304,7 @@ public static BrakeSpecificFuelConsumption Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static BrakeSpecificFuelConsumption Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static BrakeSpecificFuelConsumption Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -318,7 +320,7 @@ public static BrakeSpecificFuelConsumption Parse(string str, [CanBeNull] IFormat
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out BrakeSpecificFuelConsumption result)
+ public static bool TryParse(string? str, out BrakeSpecificFuelConsumption result)
{
return TryParse(str, null, out result);
}
@@ -333,7 +335,7 @@ public static bool TryParse([CanBeNull] string str, out BrakeSpecificFuelConsump
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out BrakeSpecificFuelConsumption result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out BrakeSpecificFuelConsumption result)
{
return QuantityParser.Default.TryParse(
str,
@@ -366,7 +368,7 @@ public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -387,7 +389,7 @@ public static bool TryParseUnit(string str, out BrakeSpecificFuelConsumptionUnit
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out BrakeSpecificFuelConsumptionUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out BrakeSpecificFuelConsumptionUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -592,7 +594,7 @@ public double As(BrakeSpecificFuelConsumptionUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -635,7 +637,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -719,7 +721,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -731,7 +733,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -746,7 +748,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -774,11 +776,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
index d3f61dfd10..cfdce7831f 100644
--- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -89,7 +91,7 @@ public Capacitance(double value, CapacitanceUnit unit)
/// No unit was found for the given .
public Capacitance(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -227,7 +229,7 @@ public static string GetAbbreviation(CapacitanceUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(CapacitanceUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(CapacitanceUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -365,7 +367,7 @@ public static Capacitance Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Capacitance Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Capacitance Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -381,7 +383,7 @@ public static Capacitance Parse(string str, [CanBeNull] IFormatProvider provider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Capacitance result)
+ public static bool TryParse(string? str, out Capacitance result)
{
return TryParse(str, null, out result);
}
@@ -396,7 +398,7 @@ public static bool TryParse([CanBeNull] string str, out Capacitance result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Capacitance result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Capacitance result)
{
return QuantityParser.Default.TryParse(
str,
@@ -429,7 +431,7 @@ public static CapacitanceUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static CapacitanceUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static CapacitanceUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -450,7 +452,7 @@ public static bool TryParseUnit(string str, out CapacitanceUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out CapacitanceUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out CapacitanceUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -655,7 +657,7 @@ public double As(CapacitanceUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -698,7 +700,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Capacitance ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -790,7 +792,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -802,7 +804,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -817,7 +819,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -845,11 +847,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs
index 46a7fac2af..284ff62318 100644
--- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -82,7 +84,7 @@ public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansion
/// No unit was found for the given .
public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -200,7 +202,7 @@ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -302,7 +304,7 @@ public static CoefficientOfThermalExpansion Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static CoefficientOfThermalExpansion Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static CoefficientOfThermalExpansion Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -318,7 +320,7 @@ public static CoefficientOfThermalExpansion Parse(string str, [CanBeNull] IForma
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out CoefficientOfThermalExpansion result)
+ public static bool TryParse(string? str, out CoefficientOfThermalExpansion result)
{
return TryParse(str, null, out result);
}
@@ -333,7 +335,7 @@ public static bool TryParse([CanBeNull] string str, out CoefficientOfThermalExpa
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out CoefficientOfThermalExpansion result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out CoefficientOfThermalExpansion result)
{
return QuantityParser.Default.TryParse(
str,
@@ -366,7 +368,7 @@ public static CoefficientOfThermalExpansionUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static CoefficientOfThermalExpansionUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static CoefficientOfThermalExpansionUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -387,7 +389,7 @@ public static bool TryParseUnit(string str, out CoefficientOfThermalExpansionUni
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out CoefficientOfThermalExpansionUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out CoefficientOfThermalExpansionUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -592,7 +594,7 @@ public double As(CoefficientOfThermalExpansionUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -635,7 +637,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -719,7 +721,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -731,7 +733,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -746,7 +748,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -774,11 +776,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs
index c22b5734eb..da5c1bbd5b 100644
--- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -122,7 +124,7 @@ public Density(double value, DensityUnit unit)
/// No unit was found for the given .
public Density(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -425,7 +427,7 @@ public static string GetAbbreviation(DensityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(DensityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(DensityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -860,7 +862,7 @@ public static Density Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Density Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Density Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -876,7 +878,7 @@ public static Density Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Density result)
+ public static bool TryParse(string? str, out Density result)
{
return TryParse(str, null, out result);
}
@@ -891,7 +893,7 @@ public static bool TryParse([CanBeNull] string str, out Density result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Density result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Density result)
{
return QuantityParser.Default.TryParse(
str,
@@ -924,7 +926,7 @@ public static DensityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static DensityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static DensityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -945,7 +947,7 @@ public static bool TryParseUnit(string str, out DensityUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out DensityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out DensityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -1150,7 +1152,7 @@ public double As(DensityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -1193,7 +1195,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Density ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -1351,7 +1353,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -1363,7 +1365,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -1378,7 +1380,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -1406,11 +1408,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
index 334f988875..8dfbec5b24 100644
--- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -89,7 +91,7 @@ public Duration(double value, DurationUnit unit)
/// No unit was found for the given .
public Duration(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -242,7 +244,7 @@ public static string GetAbbreviation(DurationUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(DurationUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(DurationUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -407,7 +409,7 @@ public static Duration Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Duration Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Duration Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -423,7 +425,7 @@ public static Duration Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Duration result)
+ public static bool TryParse(string? str, out Duration result)
{
return TryParse(str, null, out result);
}
@@ -438,7 +440,7 @@ public static bool TryParse([CanBeNull] string str, out Duration result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Duration result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Duration result)
{
return QuantityParser.Default.TryParse(
str,
@@ -471,7 +473,7 @@ public static DurationUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static DurationUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static DurationUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -492,7 +494,7 @@ public static bool TryParseUnit(string str, out DurationUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out DurationUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out DurationUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -697,7 +699,7 @@ public double As(DurationUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -740,7 +742,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Duration ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -838,7 +840,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -850,7 +852,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -865,7 +867,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -893,11 +895,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
index 4c734b5014..3ced8d43ee 100644
--- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -91,7 +93,7 @@ public DynamicViscosity(double value, DynamicViscosityUnit unit)
/// No unit was found for the given .
public DynamicViscosity(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -239,7 +241,7 @@ public static string GetAbbreviation(DynamicViscosityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(DynamicViscosityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(DynamicViscosityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -395,7 +397,7 @@ public static DynamicViscosity Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static DynamicViscosity Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static DynamicViscosity Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -411,7 +413,7 @@ public static DynamicViscosity Parse(string str, [CanBeNull] IFormatProvider pro
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out DynamicViscosity result)
+ public static bool TryParse(string? str, out DynamicViscosity result)
{
return TryParse(str, null, out result);
}
@@ -426,7 +428,7 @@ public static bool TryParse([CanBeNull] string str, out DynamicViscosity result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out DynamicViscosity result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out DynamicViscosity result)
{
return QuantityParser.Default.TryParse(
str,
@@ -459,7 +461,7 @@ public static DynamicViscosityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static DynamicViscosityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static DynamicViscosityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -480,7 +482,7 @@ public static bool TryParseUnit(string str, out DynamicViscosityUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out DynamicViscosityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out DynamicViscosityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -685,7 +687,7 @@ public double As(DynamicViscosityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -728,7 +730,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public DynamicViscosity ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -824,7 +826,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -836,7 +838,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -851,7 +853,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -879,11 +881,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
index 7fea23f989..4d32562157 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -83,7 +85,7 @@ public ElectricAdmittance(double value, ElectricAdmittanceUnit unit)
/// No unit was found for the given .
public ElectricAdmittance(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -206,7 +208,7 @@ public static string GetAbbreviation(ElectricAdmittanceUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricAdmittanceUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricAdmittanceUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -317,7 +319,7 @@ public static ElectricAdmittance Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricAdmittance Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricAdmittance Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -333,7 +335,7 @@ public static ElectricAdmittance Parse(string str, [CanBeNull] IFormatProvider p
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricAdmittance result)
+ public static bool TryParse(string? str, out ElectricAdmittance result)
{
return TryParse(str, null, out result);
}
@@ -348,7 +350,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricAdmittance resul
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricAdmittance result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricAdmittance result)
{
return QuantityParser.Default.TryParse(
str,
@@ -381,7 +383,7 @@ public static ElectricAdmittanceUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricAdmittanceUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricAdmittanceUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -402,7 +404,7 @@ public static bool TryParseUnit(string str, out ElectricAdmittanceUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricAdmittanceUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricAdmittanceUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -607,7 +609,7 @@ public double As(ElectricAdmittanceUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -650,7 +652,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricAdmittance ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -736,7 +738,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -748,7 +750,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -763,7 +765,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -791,11 +793,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
index 9d06a5e7f1..d441ab525e 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -87,7 +89,7 @@ public ElectricCharge(double value, ElectricChargeUnit unit)
/// No unit was found for the given .
public ElectricCharge(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -215,7 +217,7 @@ public static string GetAbbreviation(ElectricChargeUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricChargeUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricChargeUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -335,7 +337,7 @@ public static ElectricCharge Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricCharge Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricCharge Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -351,7 +353,7 @@ public static ElectricCharge Parse(string str, [CanBeNull] IFormatProvider provi
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricCharge result)
+ public static bool TryParse(string? str, out ElectricCharge result)
{
return TryParse(str, null, out result);
}
@@ -366,7 +368,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricCharge result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricCharge result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCharge result)
{
return QuantityParser.Default.TryParse(
str,
@@ -399,7 +401,7 @@ public static ElectricChargeUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricChargeUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricChargeUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -420,7 +422,7 @@ public static bool TryParseUnit(string str, out ElectricChargeUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricChargeUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricChargeUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -625,7 +627,7 @@ public double As(ElectricChargeUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -668,7 +670,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricCharge ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -756,7 +758,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -768,7 +770,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -783,7 +785,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -811,11 +813,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
index 84babf87b7..7eee888c9e 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -83,7 +85,7 @@ public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit)
/// No unit was found for the given .
public ElectricChargeDensity(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -191,7 +193,7 @@ public static string GetAbbreviation(ElectricChargeDensityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricChargeDensityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricChargeDensityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -275,7 +277,7 @@ public static ElectricChargeDensity Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricChargeDensity Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricChargeDensity Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -291,7 +293,7 @@ public static ElectricChargeDensity Parse(string str, [CanBeNull] IFormatProvide
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricChargeDensity result)
+ public static bool TryParse(string? str, out ElectricChargeDensity result)
{
return TryParse(str, null, out result);
}
@@ -306,7 +308,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricChargeDensity re
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricChargeDensity result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricChargeDensity result)
{
return QuantityParser.Default.TryParse(
str,
@@ -339,7 +341,7 @@ public static ElectricChargeDensityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricChargeDensityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricChargeDensityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -360,7 +362,7 @@ public static bool TryParseUnit(string str, out ElectricChargeDensityUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricChargeDensityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricChargeDensityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -565,7 +567,7 @@ public double As(ElectricChargeDensityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -608,7 +610,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricChargeDensity ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -688,7 +690,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -700,7 +702,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -715,7 +717,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -743,11 +745,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
index 0dffcbc32b..9057adb96e 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -85,7 +87,7 @@ public ElectricConductance(double value, ElectricConductanceUnit unit)
/// No unit was found for the given .
public ElectricConductance(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -203,7 +205,7 @@ public static string GetAbbreviation(ElectricConductanceUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricConductanceUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricConductanceUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -305,7 +307,7 @@ public static ElectricConductance Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricConductance Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricConductance Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -321,7 +323,7 @@ public static ElectricConductance Parse(string str, [CanBeNull] IFormatProvider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricConductance result)
+ public static bool TryParse(string? str, out ElectricConductance result)
{
return TryParse(str, null, out result);
}
@@ -336,7 +338,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricConductance resu
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricConductance result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductance result)
{
return QuantityParser.Default.TryParse(
str,
@@ -369,7 +371,7 @@ public static ElectricConductanceUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricConductanceUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricConductanceUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -390,7 +392,7 @@ public static bool TryParseUnit(string str, out ElectricConductanceUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricConductanceUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricConductanceUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -595,7 +597,7 @@ public double As(ElectricConductanceUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -638,7 +640,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricConductance ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -722,7 +724,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -734,7 +736,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -749,7 +751,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -777,11 +779,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
index c3ed929ce6..d55f01f9c8 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -85,7 +87,7 @@ public ElectricConductivity(double value, ElectricConductivityUnit unit)
/// No unit was found for the given .
public ElectricConductivity(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -203,7 +205,7 @@ public static string GetAbbreviation(ElectricConductivityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricConductivityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricConductivityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -305,7 +307,7 @@ public static ElectricConductivity Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricConductivity Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricConductivity Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -321,7 +323,7 @@ public static ElectricConductivity Parse(string str, [CanBeNull] IFormatProvider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricConductivity result)
+ public static bool TryParse(string? str, out ElectricConductivity result)
{
return TryParse(str, null, out result);
}
@@ -336,7 +338,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricConductivity res
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricConductivity result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductivity result)
{
return QuantityParser.Default.TryParse(
str,
@@ -369,7 +371,7 @@ public static ElectricConductivityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricConductivityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricConductivityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -390,7 +392,7 @@ public static bool TryParseUnit(string str, out ElectricConductivityUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricConductivityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricConductivityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -595,7 +597,7 @@ public double As(ElectricConductivityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -638,7 +640,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricConductivity ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -722,7 +724,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -734,7 +736,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -749,7 +751,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -777,11 +779,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
index 13726a1360..23877d8b2b 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -87,7 +89,7 @@ public ElectricCurrent(double value, ElectricCurrentUnit unit)
/// No unit was found for the given .
public ElectricCurrent(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -230,7 +232,7 @@ public static string GetAbbreviation(ElectricCurrentUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricCurrentUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricCurrentUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -377,7 +379,7 @@ public static ElectricCurrent Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricCurrent Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricCurrent Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -393,7 +395,7 @@ public static ElectricCurrent Parse(string str, [CanBeNull] IFormatProvider prov
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricCurrent result)
+ public static bool TryParse(string? str, out ElectricCurrent result)
{
return TryParse(str, null, out result);
}
@@ -408,7 +410,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricCurrent result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricCurrent result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrent result)
{
return QuantityParser.Default.TryParse(
str,
@@ -441,7 +443,7 @@ public static ElectricCurrentUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricCurrentUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricCurrentUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -462,7 +464,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricCurrentUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -667,7 +669,7 @@ public double As(ElectricCurrentUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -710,7 +712,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricCurrent ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -804,7 +806,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -816,7 +818,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -831,7 +833,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -859,11 +861,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
index 40b235fe08..25fbd5bc4c 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -85,7 +87,7 @@ public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit)
/// No unit was found for the given .
public ElectricCurrentDensity(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -203,7 +205,7 @@ public static string GetAbbreviation(ElectricCurrentDensityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricCurrentDensityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricCurrentDensityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -305,7 +307,7 @@ public static ElectricCurrentDensity Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricCurrentDensity Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricCurrentDensity Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -321,7 +323,7 @@ public static ElectricCurrentDensity Parse(string str, [CanBeNull] IFormatProvid
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricCurrentDensity result)
+ public static bool TryParse(string? str, out ElectricCurrentDensity result)
{
return TryParse(str, null, out result);
}
@@ -336,7 +338,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricCurrentDensity r
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricCurrentDensity result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentDensity result)
{
return QuantityParser.Default.TryParse(
str,
@@ -369,7 +371,7 @@ public static ElectricCurrentDensityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricCurrentDensityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricCurrentDensityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -390,7 +392,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentDensityUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricCurrentDensityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentDensityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -595,7 +597,7 @@ public double As(ElectricCurrentDensityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -638,7 +640,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricCurrentDensity ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -722,7 +724,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -734,7 +736,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -749,7 +751,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -777,11 +779,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
index c5366cb423..e76eaeaa5c 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -80,7 +82,7 @@ public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit)
/// No unit was found for the given .
public ElectricCurrentGradient(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -188,7 +190,7 @@ public static string GetAbbreviation(ElectricCurrentGradientUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricCurrentGradientUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricCurrentGradientUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -272,7 +274,7 @@ public static ElectricCurrentGradient Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricCurrentGradient Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricCurrentGradient Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -288,7 +290,7 @@ public static ElectricCurrentGradient Parse(string str, [CanBeNull] IFormatProvi
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricCurrentGradient result)
+ public static bool TryParse(string? str, out ElectricCurrentGradient result)
{
return TryParse(str, null, out result);
}
@@ -303,7 +305,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricCurrentGradient
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricCurrentGradient result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentGradient result)
{
return QuantityParser.Default.TryParse(
str,
@@ -336,7 +338,7 @@ public static ElectricCurrentGradientUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricCurrentGradientUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricCurrentGradientUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -357,7 +359,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentGradientUnit unit
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricCurrentGradientUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentGradientUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -562,7 +564,7 @@ public double As(ElectricCurrentGradientUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -605,7 +607,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricCurrentGradient ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -685,7 +687,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -697,7 +699,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -712,7 +714,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -740,11 +742,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
index 0a388a3fbc..9a611d2ece 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -83,7 +85,7 @@ public ElectricField(double value, ElectricFieldUnit unit)
/// No unit was found for the given .
public ElectricField(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -191,7 +193,7 @@ public static string GetAbbreviation(ElectricFieldUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricFieldUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricFieldUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -275,7 +277,7 @@ public static ElectricField Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricField Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricField Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -291,7 +293,7 @@ public static ElectricField Parse(string str, [CanBeNull] IFormatProvider provid
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricField result)
+ public static bool TryParse(string? str, out ElectricField result)
{
return TryParse(str, null, out result);
}
@@ -306,7 +308,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricField result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricField result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricField result)
{
return QuantityParser.Default.TryParse(
str,
@@ -339,7 +341,7 @@ public static ElectricFieldUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricFieldUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricFieldUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -360,7 +362,7 @@ public static bool TryParseUnit(string str, out ElectricFieldUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricFieldUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricFieldUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -565,7 +567,7 @@ public double As(ElectricFieldUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -608,7 +610,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricField ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -688,7 +690,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -700,7 +702,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -715,7 +717,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -743,11 +745,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
index 47282ca714..a35692e319 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -86,7 +88,7 @@ public ElectricInductance(double value, ElectricInductanceUnit unit)
/// No unit was found for the given .
public ElectricInductance(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -209,7 +211,7 @@ public static string GetAbbreviation(ElectricInductanceUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricInductanceUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricInductanceUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -320,7 +322,7 @@ public static ElectricInductance Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricInductance Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricInductance Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -336,7 +338,7 @@ public static ElectricInductance Parse(string str, [CanBeNull] IFormatProvider p
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricInductance result)
+ public static bool TryParse(string? str, out ElectricInductance result)
{
return TryParse(str, null, out result);
}
@@ -351,7 +353,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricInductance resul
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricInductance result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricInductance result)
{
return QuantityParser.Default.TryParse(
str,
@@ -384,7 +386,7 @@ public static ElectricInductanceUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricInductanceUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricInductanceUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -405,7 +407,7 @@ public static bool TryParseUnit(string str, out ElectricInductanceUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricInductanceUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricInductanceUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -610,7 +612,7 @@ public double As(ElectricInductanceUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -653,7 +655,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricInductance ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -739,7 +741,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -751,7 +753,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -766,7 +768,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -794,11 +796,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
index e1a6cccc54..7bbac7191b 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -84,7 +86,7 @@ public ElectricPotential(double value, ElectricPotentialUnit unit)
/// No unit was found for the given .
public ElectricPotential(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -212,7 +214,7 @@ public static string GetAbbreviation(ElectricPotentialUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricPotentialUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricPotentialUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -332,7 +334,7 @@ public static ElectricPotential Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricPotential Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotential Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -348,7 +350,7 @@ public static ElectricPotential Parse(string str, [CanBeNull] IFormatProvider pr
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricPotential result)
+ public static bool TryParse(string? str, out ElectricPotential result)
{
return TryParse(str, null, out result);
}
@@ -363,7 +365,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricPotential result
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricPotential result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotential result)
{
return QuantityParser.Default.TryParse(
str,
@@ -396,7 +398,7 @@ public static ElectricPotentialUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricPotentialUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotentialUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -417,7 +419,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricPotentialUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -622,7 +624,7 @@ public double As(ElectricPotentialUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -665,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricPotential ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -753,7 +755,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -765,7 +767,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -780,7 +782,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -808,11 +810,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
index 37892c41ef..652d9c8d04 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -84,7 +86,7 @@ public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit)
/// No unit was found for the given .
public ElectricPotentialAc(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -212,7 +214,7 @@ public static string GetAbbreviation(ElectricPotentialAcUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricPotentialAcUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricPotentialAcUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -332,7 +334,7 @@ public static ElectricPotentialAc Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricPotentialAc Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotentialAc Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -348,7 +350,7 @@ public static ElectricPotentialAc Parse(string str, [CanBeNull] IFormatProvider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricPotentialAc result)
+ public static bool TryParse(string? str, out ElectricPotentialAc result)
{
return TryParse(str, null, out result);
}
@@ -363,7 +365,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricPotentialAc resu
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricPotentialAc result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialAc result)
{
return QuantityParser.Default.TryParse(
str,
@@ -396,7 +398,7 @@ public static ElectricPotentialAcUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricPotentialAcUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotentialAcUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -417,7 +419,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialAcUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricPotentialAcUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialAcUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -622,7 +624,7 @@ public double As(ElectricPotentialAcUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -665,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricPotentialAc ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -753,7 +755,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -765,7 +767,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -780,7 +782,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -808,11 +810,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs
index 9dbe58e823..dc66e7a1aa 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -99,7 +101,7 @@ public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit
/// No unit was found for the given .
public ElectricPotentialChangeRate(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -302,7 +304,7 @@ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -557,7 +559,7 @@ public static ElectricPotentialChangeRate Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricPotentialChangeRate Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotentialChangeRate Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -573,7 +575,7 @@ public static ElectricPotentialChangeRate Parse(string str, [CanBeNull] IFormatP
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricPotentialChangeRate result)
+ public static bool TryParse(string? str, out ElectricPotentialChangeRate result)
{
return TryParse(str, null, out result);
}
@@ -588,7 +590,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricPotentialChangeR
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricPotentialChangeRate result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialChangeRate result)
{
return QuantityParser.Default.TryParse(
str,
@@ -621,7 +623,7 @@ public static ElectricPotentialChangeRateUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricPotentialChangeRateUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotentialChangeRateUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -642,7 +644,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialChangeRateUnit
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricPotentialChangeRateUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialChangeRateUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -847,7 +849,7 @@ public double As(ElectricPotentialChangeRateUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -890,7 +892,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -1008,7 +1010,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -1020,7 +1022,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -1035,7 +1037,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -1063,11 +1065,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
index dedbe936b8..e22e2c3ad7 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -84,7 +86,7 @@ public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit)
/// No unit was found for the given .
public ElectricPotentialDc(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -212,7 +214,7 @@ public static string GetAbbreviation(ElectricPotentialDcUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricPotentialDcUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricPotentialDcUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -332,7 +334,7 @@ public static ElectricPotentialDc Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricPotentialDc Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotentialDc Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -348,7 +350,7 @@ public static ElectricPotentialDc Parse(string str, [CanBeNull] IFormatProvider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricPotentialDc result)
+ public static bool TryParse(string? str, out ElectricPotentialDc result)
{
return TryParse(str, null, out result);
}
@@ -363,7 +365,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricPotentialDc resu
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricPotentialDc result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialDc result)
{
return QuantityParser.Default.TryParse(
str,
@@ -396,7 +398,7 @@ public static ElectricPotentialDcUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricPotentialDcUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricPotentialDcUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -417,7 +419,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialDcUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricPotentialDcUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialDcUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -622,7 +624,7 @@ public double As(ElectricPotentialDcUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -665,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricPotentialDc ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -753,7 +755,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -765,7 +767,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -780,7 +782,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -808,11 +810,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
index 8c96c4745e..83f7f5476d 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -84,7 +86,7 @@ public ElectricResistance(double value, ElectricResistanceUnit unit)
/// No unit was found for the given .
public ElectricResistance(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -212,7 +214,7 @@ public static string GetAbbreviation(ElectricResistanceUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricResistanceUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricResistanceUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -332,7 +334,7 @@ public static ElectricResistance Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricResistance Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricResistance Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -348,7 +350,7 @@ public static ElectricResistance Parse(string str, [CanBeNull] IFormatProvider p
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricResistance result)
+ public static bool TryParse(string? str, out ElectricResistance result)
{
return TryParse(str, null, out result);
}
@@ -363,7 +365,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricResistance resul
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricResistance result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistance result)
{
return QuantityParser.Default.TryParse(
str,
@@ -396,7 +398,7 @@ public static ElectricResistanceUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricResistanceUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricResistanceUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -417,7 +419,7 @@ public static bool TryParseUnit(string str, out ElectricResistanceUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricResistanceUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricResistanceUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -622,7 +624,7 @@ public double As(ElectricResistanceUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -665,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricResistance ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -753,7 +755,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -765,7 +767,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -780,7 +782,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -808,11 +810,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
index b6a6f1427f..41d0b2791d 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -96,7 +98,7 @@ public ElectricResistivity(double value, ElectricResistivityUnit unit)
/// No unit was found for the given .
public ElectricResistivity(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -269,7 +271,7 @@ public static string GetAbbreviation(ElectricResistivityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricResistivityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricResistivityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -470,7 +472,7 @@ public static ElectricResistivity Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricResistivity Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricResistivity Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -486,7 +488,7 @@ public static ElectricResistivity Parse(string str, [CanBeNull] IFormatProvider
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricResistivity result)
+ public static bool TryParse(string? str, out ElectricResistivity result)
{
return TryParse(str, null, out result);
}
@@ -501,7 +503,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricResistivity resu
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricResistivity result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistivity result)
{
return QuantityParser.Default.TryParse(
str,
@@ -534,7 +536,7 @@ public static ElectricResistivityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricResistivityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricResistivityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -555,7 +557,7 @@ public static bool TryParseUnit(string str, out ElectricResistivityUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricResistivityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricResistivityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -760,7 +762,7 @@ public double As(ElectricResistivityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -803,7 +805,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricResistivity ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -909,7 +911,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -921,7 +923,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -936,7 +938,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -964,11 +966,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs
index d8332d038a..98ce454741 100644
--- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -85,7 +87,7 @@ public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUn
/// No unit was found for the given .
public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -203,7 +205,7 @@ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -305,7 +307,7 @@ public static ElectricSurfaceChargeDensity Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ElectricSurfaceChargeDensity Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricSurfaceChargeDensity Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -321,7 +323,7 @@ public static ElectricSurfaceChargeDensity Parse(string str, [CanBeNull] IFormat
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ElectricSurfaceChargeDensity result)
+ public static bool TryParse(string? str, out ElectricSurfaceChargeDensity result)
{
return TryParse(str, null, out result);
}
@@ -336,7 +338,7 @@ public static bool TryParse([CanBeNull] string str, out ElectricSurfaceChargeDen
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ElectricSurfaceChargeDensity result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ElectricSurfaceChargeDensity result)
{
return QuantityParser.Default.TryParse(
str,
@@ -369,7 +371,7 @@ public static ElectricSurfaceChargeDensityUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ElectricSurfaceChargeDensityUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ElectricSurfaceChargeDensityUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -390,7 +392,7 @@ public static bool TryParseUnit(string str, out ElectricSurfaceChargeDensityUnit
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ElectricSurfaceChargeDensityUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricSurfaceChargeDensityUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -595,7 +597,7 @@ public double As(ElectricSurfaceChargeDensityUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -638,7 +640,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -722,7 +724,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -734,7 +736,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -749,7 +751,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -777,11 +779,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
index 9977662665..eb59bdee80 100644
--- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -114,7 +116,7 @@ public Energy(double value, EnergyUnit unit)
/// No unit was found for the given .
public Energy(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -392,7 +394,7 @@ public static string GetAbbreviation(EnergyUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(EnergyUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(EnergyUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -782,7 +784,7 @@ public static Energy Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Energy Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Energy Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -798,7 +800,7 @@ public static Energy Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Energy result)
+ public static bool TryParse(string? str, out Energy result)
{
return TryParse(str, null, out result);
}
@@ -813,7 +815,7 @@ public static bool TryParse([CanBeNull] string str, out Energy result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Energy result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Energy result)
{
return QuantityParser.Default.TryParse(
str,
@@ -846,7 +848,7 @@ public static EnergyUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static EnergyUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static EnergyUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -867,7 +869,7 @@ public static bool TryParseUnit(string str, out EnergyUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out EnergyUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out EnergyUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -1072,7 +1074,7 @@ public double As(EnergyUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -1115,7 +1117,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Energy ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -1263,7 +1265,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -1275,7 +1277,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -1290,7 +1292,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -1318,11 +1320,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
index c787d63860..4d22327766 100644
--- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -86,7 +88,7 @@ public Entropy(double value, EntropyUnit unit)
/// No unit was found for the given .
public Entropy(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -224,7 +226,7 @@ public static string GetAbbreviation(EntropyUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(EntropyUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(EntropyUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -362,7 +364,7 @@ public static Entropy Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Entropy Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Entropy Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -378,7 +380,7 @@ public static Entropy Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Entropy result)
+ public static bool TryParse(string? str, out Entropy result)
{
return TryParse(str, null, out result);
}
@@ -393,7 +395,7 @@ public static bool TryParse([CanBeNull] string str, out Entropy result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Entropy result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Entropy result)
{
return QuantityParser.Default.TryParse(
str,
@@ -426,7 +428,7 @@ public static EntropyUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static EntropyUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static EntropyUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -447,7 +449,7 @@ public static bool TryParseUnit(string str, out EntropyUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out EntropyUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out EntropyUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -652,7 +654,7 @@ public double As(EntropyUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -695,7 +697,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Entropy ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -787,7 +789,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -799,7 +801,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -814,7 +816,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -842,11 +844,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs
index 98be579b24..4ae5d7bb02 100644
--- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -93,7 +95,7 @@ public Force(double value, ForceUnit unit)
/// No unit was found for the given .
public Force(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -266,7 +268,7 @@ public static string GetAbbreviation(ForceUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ForceUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ForceUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -467,7 +469,7 @@ public static Force Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Force Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Force Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -483,7 +485,7 @@ public static Force Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Force result)
+ public static bool TryParse(string? str, out Force result)
{
return TryParse(str, null, out result);
}
@@ -498,7 +500,7 @@ public static bool TryParse([CanBeNull] string str, out Force result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Force result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Force result)
{
return QuantityParser.Default.TryParse(
str,
@@ -531,7 +533,7 @@ public static ForceUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ForceUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ForceUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -552,7 +554,7 @@ public static bool TryParseUnit(string str, out ForceUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ForceUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ForceUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -757,7 +759,7 @@ public double As(ForceUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -800,7 +802,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public Force ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -906,7 +908,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -918,7 +920,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -933,7 +935,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -961,11 +963,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
index 1d5bf52173..6b0737e640 100644
--- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -90,7 +92,7 @@ public ForceChangeRate(double value, ForceChangeRateUnit unit)
/// No unit was found for the given .
public ForceChangeRate(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -248,7 +250,7 @@ public static string GetAbbreviation(ForceChangeRateUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ForceChangeRateUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ForceChangeRateUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -422,7 +424,7 @@ public static ForceChangeRate Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ForceChangeRate Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ForceChangeRate Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -438,7 +440,7 @@ public static ForceChangeRate Parse(string str, [CanBeNull] IFormatProvider prov
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ForceChangeRate result)
+ public static bool TryParse(string? str, out ForceChangeRate result)
{
return TryParse(str, null, out result);
}
@@ -453,7 +455,7 @@ public static bool TryParse([CanBeNull] string str, out ForceChangeRate result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ForceChangeRate result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ForceChangeRate result)
{
return QuantityParser.Default.TryParse(
str,
@@ -486,7 +488,7 @@ public static ForceChangeRateUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ForceChangeRateUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ForceChangeRateUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -507,7 +509,7 @@ public static bool TryParseUnit(string str, out ForceChangeRateUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ForceChangeRateUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ForceChangeRateUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -712,7 +714,7 @@ public double As(ForceChangeRateUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -755,7 +757,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ForceChangeRate ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -855,7 +857,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -867,7 +869,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -882,7 +884,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -910,11 +912,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
index e0f342908e..ad2286a663 100644
--- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -102,7 +104,7 @@ public ForcePerLength(double value, ForcePerLengthUnit unit)
/// No unit was found for the given .
public ForcePerLength(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -320,7 +322,7 @@ public static string GetAbbreviation(ForcePerLengthUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(ForcePerLengthUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(ForcePerLengthUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -602,7 +604,7 @@ public static ForcePerLength Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static ForcePerLength Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static ForcePerLength Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -618,7 +620,7 @@ public static ForcePerLength Parse(string str, [CanBeNull] IFormatProvider provi
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out ForcePerLength result)
+ public static bool TryParse(string? str, out ForcePerLength result)
{
return TryParse(str, null, out result);
}
@@ -633,7 +635,7 @@ public static bool TryParse([CanBeNull] string str, out ForcePerLength result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out ForcePerLength result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out ForcePerLength result)
{
return QuantityParser.Default.TryParse(
str,
@@ -666,7 +668,7 @@ public static ForcePerLengthUnit ParseUnit(string str)
///
/// The value of 'str' cannot be null.
/// Error parsing string.
- public static ForcePerLengthUnit ParseUnit(string str, [CanBeNull] IFormatProvider provider)
+ public static ForcePerLengthUnit ParseUnit(string str, IFormatProvider? provider)
{
return UnitParser.Default.Parse(str, provider);
}
@@ -687,7 +689,7 @@ public static bool TryParseUnit(string str, out ForcePerLengthUnit unit)
/// Length.TryParseUnit("m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParseUnit(string str, IFormatProvider provider, out ForcePerLengthUnit unit)
+ public static bool TryParseUnit(string str, IFormatProvider? provider, out ForcePerLengthUnit unit)
{
return UnitParser.Default.TryParse(str, provider, out unit);
}
@@ -892,7 +894,7 @@ public double As(ForcePerLengthUnit unit)
///
public double As(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -935,7 +937,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
///
public ForcePerLength ToUnit(UnitSystem unitSystem)
{
- if(unitSystem == null)
+ if(unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
@@ -1059,7 +1061,7 @@ public override string ToString()
///
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
- public string ToString([CanBeNull] IFormatProvider provider)
+ public string ToString(IFormatProvider? provider)
{
return ToString("g", provider);
}
@@ -1071,7 +1073,7 @@ public string ToString([CanBeNull] IFormatProvider provider)
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")]
- public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix)
+ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix)
{
var value = Convert.ToDouble(Value);
var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix);
@@ -1086,7 +1088,7 @@ public string ToString([CanBeNull] IFormatProvider provider, int significantDigi
/// String representation.
/// Format to use for localization and number formatting. Defaults to if null.
[Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")]
- public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args)
+ public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args)
{
if (format == null) throw new ArgumentNullException(nameof(format));
if (args == null) throw new ArgumentNullException(nameof(args));
@@ -1114,11 +1116,11 @@ public string ToString(string format)
/// Gets the string representation of this instance in the specified format string using the specified format provider, or if null.
///
/// The format string.
- /// Format to use for localization and number formatting. Defaults to if null.
+ /// Format to use for localization and number formatting. Defaults to if null.
/// The string representation.
- public string ToString(string format, IFormatProvider formatProvider)
+ public string ToString(string format, IFormatProvider? provider)
{
- return QuantityFormatter.Format(this, format, formatProvider);
+ return QuantityFormatter.Format(this, format, provider);
}
#endregion
diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
index 3965121cac..665f183951 100644
--- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs
@@ -24,6 +24,8 @@
using UnitsNet.InternalHelpers;
using UnitsNet.Units;
+#nullable enable
+
// ReSharper disable once CheckNamespace
namespace UnitsNet
@@ -89,7 +91,7 @@ public Frequency(double value, FrequencyUnit unit)
/// No unit was found for the given .
public Frequency(double value, UnitSystem unitSystem)
{
- if(unitSystem == null) throw new ArgumentNullException(nameof(unitSystem));
+ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -242,7 +244,7 @@ public static string GetAbbreviation(FrequencyUnit unit)
/// Unit to get abbreviation for.
/// Unit abbreviation string.
/// Format to use for localization. Defaults to if null.
- public static string GetAbbreviation(FrequencyUnit unit, [CanBeNull] IFormatProvider provider)
+ public static string GetAbbreviation(FrequencyUnit unit, IFormatProvider? provider)
{
return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider);
}
@@ -407,7 +409,7 @@ public static Frequency Parse(string str)
/// Units.NET exceptions from other exceptions.
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static Frequency Parse(string str, [CanBeNull] IFormatProvider provider)
+ public static Frequency Parse(string str, IFormatProvider? provider)
{
return QuantityParser.Default.Parse(
str,
@@ -423,7 +425,7 @@ public static Frequency Parse(string str, [CanBeNull] IFormatProvider provider)
///
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
- public static bool TryParse([CanBeNull] string str, out Frequency result)
+ public static bool TryParse(string? str, out Frequency result)
{
return TryParse(str, null, out result);
}
@@ -438,7 +440,7 @@ public static bool TryParse([CanBeNull] string str, out Frequency result)
/// Length.Parse("5.5 m", new CultureInfo("en-US"));
///
/// Format to use when parsing number and unit. Defaults to if null.
- public static bool TryParse([CanBeNull] string str, [CanBeNull] IFormatProvider provider, out Frequency result)
+ public static bool TryParse(string? str, IFormatProvider? provider, out Frequency result)
{
return QuantityParser.Default.TryParse(
str,
@@ -471,7 +473,7 @@ public static FrequencyUnit ParseUnit(string str)
///
///