-
Notifications
You must be signed in to change notification settings - Fork 209
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
testBuilder method does not work with GenerateForAnnotated generators #2292
Comments
I was not able to repro the error here - you will need to ensure that you are correctly emulating the annotations library - is that the exact same uri as the actual annotation as it is imported in the builder file? |
No. The annotation library is fake. I had maden this up instead of pasting the real annotations for the sake of simplicity. The point is that, the code does not hit |
Right, but the likely reason it isn't is because it can't resolve the annotation. You have to provide in |
Well, I created a real |
I have made some corrections on the first comment. Still does not work. There is one more issue(#1828) representing this problem which was closed without being resolved. I would like to know if it is a bug or our mistake. |
In both of these cases I can't actually reproduce the problem, (I recreated your example above and it works for me). So I assume there is some mistake somewhere. |
Did the breakpoint in the generator work for you??? I shared |
Below you can watch the problem if you do not believe me. I reproduced the problem and recorded every step. I want to know where is my mistake in this setup? |
@elnurvl - is there a repository we can check out and reproduce what you are seeing? |
Yes, it did.
I think it might have to do with the export - in that case the class is actually defined in the exported file under src but in your test the annotation facade is directly under |
@jakemac53 , can you please share your working sample, so I can examine the problem? |
@natebosch I will push the code to a repository soon and share it here. |
@natebosch , you can look at the repository from this link: If you think there is something wrong in this repository which causes the problem mentioned here, please feel free to send a pull request with the corrected code, or open an issue stating the source of the problem. If it cannot be thought as a mistake, I suggest, either to improve the code in order to achieve easier test setup or to improve the documentation in order to prevent any confusion while working with the package, as it is quite hard to detect a problem especially when almost identical codes give different results. Thanks. |
Sent a pr to implement the fix that I outlined above |
#2297 will also make this a bit easier, so you won't have to provide these types of mock assets (and won't get broken if the real asset moves) |
I have a custom generator that extends from
GenerateForAnnotated
class. I want to debug my generator with breakpoints. In order to do that, I am usingtestBuilder
method ofbuild_test
package.However, the debugger does not hit
generateForAnnotatedElement
method and testBuilder’s result is an empty asset.When I change my generator to inherit from
Generator
class, the package works and the debugger hits thegenerate
method.Why does it happen? Is it a bug? How can I debug the generator?
Test file:
TestAnnot file:
Generator file:
pubspec.yaml:
The text was updated successfully, but these errors were encountered: