You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like initially PartialDefinitionPart and PartialImplementationPart are created with their own unique backing field symbols. After the parts are merged, ContainingType.GetMembers() contains PartialDefinitionPart.BackingField and PartialImplementationPart.BackingField is adjusted to point to that field symbolas well. The field symbol originally created for PartialImplementationPart is not among ContainingType.GetMembers(), but if the implementation part has an initializer, corresponding bound field initializer refers to that field, rather than to the PartialDefinitionPart.BackingField. Also, it is very likely that PartialDefinitionPart.BackingField.HasInitializer is set to false. Emitted code for a simple scenario looks correct, likely due to the fact that the fields share the same name. However, the internal compiler data structures look inconsistent, which potentially might cause observable problems in some scenarios.
Another aspect is the FieldSymbol.AssociatedSymbol's behavior. Is it supposed to return PartialDefinitionPart or PartialImplementationPart? Whatever the answer is, it feels inappropriate for the other part to return the same field symbol from BackingField.
The text was updated successfully, but these errors were encountered:
A workaround for the inconsistency is added to #76871, otherwise several tests in PartialPropertiesTests and FieldKeywordTests were asserting in AssertMemberExposure.
It looks like initially PartialDefinitionPart and PartialImplementationPart are created with their own unique backing field symbols. After the parts are merged,
ContainingType.GetMembers()
containsPartialDefinitionPart.BackingField
andPartialImplementationPart.BackingField
is adjusted to point to that field symbolas well. The field symbol originally created for PartialImplementationPart is not amongContainingType.GetMembers()
, but if the implementation part has an initializer, corresponding bound field initializer refers to that field, rather than to thePartialDefinitionPart.BackingField
. Also, it is very likely thatPartialDefinitionPart.BackingField.HasInitializer
is set to false. Emitted code for a simple scenario looks correct, likely due to the fact that the fields share the same name. However, the internal compiler data structures look inconsistent, which potentially might cause observable problems in some scenarios.Another aspect is the
FieldSymbol.AssociatedSymbol
's behavior. Is it supposed to returnPartialDefinitionPart
orPartialImplementationPart
? Whatever the answer is, it feels inappropriate for the other part to return the same field symbol fromBackingField
.The text was updated successfully, but these errors were encountered: