feature: Add @RPC scripted test + extend Object filter (#498 Gap 4 Part 2)#503
Conversation
…rt 2) Wraps up #498 Gap 4. The runtime API surface (@rpc, RxRouter, RxRouterProvider) landed in #501, and the existing uniHttpClients codegen pipeline (HttpCodeGenerator + ServiceScanner) already produces the same POST routes that an @RPC-annotated trait expects. This PR adds: - A second sbt-uni scripted test (codegen/rpc-client-annotated) that drives codegen against an @RPC-annotated trait whose companion extends RxRouterProvider — the exact migration shape used by wvlet-api's FrontendApi. Verifies end-to-end that the annotation doesn't break the codegen pipeline and that the generated client class compiles. - Extends ObjectMethodNames in RouterMacros to also exclude scala.Product members (canEqual, productArity, productElement, productElementName, productIterator, productPrefix). Surface.methodsOf already filters them by owner; this is belt-and-suspenders, addressing Gemini's medium-priority follow-up on #502. - Mirrors the same Product-method exclusion in ServiceScanner's excludedNames so codegen output stays consistent with router output when applied to case-class-flavored services.
There was a problem hiding this comment.
Code Review
This pull request introduces a new test case to verify RPC client code generation for traits with companions extending RxRouterProvider. Additionally, it updates ServiceScanner and RouterMacros to exclude standard scala.Product methods from being identified as service routes. Feedback was provided to include productElementNames in the exclusion lists for both files to ensure complete coverage of Product methods.
| "canEqual", | ||
| "productArity", | ||
| "productElement", | ||
| "productElementName", | ||
| "productIterator", | ||
| "productPrefix", |
There was a problem hiding this comment.
The list of scala.Product methods is missing productElementNames. While productElementName (singular) is included, the plural version productElementNames (which returns an Iterator[String]) should also be excluded to ensure that all standard product-related methods are filtered out during service scanning.
"canEqual",
"productArity",
"productElement",
"productElementName",
"productElementNames",
"productIterator",
"productPrefix",| "canEqual", | ||
| "productArity", | ||
| "productElement", | ||
| "productElementName", | ||
| "productIterator", | ||
| "productPrefix" |
There was a problem hiding this comment.
The list of scala.Product methods is missing productElementNames. For consistency with the intended "belt-and-suspenders" approach to exclude all Product members, please add productElementNames to this set.
"canEqual",
"productArity",
"productElement",
"productElementName",
"productElementNames",
"productIterator",
"productPrefix"
Summary
Wraps up #498 Gap 4. The runtime API surface (`@RPC`, `RxRouter`,
`RxRouterProvider`) landed in #501 and the existing `uniHttpClients`
codegen pipeline (`HttpCodeGenerator` + `ServiceScanner`) already
produces the same `POST` routes that an `@RPC`-annotated trait expects.
This PR adds the missing test + polish:
drives codegen against an `@RPC`-annotated trait whose companion
extends `RxRouterProvider` — the exact migration shape used by
wvlet-api's `FrontendApi`. Verifies end-to-end that the annotation
doesn't break the codegen pipeline and that the generated client
class compiles.
`scala.Product` members (`canEqual`, `productArity`, `productElement`,
`productElementName`, `productIterator`, `productPrefix`).
`Surface.methodsOf` already filters them by owner; this is
belt-and-suspenders, addressing Gemini's medium-priority follow-up
on fix: Filter Object methods and prefix StemNode names (#501 follow-up) #502.
`excludedNames` so codegen output stays consistent with router output
when applied to case-class-flavored services.
Why this closes Gap 4
Issue #498 Gap 4 lists three deliverables:
already present as `uniHttpClients` (`UniPlugin.scala`), which the
new scripted test exercises against an `@RPC` trait.
After this PR merges, wvlet-api's `FrontendApi` / `FileApi`-style
`@RPC` trait + `RxRouterProvider` companion shape compiles against
uni and `uniHttpClients` generates the typed RPC client.
Test plan
backward-compat coverage) and `codegen/rpc-client-annotated`
(new `@RPC` coverage) in the same CI step.
Refs #498 Gap 4 Part 2 (final).