Skip to content

Commit

Permalink
Fix MeasurementUnit.TryParse
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyAkinshin committed Mar 11, 2024
1 parent d39e8a7 commit 8d829c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Perfolizer/Perfolizer/Metrology/MeasurementUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public string ToString(UnitPresentation? unitPresentation)

public static bool TryParse(string? s, out MeasurementUnit unit)
{
unit = NumberUnit.Instance;
if (s is { Length: 0 })
return true;

if (s != null && s.IsNotBlank())
foreach (var measurementUnit in GetAll())
{
Expand All @@ -55,7 +59,7 @@ public static bool TryParse(string? s, out MeasurementUnit unit)
return true;
}
}
unit = NumberUnit.Instance;

return false;
}

Expand Down

0 comments on commit 8d829c2

Please sign in to comment.