Inherit protocol modifiers
- Allows protocols with any modifiers, like
public,fileprivateetc. to inherit this access on the spy and all the generated members. This is done by taking themodifierson the original protocol definition and applying it to all generated members.-
privateprotocol members will inherit an access levelfileprivateinstead. Aprotocoldeclaredprivateat file-scope is effectively treated asfileprivate. This access level on the generated members is required to satisfy the protocol requirements
-
- Generate an
initwith the same access level, allowing the spy to be created outside of the current module (as the default init level isinternal). - Adds tests for all use cases.
- Closes #73 , fixes #72
Thanks for the great library! This is the best spy/mock generator out there atm.
Hi @bradleymackey, welcome to the project!
Thank you for your contribution! I'll try to review it over the weekend! 🙌
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 96.92%. Comparing base (
288c860) to head (13b69a5). Report is 104 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #80 +/- ##
==========================================
+ Coverage 96.69% 96.92% +0.23%
==========================================
Files 17 18 +1
Lines 695 748 +53
==========================================
+ Hits 672 725 +53
Misses 23 23
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hey @Matejkob could you merge this improvement by any chance?
Oops, this one fell off my radar, apologies for not addressing the feedback as requested. I'm using Mockolo now for my personal projects as it has a lot of features I need anyway with a bit more control over certain aspects of the mock generation.
I'll see about having a look at addressing these improvements in a week or so, but no promises as I may be a little busy.
I would love to see this implemented because i am facing exactly the same issue. Is there any effort any time soon to merge this? :)
Hello! Do we have any updates on this? When will the @Spyable create a public class?
Thank you so much @bradleymackey, for your hard work on this feature! Your approach of modifying each node individually was a great step forward and really helped shape the direction of this functionality.
I’m closing this PR in favor of a new implementation (#130) that uses a syntax rewriter to handle access level inheritance. This simplifies the logic and ensures consistent behavior for all declaration members.
Your contribution was invaluable, and I truly appreciate the effort you put into this. Looking forward to more contributions from you in the future! 😊
Hi @damian-kolasinski, @armintelker, @KonDouvris! Thank you for your patience and for highlighting the importance of this feature. I’ve created a new PR (#130 ) that implements access level inheritance using a syntax rewriter, ensuring consistent behavior across all members.
I’m planning to merge it in 2/3 days to allow the community some time to review and provide feedback. I’d love to hear your thoughts or suggestions on the new implementation before it’s finalized! Your input is always appreciated. 😊
Thanks again for your support and enthusiasm for this project!