Closed wolfenrain closed 2 weeks ago
/cc @kevmoo as he asked me to open an issue and CC him on it 😏
fwiw I'm also seeing the same thing. I was able to see things work correctly once or twice (e.g I could see the "go to augmentation" shortcut in vscode and the analyzer wasn't complaining) but lately I'm also experiencing the same issues as @wolfenrain using the exact same Dart version.
You're hitting https://github.com/dart-lang/sdk/issues/55746 which has just been fixed. Currently the analysis server isn't running macros if they're imported from a file that export
s them.
If you add src/
into your import in example/main.dart
to import the file containing the macro directly then things will work:
import 'package:struct_annotation/src/struct_annotation.dart';
// ^^^^
Once you're on an SDK that includes https://github.com/dart-lang/sdk/commit/73bdc86dd50e11cedb3bf976c597a02ad209bdb4 then you'll be able to import a file that export
s them.
Describe the bug
I have been playing around with Dart's experimental support for macros and I have followed the steps described here but I have not been able to get the augmented code to show up.
To Reproduce
dart pub get
example/main.dart
Expected behavior
I expected the augmented code to work and show up correctly.
Screenshots This screenshot shows that the
copyWith
does not exist, even tho the macro adds it and I can run that code withdart run --enable-experiment=macros example/main.dart
Please complete the following information:
You can run the Dart: Collect Diagnostic Information command from the VS Code command palette (
F1
) to easily capture this information or provide it manually.Output from 'dart info'
`/Users/wolfen/development/flutter/bin/cache/dart-sdk/bin/dart info` If providing this information as part of reporting a bug, please review the information below to ensure it only contains things you're comfortable posting publicly. #### General info - Dart 3.5.0-160.0.dev (dev) (Wed May 15 17:06:58 2024 -0700) on "macos_arm64" - on macos / Version 14.4.1 (Build 23E224) - locale is en-NL #### Project info - sdk constraint: '^3.5.0-152.0.dev' - dependencies: collection, equatable, macros - dev_dependencies: #### Process info | Memory | CPU | Elapsed time | Command line | | -----: | ---: | -----------: | ------------------------------------------------------------------------------- | | 351 MB | 0.0% | 02:30:27 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.88.1 | | 132 MB | 0.0% | 03:20 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.88.1 | | 27 MB | 0.0% | 02:30:27 | dart tooling-daemon --machine | | 39 MB | 0.0% | 03:20 | dart tooling-daemon --machine |