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

Macro doesn't execute when defined in a project outside of analysis roots #55670

Open
DanTup opened this issue May 8, 2024 · 2 comments
Open
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DanTup
Copy link
Collaborator

DanTup commented May 8, 2024

I was investigating an issue @mit-mit / @davidmorgan are seeing of macros not executing in VS Code. I can reproduce the issue and it seems to be that when the project that contains a macros definition is not in the workspace, the macro does not execute.

Here's a repro:

https://github.com/DanTup/macro-other-project-issue

This project has two projects:

  • my_macro - defines a macro @WithMethod(name) that adds a method to a class
  • my_macro_user - defines a class A annotated with @WithMethod('hello) to add a method called hello

If I open the entire repository in VS Code, the macro executes fine (I can hover over and jump to the definition):

image

However, if I open only the my_macro_user folder (so that the definition of the macro is not in the workspace), the macro doesn't execute (and no errors are shown in VS Code or in the instrumentation log):

image

@mit-mit was using latest Flutter master and I repro'd on Dart SDK version: 3.5.0-edge.8ef0e2a15805d3b79c64c3998fa1c9500f3654d0 (main) (Mon May 6 23:57:19 2024 +0000) on "windows_x64".

@DanTup DanTup added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 8, 2024
@bwilkerson
Copy link
Member

@scheglov

@bwilkerson bwilkerson added the feature-macros Implementation of the macros feature label May 8, 2024
@scheglov
Copy link
Contributor

scheglov commented May 8, 2024

We discussed this internally, and the conclusion is that we don't use analysis_options.yaml of dependencies: my_macro here, to enable experiments. So, when you analyze just my_macro_user, it does not see any macros in my_macro.

There is no solution so far, at least for such random custom macro packages.
For json we could potentially use allowed_experiments.json.

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P2 A bug or feature request we're likely to work on labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants