-
Notifications
You must be signed in to change notification settings - Fork 397
Remove reflection #618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove reflection #618
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
|
||
return Quantity.From(value, unitValue); | ||
} | ||
|
||
private static object TryDeserializeIComparable(JsonReader reader, JsonSerializer serializer) | ||
{ | ||
var token = JToken.Load(reader); | ||
JToken token = JToken.Load(reader); |
There was a problem hiding this comment.
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.
Very nice 🎉 |
IQuantity and QuantityInfo negates the need for a lot of reflection 👍