Closed andysturrock closed 8 years ago
LGTM.
Informative error messages are an important part of making this work well in practice. Ideally all missing field names would be included in the error message string. I'd envisaged creating a local of List<string>
, keeping it null
and lazily initialising it at the first mismatch. Then only when deserialisation is complete would the contents of this list be dumped out in the error. Easier to do this by calling a static StrictDeserialiserException.ThrowForMissingFields(IEnumerable<string>)
rather than coding all that logic in IL.
Also field names become case insensitive. There need to be more tests on the type ahead of time to verify that names match, there are no duplicates that differ only by case, and so on.
I've improved the exception message so that the test passes now. The test was actually incorrect as it had "Score" rather than "score" in the expected result, and the constructor arg is lowercase.
This is very interesting - takes me back to writing 8502 assembler on my Commodore 128 :-).