- Notifications
You must be signed in to change notification settings - Fork5.1k
Do not keep cctor for instance fields#96656
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedJan 9, 2024
Tagging subscribers to 'linkable-framework':@eerhardt,@vitek-karas,@LakshanF,@sbomer,@joperezr,@marek-safar Issue DetailsJust want to see if the tests pass. The ILLinker SLN files seem unusable for local testing because they miss projects.
|
Looks like this is ready to review. I half expected worms to come out of this can but the CI looks reasonable. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
hez2010 commentedJan 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Will this also affect the behaviour of cctors without beforefieldinit? newFoo().X=1;// this should print "1" as the cctor of Foo is not beforefieldinitclassFoo{staticFoo(){}// opt-out beforefieldinitpublicstaticBarbar=new();publicintX;}classBar{publicBar(){Console.WriteLine(1);}} I believe some applications rely on this behavior to do initialization. |
The instance constructor is responsible for triggering the cctor in your example. The instance field access (on non-null this pointer) assumes that the cctor was triggered when the instance was created. |
Uh oh!
There was an error while loading.Please reload this page.
Fixes#96655