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

Finish removing backing fields from GetMembers #44932

Closed

Conversation

jnm2
Copy link
Contributor

@jnm2 jnm2 commented Jun 7, 2020

Fixes #42355.

This is also an essential building block in the prototype for the field backing field access keyword being discussed for potential inclusion in a future version of C#. master...jnm2:prototypes/backing_field_access

For previous context, also see #40572 (comment). This is work that the Roslyn team had wanted to do at some point.

Asked for by @CyrusNajmabadi

@@ -90,7 +90,7 @@ private static void StructDependsClosure(NamedTypeSymbol type, HashSet<Symbol> p
{
foreach (var member in type.GetMembersUnordered())
{
var field = member as FieldSymbol;
var field = member as FieldSymbol ?? (member as PropertySymbol)?.AssociatedField;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why weren't event backing fields already considered here?

@@ -17,6 +17,8 @@ public SourceOrRecordPropertySymbol(Location location)

internal abstract SynthesizedBackingFieldSymbol BackingField { get; }

internal sealed override FieldSymbol AssociatedField => BackingField;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new BackingField property was added in master in the meantime. Perhaps IPropertySymbol.BackingField should be the name instead of AssociatedField?

Comment on lines +97 to +98
// TODO: event backing fields
return member as IFieldSymbol ?? (member as IPropertySymbol)?.AssociatedField;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's a test hole here as well that would require IEventSymbol.AssociatedField to be exposed.

Comment on lines +27 to +28
// TODO: This probably indicates a problem because event backing fields have not been in GetMembers() for a
// long time. Compare to the changes that were necessary in PropertySymbolReferenceFinder.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an existing 'find all references' test hole here that would require IEventSymbol.AssociatedField to be exposed.

Comment on lines 690 to 716
// TODO: Events?
#if CODE_STYLE
var fieldSymbol = member as IFieldSymbol;
#else
var fieldSymbol = member as IFieldSymbol ?? (member as IPropertySymbol)?.AssociatedField;
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's an existing test hole again that would require IEventSymbol.AssociatedField to be exposed.

@jnm2 jnm2 force-pushed the finish_removing_backing_fields_from_getmembers branch from b51cc92 to a4665c3 Compare June 7, 2020 21:08
@jnm2 jnm2 force-pushed the finish_removing_backing_fields_from_getmembers branch from a4665c3 to a44d7f8 Compare June 7, 2020 21:30
@jnm2
Copy link
Contributor Author

jnm2 commented Jun 8, 2020

Can you rerun the failing CI jobs? There is a single VB test in Microsoft.VisualStudio.LanguageServices failing in only one of the runs and it doesn't repro locally on x86 or x64.

@jinujoseph jinujoseph added Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Jun 10, 2020
@jnm2
Copy link
Contributor Author

jnm2 commented Jun 22, 2020

@CyrusNajmabadi asked me to split this PR and just add the API first since removing backing fields from GetMembers() is a behavioral breaking change. Take a look at a44d7f8 for a clear view of the impact of the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose IPropertySymbol.AssociatedField
2 participants