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 IEventSymbol.AssociatedField #40103

Open
JohanLarsson opened this issue Dec 3, 2019 · 3 comments
Open

Expose IEventSymbol.AssociatedField #40103

JohanLarsson opened this issue Dec 3, 2019 · 3 comments
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API.
Milestone

Comments

@JohanLarsson
Copy link

public class C
{
    public event EventHandler E;
}

Given ^ type.GetMebres() does not return the backing field of the event. See #36259

And IEventSymbol does not expose AssociatedField

Is there a way to get the field for a third party analyzer?

@RikkiGibson RikkiGibson added Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. labels Dec 4, 2019
@jaredpar jaredpar added this to the Backlog milestone Dec 14, 2019
@jnm2
Copy link
Contributor

jnm2 commented Dec 26, 2019

Use case: DotNetAnalyzers/ReflectionAnalyzers#206

@gafter
Copy link
Member

gafter commented Mar 12, 2020

We currently treat auto-properties and field-like events differently: for the former we have a field in the set of members, and for the latter we do not. I think this is an artifact of the history of the compiler rather than an explicit design choice. In both cases the language specification explicitly calls out the existence of an underlying field.

@jnm2
Copy link
Contributor

jnm2 commented Mar 12, 2020

@gafter Right now with events, third-party analyzers are out to dry. There is no Roslyn API to show the existence of an event backing field.

@CyrusNajmabadi makes the point in #42355 (comment) that such a public API would be desirable even if there was currently another way to access the info. In the case of events, there is no current way to access backing field info.

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants