Skip to content

Conversation

@Alkenso
Copy link
Contributor

@Alkenso Alkenso commented May 12, 2023

  • fix output for case when one of CodingKeys is empty string
  • fix mirror decoding of encoded type where one of CodingKeys is empty string

@Alkenso
Copy link
Contributor Author

Alkenso commented May 12, 2023

@Joannis , please review.
Probably you'll find some additional cases that I could miss due to pretty complex conditions of decoding

@Joannis
Copy link
Member

Joannis commented May 12, 2023

I need a bit more time for review, but could you document your intended behaviour here? That helps me review, and end users understand how encoding/decoding enum cases works.

@Alkenso
Copy link
Contributor Author

Alkenso commented May 12, 2023

Such functionality allows the ability to inline one of codable fields.
It works exactly like already documented paragraph Coding key value intrinsic, but this implementation works for complex types, not only simple ones

Also I decided to simplify dealing with Choice containers. Added tests, update README.

@Alkenso Alkenso force-pushed the empty_codingkey_encode_decode_output branch from c896105 to 5119277 Compare May 13, 2023 07:14
@Alkenso
Copy link
Contributor Author

Alkenso commented May 16, 2023

@Joannis , update with additional fixes

@Alkenso
Copy link
Contributor Author

Alkenso commented Jun 7, 2023

@Joannis , ping

@Joannis
Copy link
Member

Joannis commented Jun 7, 2023

Thanks for the ping! The PR was made at a very unfortunate time, so it got missed

Copy link
Member

@Joannis Joannis left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, and sorry for the delayed review! Just some small changes regarding isInlined

var string = ""
string += element._toXMLString(indented: level + 1, escapedCharacters, formatting, indentation)
string += prettyPrinted ? "\n" : ""
let indentLevel = !isInlided ? level + 1 : level
Copy link
Member

Choose a reason for hiding this comment

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

Reverse the ternary, making it easier to parse

Suggested change
let indentLevel = !isInlided ? level + 1 : level
let indentLevel = isInlined ? level : level + 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


extension XMLKeyedDecodingContainer {
internal init?(box: Box, decoder: XMLDecoderImplementation) {
if let keyedContainer = box as? KeyedContainer {
Copy link
Member

Choose a reason for hiding this comment

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

Should be a switch instead. Switch statements are a bit faster.

Copy link
Member

Choose a reason for hiding this comment

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

switch box {
case let container as KeyedContainer:
...
default:
    return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Alkenso Alkenso force-pushed the empty_codingkey_encode_decode_output branch from a6eb8eb to 31c3936 Compare June 8, 2023 06:08
Copy link
Member

@Joannis Joannis left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I'll test it myself, and publish it later

@Joannis
Copy link
Member

Joannis commented Jun 9, 2023

@Alkenso
Copy link
Contributor Author

Alkenso commented Jun 9, 2023

@Joannis , I dont know how it is possible. Locally all builds fine. Please check on yours

Extension of protocol CodingKey adds method isInlined. Dont think it didnt work on Xcode 13...

@Alkenso
Copy link
Contributor Author

Alkenso commented Jun 13, 2023

@Joannis , please re-run CI. Maybe the CI issue could occur because I've made force-push of last commit instead making new one?

@Joannis
Copy link
Member

Joannis commented Jun 13, 2023

I did re-run it a couple of times, but the CI keeps failing to spin up a worker. I don't know what is going on at Github..

@Joannis
Copy link
Member

Joannis commented Jun 13, 2023

image

@Alkenso
Copy link
Contributor Author

Alkenso commented Oct 11, 2023

@Joannis , lets revive this PR. Probably we can move to Xcode 14-15 for builds

@Joannis
Copy link
Member

Joannis commented Oct 11, 2023

@Alkenso Yeah, I think that's a good plan.

@Joannis Joannis merged commit f2c0d9f into CoreOffice:main Feb 12, 2024
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.

2 participants