-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Implement @Default macro #189
base: main
Are you sure you want to change the base?
Conversation
This addresses sindresorhus#142 by creating a new macro that can be used inside `@Observable` classes. The macro is implemented in a new `DefaultsMacros` module. The decision to do so is based on the introduction of a new dependency on `swift-syntax`, and to keep the main module dependency-free.
Thanks for working on this 🙏 |
👍 |
Tests for the macro declaration were in the wrong test target and the test method names were not accurate. Added another test target to actually test that the macro works when used in an @observable class.
This is to be consistent with the `@Default` property wrapper.
In the macro tests, I had to move the @observable classes out of the test because linter was asking to mark them as private but doing so was causing the @observable macro to error.
I think this is now ready for review. Please, let me know about any issues/concerns. BTW I renamed the macro to |
Hi there! Thought I'd pitch in and contribute to this great package. This addresses #142 by creating a new macro that can be used inside
@Observable
classes.The macro is implemented in a new
DefaultsMacros
module. The decision to do so is based on the introduction of a new dependency onswift-syntax
, and to keep the main module dependency-free (specially since the syntax package adds quite a bit to build times). Please, let me know if you'd rather move it to the main module.Settings the PR as draft for early review, but there are at least a couple things I want to do to get it ready. Also, I haven't put much thought into the naming; advice on this is appreciated.
TODO
Figure out if@ObservationIgnored
can be added automatically as part of the macro.