-
-
Notifications
You must be signed in to change notification settings - Fork 319
useDeepEquality option is not being passed to the generated code
#1064
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
base: main
Are you sure you want to change the base?
useDeepEquality option is not being passed to the generated code
#1064
Conversation
useDeepEquality option is not being passed to the generated code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where the useDeepEquality option from the @observable annotation was not being extracted and passed to the code generator, preventing users from controlling deep equality checks in their observable setters.
Key Changes:
- Extracts the
useDeepEqualityparameter from@observableannotations in the code generation pipeline - Adds comprehensive test coverage for
useDeepEqualitywith true, false, and null values - Updates version from 2.7.4 to 2.7.5
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mobx_codegen/lib/src/store_class_visitor.dart | Added _getUseDeepEquality() method to extract the useDeepEquality parameter from annotations and pass it to ObservableTemplate |
| mobx_codegen/test/store_class_visitor_test.dart | Added three test cases to verify useDeepEquality is correctly included in generated code when set to true, false, or null |
| mobx_codegen/pubspec.yaml | Updated version to 2.7.5 and normalized quote style for dependency version constraints |
| mobx_codegen/lib/version.dart | Updated version constant to match pubspec.yaml |
| mobx_codegen/CHANGELOG.md | Documented the bug fix for version 2.7.5 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
amondnet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix! The core implementation looks good and follows the existing patterns.
However, there are a couple of issues to address:
-
Rebase needed: The PR appears to be based on an older branch. The
pubspec.yamlhas SDK>=3.0.0but current main requires>=3.7.0. Please rebase on the latestmainbranch. -
Missing
latefield support: TheuseDeepEqualityparameter is only added to regular field setters but not tolatefield setters inobservable.dart(line 70). Could you also add it there for completeness?
Let me know if you need any help with these changes!
|
@amondnet thank you for the feedback. I've made the requested changes. Let me know if you have any more comments. I've also got a PR I'd like to raise for |
|
@ben-milanko Could you please fix the failing test? The test data needs to be modified. If it's difficult, please grant me permission to modify the PR. |
|
Hi @amondnet I've merged the latest changes from main, and tried to update the test data to include useDeepEquality, but am running into some formatting issues. In this example the expected is on the left and the actual on the right. The deep equality was fixed in this example.
The test in question is test('generates for a class mixing Store', () async {
await compareFiles('./data/valid_input.dart', './data/valid_output.dart');
});I'm not sure if you might be using a different formatter to me? I've added you with write permissions on my fork if you would like to take a look. |

Describe the changes proposed in this Pull Request.
There is an existing bug where the
useDeepEqualityoption is not being passed to the generator.Based on
MakeObservablethe default option should beuseDeepEquality: true.After looking at the generated code, this is not being passed through.
Pull Request Checklist
pubspec.yamlis updated.major/minor/patch/patch-count, depending on the complexity of changemelos run set_versioncommand from the root directory