Version 2.1.2 breaks auto-property constructor initialization
See original GitHub issueHi, when I updated to version 2.1.2 our entire application broke because as it turned out, during the IL weaving the auto-property initialization in the constructor have been replaced by direct backing-filed assignments.Here is a short example code.
public class Model {
public int Something { get; set; }
public Model() {
Something = 1;
}
}
In the generated assembly the Something = 1
property assignment is turned into assigning the value 1
to the corresponding backing field.
Reverting to 1.53.0 the problem is gone.
Is this behavior by design? If so, I couldn’t find any notes anywhere about such a breaking change.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
c# - Auto-Property Initializes vs Constructor ...
It seems that the Auto-property initializer will be the first to be invoked, and then, the constructor. I made a small demo with...
Read more >Constructors and member initializer lists
The member initializer list is the place where non-default initialization of these objects can be specified. For bases and non-static data ...
Read more >“How-to” Guides
2.1.2. Automatic Property Expansion Using Gradle. You can automatically expand properties from the Gradle project by configuring the Java ...
Read more >TypeScript: Documentation - Classes
A field declaration creates a public writeable property on a class: ... let , and var , the initializer of a class property...
Read more >Object orientation
Constructors are special methods used to initialize an object with a specific state. As with normal methods, it is possible for a class...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@SimonCropp then please re-open #220.
#264 will now have the old behavior as default; suppressing property changes from within the constructor can be controlled by the new
NotifyAutoPropertiesInConstructorAttribute