It had to happen. I was counting the minutes, the seconds, the… I had my first feedback (positive or negative) for NMoneys. Yeah, it was sort of negative, but a failure never made me happier.
As a result, I made a quick fix of the issue, which is the 22.214.171.124 version.
When a default instance of
Money is created, as in:
The values of the fields/properties are initialized to their default values. In the case of the Amount, which if decimal type, it will be initialized to default(decimal) which is 0. In the case of
CurrencyIsoCode, being of a derivative of
System.Enum, anyone guesses what will be its
0 will be.
Is there any currency defined with the zero value?
No, there is not.
The type will be created but as soon as any of the features that make use of the Currency represented by its code (
.ToString()…) an exception will be thrown as no currency can be used for that code.
This behavior is a bit disturbing and not immediately obvious so I did something about it by releasing this fix. Now, default instances of
Money will have a no-currency
As always, try it and if you find something that can be improved, contribute to make NMoneys a better library.