-
Notifications
You must be signed in to change notification settings - Fork 386
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
Readonly structs #1130
Comments
As far as I see, everything compiles with |
Sounds like a good improvement as long as it compiles for nestandard2.0. 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. #1135 |
Fixes #1130 https://docs.microsoft.com/en-us/dotnet/csharp/write-safe-efficient-code#declare-immutable-structs-as-readonly Force the compiler to check, that all fields are readonly as well.
@sonnemaf Sorry for the friction. You need to install Git LFS to clone the repo. LFS is nice when it works, but GitHub charges for it when monthly bandwidth exceeds a certain amount. |
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`.The text was updated successfully, but these errors were encountered: