-
Notifications
You must be signed in to change notification settings - Fork 94
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
Consider emitting methods with SkipLocalsInitAttribute #595
Comments
There are a couple of scenarios to consider when outputting it. |
Do we only want to apply |
We can completely control the methods we emit to ensure they are safe. Structs we emit are expected to be initialized by the users, which are accustomed to .NET behavior of clearing memory for a new struct, so I do not think we should apply this attribute on structs. |
Is there any difference between placing |
From the docs. I actually had no idea. It does apply to all methods. It doesn't say it applied to the fields on the module though.
|
How could it apply to fields? It only affects the locals block of method bodies so that they are not locals-init blocks. |
I think you're right. I am not too familiar with the attribute yet so I probably added more confusion than clarity with my last comment. |
One other option here is to use |
The
LibraryImportAttribute
source generator emits code that applies SkipLocalsInitAttribute to each method. Perhaps we should too for perf reasons.The text was updated successfully, but these errors were encountered: