An package to use as a starting point for trying out Dart macros.
First, you need to ensure your SDK is compatible with this package, and also that the versions of the various dependencies are lined up. You can use either a released dev SDK or a local build of the SDK.
To use a released Dev SDK, look at the pubspec.yaml
file in this repo and
download exactly the version you see set in the environment constraint (which
should also match the ref you see in each of the dependencies). Then run a
pub get
.
To use a local SDK, open up the pubspec_overrides.yaml
file, uncomment all the
lines in it, and update the paths to point at your local SDK. Make sure you do
a build of your local SDK as well.
In this setup, you may find the APIs have changed and you get some errors. If so
feel free to update things, as well as the SDK versions in the pubspec.yaml
file, and send a PR to update. Or, file an issue on this repo.
You can run the example under bin
normally on the Dart VM, by passing
--enable-experiment=macros
. So the full command would be:
dart --enable-experiment=macros bin/auto_to_string.dart
You can also run/debug from your IDE using the instructions below.
You will need to set the "dart.experimentalMacroSupport": true,
option in your
VS Code settings (it's already set in .vscode/settings.json
for this project).
To run/debug from VS Code, you will need to add "--enable-experiment=macros"
to toolArgs
in your .vscode/launch.json
(it's already done for this
project).
To run this example, open bin/auto_to_string.dart
and press F5
(or click the
Run
/Debug
CodeLens links).
Note that support here is still very early days, so please file issues as you find them.
TODO: Add instructions once available