Skip to content

Use reference equality to compare model instances in EditContext (#1872) #18649

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

Merged
merged 1 commit into from
Feb 14, 2020

Conversation

pranavkm
Copy link
Contributor

  • Use reference equality to compare model instances in EditContext

Fixes #18069

Description

EditContext uses FieldIdentifiers for lookups. The equality and hashcode for FieldIdentifer attempts to compare instances of an application model, but uses the model's virtual Equals and GetHashCode methods. If a model overrides these methods, lookups will fail and you get incorrect validation results. This change uses the non-virtualized methods to compare model instances.

Customer impact

Models overriding Equals or GetHashCode cannot be used with a Blazor (server) application.

Regression

No. This behavior has been present since Blazor shipped in 3.0.

Risk

Low. There's a small chance that users may have inadvertently relied on the incorrect behavior and built their application around it. However, we don't commonly see the pattern of users overriding these methods. In the original user reported issue, these methods were code-gen from GRPC proto files.

)

* Use reference equality to compare model instances in EditContext

Fixes #18069
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Jan 28, 2020
@mkArtakMSFT mkArtakMSFT added the Servicing-consider Shiproom approval is required for the issue label Jan 29, 2020
@mkArtakMSFT mkArtakMSFT added this to the 3.1.x milestone Jan 29, 2020
@Pilchie Pilchie added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Feb 4, 2020
@Pilchie Pilchie modified the milestones: 3.1.x, 3.1.3 Feb 4, 2020
@mkArtakMSFT mkArtakMSFT merged commit d7f98bd into release/3.1 Feb 14, 2020
@mkArtakMSFT mkArtakMSFT deleted the prkrishn/editcontext branch February 14, 2020 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants