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.IsAutoProperty as a public API #46682

Open
Evangelink opened this issue Aug 10, 2020 · 6 comments
Open

Expose IPropertySymbol.IsAutoProperty as a public API #46682

Evangelink opened this issue Aug 10, 2020 · 6 comments
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API.

Comments

@Evangelink
Copy link
Member

Can we file a Roslyn feature request to expose IPropertySymbol.IsAutoProperty as a public API?

Originally posted by @mavasani in dotnet/roslyn-analyzers#3884

@RikkiGibson
Copy link
Contributor

RikkiGibson commented Aug 10, 2020

We don't typically expose source-only concepts in symbol APIs. For example, symbols do not have a public IsNew property. This is a similar situation--it might be reasonable for someone else to introduce an extension method IPropertySymbol.IsAutoProperty but I do not think Roslyn would ship such a method.

wondering what you think @jaredpar @333fred.

@CyrusNajmabadi
Copy link
Member

I believe @jnm2 had a good solution here in one of his PRs. SPeciifcally, IPropertySymbol can expose an 'associated symbol' (in this case, the backing field).

This would be highly desirable in many scenarios for the IDE. Right now we do the reverse. We go find all fields in teh type and see if they point at the property. Having the reverse already there makes this much simpler and clearer. This would then answer the .IsAutoProp question.

@CyrusNajmabadi
Copy link
Member

@jnm2 Do you have that PR somewhere? I'd be happy to push it along.

@jnm2
Copy link
Contributor

jnm2 commented Aug 10, 2020

@CyrusNajmabadi It was basically this commit: 83ecbec which was going to be extracted from #44932 and done on its own. And then the same for event symbols. I'll try to do that sometime soon.

Existing issues:
#42355 (IPropertySymbol.AssociatedField)
#40103 (IEventSymbol.AssociatedField)

@jnm2
Copy link
Contributor

jnm2 commented Aug 10, 2020

One thing I noticed that came up a lot internally to Roslyn features was the concept of taking an ISymbol and wanting to obtain an IFieldSymbol, treating the original symbol equally whether it is a field or whether it has an associated field. Some sort of API like that would certainly be nice to enable asking generalized questions about where the state of an object is held.

@jinujoseph jinujoseph added Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. labels Aug 13, 2020
@jnm2
Copy link
Contributor

jnm2 commented Nov 29, 2020

Do you have that PR somewhere? I'd be happy to push it along.

@CyrusNajmabadi I finally got it up: #49659

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

No branches or pull requests

5 participants