You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Money in constructor a typical dangerous thing is the conversion of decimal to Money as implicit, especially in a microservices world, you never know what currency is going to be based on the locale, so developers can make mistake passing a decimal where a money with currency is expected instead. I suggest providing configurability to exclude the op implicit on the constructor for money, or making it throw an exception when configured correctly (e.g. statically) .
or some other way of configuring this, else this requires for now this workaround solution
classMyClass{publicMyClass(Moneymoney){ ...}// this works or using a subclass of money where implicit is redefined also works, but it's not the easiest solutionpublicMyClass(decimalmoney){thrownew ArgumentException('do not allow implicitfor currency issues with locale');}}
The text was updated successfully, but these errors were encountered:
We've run into this problem too and would 100% prefer this to be configurable. To be honest I would prefer this to not be there at all, so that it would not even compile (or these being in a separate NuGet package, which is probably not possible and / or practical). Alternatively this could be solved by a Roslyn analyzer I guess.
When using Money in constructor a typical dangerous thing is the conversion of decimal to Money as implicit, especially in a microservices world, you never know what currency is going to be based on the locale, so developers can make mistake passing a decimal where a money with currency is expected instead. I suggest providing configurability to exclude the op implicit on the constructor for money, or making it throw an exception when configured correctly (e.g. statically) .
https://stackoverflow.com/questions/46190907/overriding-implicit-operators-in-c-sharp
maybe something like?
or some other way of configuring this, else this requires for now this workaround solution
The text was updated successfully, but these errors were encountered: