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: @dynamicMember conflicting field name #2965

Merged
merged 7 commits into from
Apr 17, 2023
Merged

Conversation

calvincestari
Copy link
Member

Fixes #2950

  • Introduces a new set of field names for which properties are generated, overriding the @dynamicMember subscript.
  • Changes Mock subscript setters to use a common private _set function that can be called from initializers too.

@netlify
Copy link

netlify bot commented Apr 17, 2023

Deploy Preview for apollo-ios-docs canceled.

Name Link
🔨 Latest commit 0c6ca47
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docs/deploys/643da4e1dbfa680008a8ffac

Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

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

Thanks so much for getting this one out @calvincestari!

@@ -68,6 +69,19 @@ struct MockObjectTemplate: TemplateRenderer {
"""
}

private func conflictingFieldNameProperties(_ fields: [TemplateField]) -> TemplateString {
"""
\(fields.map { """
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: might be more performant to compute an intersection with the TestMockConflictingFieldNames set and then just map over those? I could be wrong, but I believe that set intersection computation is very fast b/c of hashing algorithms. This is so so minor though, I'm not really worried about making the change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing about fields nor the FieldCollector is a Set unfortunately, I don't think we're going to get much benefit out of going that route here.

@calvincestari calvincestari merged commit cafeffa into main Apr 17, 2023
@calvincestari calvincestari deleted the fix/hash-clash branch April 17, 2023 21:05
@calvincestari calvincestari mentioned this pull request May 1, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated test Mock code produces compilation error when object contains property named "hash"
2 participants