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

Fix ErrorMessageOverride collision with classname #4930

Merged
merged 5 commits into from
Jul 3, 2024

Conversation

andrueastman
Copy link
Member

Fixes #4893

In summary, this PR

  • Updates the ReplaceReservedExceptionPropertyNames method to also rename the error class if it is the same name as a reserved class to avoid collision with class name and property name.
  • Updates the AddPrimaryErrorMessage to rename existing matching properties if they already exist in the error model to avoid information/property loss (otherwise we will fail to add the override and lead to invalid generation)
  • Add tests to validate the scenarios.

Essentially, in a scenario where a ErrorMessageOverride property kind named message is added,

  • if the error model class is also called message, the model class will be renamed to avoid class and property name collision.
  • if a property with the same name already exists in the model, the pre-existing property is renamed to ensure the suitable override is added (if the type does not match).
  • otherwise, normal behavior of adding the override property will be used.

@andrueastman andrueastman marked this pull request as ready for review July 3, 2024 09:59
@andrueastman andrueastman requested a review from a team as a code owner July 3, 2024 09:59
@andrueastman andrueastman enabled auto-merge July 3, 2024 09:59
auto-merge was automatically disabled July 3, 2024 10:03

Pull Request is not mergeable

baywet
baywet previously approved these changes Jul 3, 2024
@baywet baywet enabled auto-merge July 3, 2024 12:52
Copy link

sonarqubecloud bot commented Jul 3, 2024

auto-merge was automatically disabled July 3, 2024 12:57

Pull Request is not mergeable

@baywet baywet enabled auto-merge July 3, 2024 12:58
@baywet baywet merged commit 77b80dd into main Jul 3, 2024
207 checks passed
@baywet baywet deleted the andrueastman/fixMethodOverride branch July 3, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

class to name conflict avoidance behaviour colliding with error default message behaviour in CSharp
2 participants