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

Enable Quotes when parsing arguments in property wrapper parameters #1316

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

art-divin
Copy link
Collaborator

@art-divin art-divin commented Mar 28, 2024

Resolves #1043

Context

The logic at fault is, when Attribute is parsed from AttributeSyntax, for some reason " is replaced with an empty string - unsure why this was applied during initial implementation, when swift-syntax was integrated. As far as I can see, the behaviour changes a little, but it changes in a correct manner, that is, the reported issue is fixed.

I suspect there was an assumption made initially that quotes did not look good, especially when writing unit tests; however, as practice shows, they are needed.

extension Attribute {
    convenience init(_ attribute: AttributeSyntax) {
             ...
              let components = part.split(separator: ":", maxSplits: 1)
              switch components.count {
              case 2:
                  arguments[components[0].trimmed] = components[1].replacingOccurrences(of: "\"", with: "").trimmed as NSString
              case 1:
                  arguments["\(idx)"] = components[0].replacingOccurrences(of: "\"", with: "").trimmed as NSString
              ...
    }
   ...
}

@art-divin art-divin merged commit bba88d9 into master Mar 29, 2024
2 checks passed
@art-divin art-divin deleted the correct-property-wrapper-argument-strings-parsing branch March 29, 2024 15:13
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.

Attributes don't work properly
3 participants