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: introduce WireMacros - no ticket #1694

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

Conversation

johnxnguyen
Copy link
Collaborator

@johnxnguyen johnxnguyen commented Jul 15, 2024

Issue

Create a WireMacros package:

  • @Provided generates a "provider" companion protocol for other protocols.
  • #UUID validates uuid strings at compile time.
  • new macros can be created and tested here too.

Open question: is the potential overhead of using macros a concern?


Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

Comment on lines +45 to +46
let uuid = #UUID("7411ca17-ba08-4905-92d2-0617a8c810ca")
print(uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these lines here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This main file is kind of a playground to develop the macros.... maybe it's not needed since we can do that in tests and/or in our other modules.

@markusfassbender
Copy link
Contributor

added an example how to use it in WireAPI tests: d9661cd
Great job @johnxnguyen , thanks!

@netbe netbe added the WIP label Jul 24, 2024
Comment on lines +25 to +26
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably remove these two lines of comments

Copy link
Contributor

@samwyndham samwyndham left a comment

Choose a reason for hiding this comment

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

Nice! I'm super in favor of adding macros if we can keep the compile performance costs are not prohibitive - especially those which can get rid of unnecessary optional values as these tend explode.

I would also consider adding something like #URL("http://example.com")

import Foundation

/// A macro that, when attached to a protocol declaration, produces a
/// companion "provider" protocol that can be used inject dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty interesting. I need to take a look to understand the provider pattern more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants