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

feat: rename deserialization protocols for clarity, improve usability of error types, and broke up into multiple files. (7.0.0) #259

Merged
merged 16 commits into from
May 7, 2022

Conversation

drmohundro
Copy link
Owner

@drmohundro drmohundro commented Apr 28, 2022

This pull request covers a variety of improvements.

Renaming XMLIndexerDeserializable protocol and Adding XMLValueDeserialization protocol

I renamed XMLIndexerDeserializable to be XMLObjectDeserialization - its purpose is to deserialize object structures like classes or structs. So, multiple values. Then, there is a new protocol named XMLValueDeserialization - it serves the purpose of both XMLElementDeserializable and XMLAttributeDeserializable. It is only used for custom value deserialization. I hope this will clarify the usage a lot. It makes sense to me anyway!

This should cover the use case at #148.

Usability of Errors

Multiple times when helping people, I'd notice that the nodeIsInvalid error would get thrown, but the error message was just about impossible to determine what was wrong. The code had implemented CustomStringConvertible but everyone was using localizedDescription. Now, errors implement LocalizedError, too, so it is a lot more obvious to see the elements that had caused issues.

Code Reorganization

The code had all been lumped into two Swift files since the beginning. It was unwieldy then, but it has just gotten worse. So I gave in and broke them all out into their own files by type. Much better.

Checklist

@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #259 (54e2186) into main (8b594e0) will decrease coverage by 1.28%.
The diff coverage is 68.01%.

@@            Coverage Diff             @@
##             main     #259      +/-   ##
==========================================
- Coverage   66.70%   65.41%   -1.29%     
==========================================
  Files          14       36      +22     
  Lines        1910     1995      +85     
==========================================
+ Hits         1274     1305      +31     
- Misses        636      690      +54     
Impacted Files Coverage Δ
...e/Deserialization/XMLAttributeDeserializable.swift 0.00% <0.00%> (ø)
...urce/Deserialization/XMLValueDeserialization.swift 0.00% <0.00%> (ø)
Source/XMLHash.swift 82.60% <ø> (+3.34%) ⬆️
...LHashTests/TypeConversionPrimitiveTypesTests.swift 54.34% <0.00%> (ø)
Source/Errors/IndexingError.swift 9.09% <9.09%> (ø)
...rce/Deserialization/XMLElementDeserializable.swift 25.00% <25.00%> (ø)
...rce/Deserialization/XMLObjectDeserialization.swift 25.00% <25.00%> (ø)
Source/Errors/XMLDeserializationError.swift 36.84% <36.84%> (ø)
...eserialization/XMLIndexer+XMLDeserialization.swift 59.74% <45.45%> (ø)
...serializationTypes/Double+XMLDeserialization.swift 50.00% <50.00%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b594e0...54e2186. Read the comment docs.

@drmohundro drmohundro marked this pull request as ready for review May 3, 2022 13:57
@drmohundro drmohundro force-pushed the feat/improve-node-is-invalid-errors branch from 338734e to 1e31af3 Compare May 3, 2022 18:22
This commit also introduces a new XMLDeserialization type that hopefully will make it easier to implement deserialization for custom types.
@drmohundro drmohundro force-pushed the feat/improve-node-is-invalid-errors branch from 1e31af3 to cd81c77 Compare May 3, 2022 18:25
@drmohundro drmohundro force-pushed the feat/improve-node-is-invalid-errors branch from 7b94133 to f9849b3 Compare May 3, 2022 18:44
@drmohundro drmohundro force-pushed the feat/improve-node-is-invalid-errors branch from f9849b3 to d7aba5a Compare May 3, 2022 18:48
@drmohundro drmohundro force-pushed the feat/improve-node-is-invalid-errors branch from 2a40f32 to 9ee0729 Compare May 3, 2022 21:34
@drmohundro drmohundro changed the title feat: improve nodeIsInvalid error messages feat: code reorganization, clean up, and improvements May 4, 2022
@drmohundro drmohundro changed the title feat: code reorganization, clean up, and improvements feat: rename deserialization protocols for clarity, improve usability of error types, and broke up into multiple files. May 7, 2022
@drmohundro drmohundro changed the title feat: rename deserialization protocols for clarity, improve usability of error types, and broke up into multiple files. feat: rename deserialization protocols for clarity, improve usability of error types, and broke up into multiple files. (7.0.0) May 7, 2022
@drmohundro drmohundro merged commit 6f446b2 into main May 7, 2022
@drmohundro drmohundro deleted the feat/improve-node-is-invalid-errors branch May 7, 2022 00:54
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.

1 participant