Skip to content
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

Expose IPropertySymbol.AssociatedField #42355

Closed
jnm2 opened this issue Mar 12, 2020 · 2 comments
Closed

Expose IPropertySymbol.AssociatedField #42355

jnm2 opened this issue Mar 12, 2020 · 2 comments
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request

Comments

@jnm2
Copy link
Contributor

jnm2 commented Mar 12, 2020

Same as #40103 which covers IEventSymbol.

The only way to detect the existence of the backing field from a third-party analyzer is to find the field in the parent ITypeSymbol.GetMembers() collection and check its AssociatedSymbol property. This means of locating backing fields would disappear if property backing fields (like event backing fields) were removed from ITypeSymbol.GetMembers().

The ability to remove all backing fields from ITypeSymbol.GetMembers() solves a binding cycle problem that is blocking one of the design options for dotnet/csharplang#140. If IPropertySymbol.AssociatedField was exposed, it would enable removing all backing fields from GetMembers() rather than just event backing fields. That would enable the preferred syntax for dotnet/csharplang#140.

/cc @CyrusNajmabadi

@CyrusNajmabadi
Copy link
Member

Note: ths is desirable no matter what. The current approach consumers need to take today to determine if a prop is an auto-prop is to iterate all fields, and see if any of htem have the prop as their AssociatedSymbol. This is really inefficient and unfortunate given that the data is already on the property itself.

@jnm2
Copy link
Contributor Author

jnm2 commented Apr 24, 2024

I'm far away from this use case. Feel free to reopen if folks come along with the same request.

@jnm2 jnm2 closed this as completed Apr 24, 2024
@jnm2 jnm2 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. Feature Request
Projects
None yet
4 participants