-
Notifications
You must be signed in to change notification settings - Fork 933
Support proxies of classes with init properties #3189
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
Conversation
@gliljas I think this fix is not entirely correct. For this entity the following proxy will be generated: [Serializable]
public class ClassWithInitProperties
{
public virtual int Id { get; init; }
public virtual string Name { get; init; }
}
[Serializable]
public class ClassWithInitPropertiesStaticProxy : ClassWithInitProperties
{
// this is incorrect code because
// error CS8080: Auto-implemented properties must override all accessors of the overridden property.
public override int Id { get; }
public override string Name { get; }
} While overriding I think the more correct solution would be to copy |
@fredericDelaporte this is a bug, actually. |
Also, if we decide to go ahead with 5.3.15 I would like the fix to be included there. |
This comment was marked as off-topic.
This comment was marked as off-topic.
00bf1b0
to
cde9982
Compare
While your version is quite possibly better, I'm not sure I agree with your assessment. The proxy doesn't get any auto-implemented properties, and isn't affected by CS8080. |
@gliljas yeah, you are correct and I need to sleep more:) |
Ok. Maybe we can treat |
Should I force push? Maybe add an exception to AsyncGenerator.yml? |
Would it work?
I think it is better to do as a separate PR with test cases specific to the improvement (eg check that method is not overriden). This way it would be easier to backport changes to 5.3.x should we wish it. |
I have classified it as New Feature because property But I do not mind if you rather see it as a bug fix. |
Why not. |
I'm somewhat at a loss as to what you want me to change, if anything. New PR with the same code? More tests? |
@gliljas if you want to not generate overrides for When implementing, please consider this interface as entity:
|
5.3 branch uses old AsyncGenerator - 0.18.4. So maca88/AsyncGenerator#168 fix needs to be backported to 0.18 version. Or to make things simpler - we can backport this PR without unit test. |
Using "init" properties in mapped classes works really well, e.g by using the BackingField access strategy.
However, when creating proxies of these classes, it currently fails with
System.TypeLoadException : Signature of the body and declaration in a method implementation do not match.
This is because the proxy generator thinks that the init "setter" is proxiable, which of course it isn't.
The implementation adds an IsExternalInit class, which is needed when supporting <NET5.