UnitsNet
UnitsNet copied to clipboard
Readonly structs
Should/could the structs in this project be made readonly
. I think they should. All primitive struct types from Microsoft are readonly.
Readonly structs have a lot of advantages where there are no defensive copies for readonly fields
, in parameters
, 'readonly locals + returns`.
As far as I see, everything compiles with public readonly partial struct
as well.
Sounds like a good improvement as long as it compiles for nestandard2.0. These structs were intended to be immutable already.
Would you be interested in attempting a pull request @sonnemaf ?
Hi @angularsen
Good news but unfortunately I don't have time to implement it the next few weeks. Is it in a hurry? I will probably have time for it in october.
No rush on my end :-)
Hi,
I'm unable to clone the repository. I keep getting this error. Tried it on two computers.
I'm giving up. The change is really small. You only have to add the readonly text to the UnitsNet\CodeGen\Generators\UnitsNetGen\QuantityGenerator.cs on line 75, see screenshot below.
Can you do it yourself?
Regards,
Fons
There is already a PR for this. https://github.com/angularsen/UnitsNet/pull/1135 Currently the maintainer @angularsen seems to be unavailable.
@sonnemaf Sorry for the friction. You need to install Git LFS to clone the repo. https://git-lfs.github.com/
LFS is nice when it works, but GitHub charges for it when monthly bandwidth exceeds a certain amount. #1052 suggests downloading tooling binaries on-demand with an init script, instead of having it happen during checkout.