-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Avoid compiler error when using init properties with BindingSourceGenerator #27655
Conversation
…erator Always emit a throwing setter func.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
isn't there anything diagnostic we can send at sourceGen time to avoid runtime exception ? |
This implementing the equivalent behaviour to get-only properties. If we wanted to emit diagnostics it should be for all the cases where the target property isn't writable and |
Yes, that's correct. Inspecting the binding mode is tricky because there are several options:
So we could do a best effort implementation that will produce a warning when it is clear that the binding mode is not compatible with the target property. Then there is also the option to just generate empty setters without throwing any exception when the property isn't writable. That might make it easier to adopt this feature. /cc @jkurdek |
that almost never happen, and we could warn on those cases |
Failing tests not related |
Always emit a throwing setter action for init properties.
Closes #27654