Improve conflicting member exception message#38222
Open
m-x-shokhzod wants to merge 1 commit intodotnet:mainfrom
Open
Improve conflicting member exception message#38222m-x-shokhzod wants to merge 1 commit intodotnet:mainfrom
m-x-shokhzod wants to merge 1 commit intodotnet:mainfrom
Conversation
When adding a member with a name that already exists, the previous exception only stated "a property or navigation with the same name already exists" without distinguishing what kind of member the conflict was with, and unconditionally included the declaring type even when it was the same as the type being added to. Address the three improvements requested in dotnet#36487: 1. Specify the kind of the conflicting member (property, complex property, navigation, skip navigation, or service property). 2. Include the declaring type only when it differs from the current type — split into two resources, ConflictingPropertyOrNavigation for same-type conflicts and ConflictingPropertyOrNavigationOnBaseType for conflicts inherited from a base type. 3. Add explicit removal guidance: "Remove the existing X first." Add two helpers in PropertyBaseExtensions: - GetMemberKindString returns the human-readable kind label. - FormatConflictingMemberMessage picks the right resource based on declaring-type-vs-current-type and assembles the message. Update all eight throw sites to use the helper (or the new resource directly when the conflicting member is not in scope). Update affected tests to assert against the new messages. Fixes dotnet#36487
5379f2a to
9425fcf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When adding a member with a name that already exists, the previous exception only stated "a property or navigation with the same name already exists" without distinguishing what kind of member the conflict was with, and unconditionally included the declaring type even when it was the same as the type being added to.
Address the three improvements requested in #36487:
Add two helpers in PropertyBaseExtensions:
Update all eight throw sites to use the helper (or the new resource directly when the conflicting member is not in scope).
Update affected tests to assert against the new messages.