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

Remove dependency on Foundation #9

Open
t089 opened this issue Dec 11, 2024 · 13 comments
Open

Remove dependency on Foundation #9

t089 opened this issue Dec 11, 2024 · 13 comments

Comments

@t089
Copy link

t089 commented Dec 11, 2024

I have been looking into removing the dependency on Foundation from soto and soto-core. I got really far without too much trouble, but then realized that this library has a pretty strong dependency on Foundation that is not easily resolvable as many of the types used here are not available in FoundationEssentials. Such as NSNumber, NSNull, JSONSerialization.

Not sure what the best approach would be, maybe it would be better to instead use a different JSON library such as IkigaJSON.

@adam-fowler
Copy link
Owner

It might just be better to write a JSON parser specifically for the library. Ikiga includes a load of extra stuff we wouldn't need. A JSON parser is fairly easy to write. We could probably ditch the NSNull stuff after that as that is a requirement for parsing output of JSONSerialization. Not so sure about NSNumber as it used as a general wrapper for a number type.

@adam-fowler
Copy link
Owner

I can see a way around the uses of NSNumber

@t089
Copy link
Author

t089 commented Dec 12, 2024

We could also just "rip out" the json parser from Foundation-Essentials. There is also @tayloraswift's https://github.com/tayloraswift/swift-json

@adam-fowler
Copy link
Owner

We could also just "rip out" the json parser from Foundation-Essentials. There is also @tayloraswift's https://github.com/tayloraswift/swift-json

That's kinda what I was thinking. I'd probably go with FoundationEssentials.
If you have soto-core changes I'd love to see them in a draft.

@adam-fowler
Copy link
Owner

datetime date format is the one thing I can think of that isn't supported by FoundationEssentials
There a couple of places where I've added foundation APIs.
Even a PR that gets halfway would be better than nothing

@t089
Copy link
Author

t089 commented Dec 12, 2024

check the links above, they show the WIP commits in my forks. I can open WIP PRs of course!

@t089
Copy link
Author

t089 commented Dec 12, 2024

I have not updated the code generator but just brute-force updated the generated files in place

@adam-fowler
Copy link
Owner

Here's a start #10

@adam-fowler
Copy link
Owner

I had a look at JSONScanner from Foundation. It's really clever. The scanner just works out the ranges of everything. There is no parsing of values that is done inside the decoder. This means you only convert the values you need. For JMESPath that's great as you don't need to convert most of the file.

Actually getting it to work with JMESPath is quite a bit of work though.

@t089
Copy link
Author

t089 commented Dec 13, 2024

Actually getting it to work with JMESPath is quite a bit of work though.

Would be great though ;)

@adam-fowler
Copy link
Owner

#11 gets rid of Foundation for loading json. Now need to get rid of writing json and work out how I'm going to keep the Data APIs.

@t089
Copy link
Author

t089 commented Dec 16, 2024

Nice!

Data is in FoundationEssentials though or do you want to get fully independent?

@adam-fowler
Copy link
Owner

Data is in FoundationEssentials though or do you want to get fully independent?

Ah didn't realise that. Would be nice to have one entry point which takes a generic. Might be able to use the ContiguousBytes protocol.

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

No branches or pull requests

2 participants