Skip to content

Conversation

tmilnthorp
Copy link
Collaborator

@tmilnthorp tmilnthorp commented Feb 27, 2019

IQuantity and QuantityInfo negates the need for a lot of reflection 👍

UnitConverter no longer needs reflection due to IQuantity and QuantityInfo.
Reflection no longer needed in UnitsNetJsonConverter due to IQuantity and QuantityInfo
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I love the new code and getting rid of all that reflection crap.

@@ -77,13 +77,6 @@ public void ConvertByAbbreviation_ConvertsTheValueToGivenUnit(double expectedVal
Assert.Equal(expectedValue, UnitConverter.ConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit));
}

[Theory]
[InlineData(1, "UnknownQuantity", "m", "cm")]
public void ConvertByAbbreviation_ThrowsQuantityNotFoundExceptionOnUnknownQuantity(double inputValue, string quantityTypeName, string fromUnit, string toUnit)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why was this test case removed? Is it no longer relevant/valid?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see further down why, but I think we can keep the test case and test for UnitNotFoundException instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails because it doesn't throw it any more 😃 Code is unnecessary.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But.. I honestly don't know what result to expect when calling this method with these arguments? What results are we getting if not exception?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will also give UnitNotFoundException. I'll add it back and catch that.

Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some follow-up comments.

PR suggestions
Updating doc

return Quantity.From(value, unitValue);
}

private static object TryDeserializeIComparable(JsonReader reader, JsonSerializer serializer)
{
var token = JToken.Load(reader);
JToken token = JToken.Load(reader);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you reverted all the types back. That's fine, although I only meant for the few places where the exact type wasn't obvious to have explicit types.

@angularsen angularsen merged commit e3d84e5 into angularsen:master Feb 28, 2019
@angularsen
Copy link
Owner

Very nice 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants