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

Implement @ObservableDefault macro #189

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Commits on Sep 15, 2024

  1. Implement @ObservableDefaults macro

    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.
    kevinrpb committed Sep 15, 2024
    Configuration menu
    Copy the full SHA
    4827461 View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2024

  1. Fix test names, add tests for @observable result

    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.
    kevinrpb committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    21c4281 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    85587a0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    028cdfb View commit details
    Browse the repository at this point in the history
  4. Rename @ObservableDefaults macro to @Default

    This is to be consistent with the `@Default` property wrapper.
    kevinrpb committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    70f569e View commit details
    Browse the repository at this point in the history
  5. Fix lint warnings

    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.
    kevinrpb committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    6cc37e0 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    147892d View commit details
    Browse the repository at this point in the history

Commits on Sep 25, 2024

  1. Update readme.md

    sindresorhus authored Sep 25, 2024
    Configuration menu
    Copy the full SHA
    8708fd5 View commit details
    Browse the repository at this point in the history
  2. Update Default.swift

    sindresorhus authored Sep 25, 2024
    Configuration menu
    Copy the full SHA
    1c9262c View commit details
    Browse the repository at this point in the history

Commits on Sep 26, 2024

  1. Rename @default macro back to @ObservableDefault

    We cannot overload @default, otherwise it is impossible to use the
    property wrapper version in the same source file as the macro as the
    later takes precedence.
    kevinrpb committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    017a42d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    242aba5 View commit details
    Browse the repository at this point in the history