feat: 生成コードを再生成し Autogen 名前空間に追随する - #64
Open
masatoi wants to merge 1 commit into
Open
Conversation
pokepay-server の api-response-validation-tests ブランチ (x-pokepay-mobile-sdk を
55 → 153 箇所に拡大) の spec から pokepay-sdk-generator#77 で再生成した。
主な変更は 2 つ。
1. ios/Classes/AutogenMethodHandlers.swift の呼び出し先を Autogen.BankAPI.<Tag> に
変更 (150 箇所)。ios-sdk#119 で生成コードが Autogen 名前空間へ隔離されたため、
未修飾の BankAPI.<Tag> を指したままだと、手書き側に同名の型が無い操作で
コンパイルできない。
2. spec の拡大にともなう Dart 層と両ネイティブリンクの生成物の更新。
Dart 呼び出し 104 → 154、Java/Swift の case 92 → 186。
android/src/main/java/.../AutogenMethodHandlers.java は元から
jp.pokepay.pokepaylib.BankAPI.autogen.* を import しており、パッケージ指定の
変更は不要だった (android-sdk は元から隔離できているため)。
手書きコードには一切変更なし。変更は lib/generated/ と両 AutogenMethodHandlers に閉じている。
検証:
flutter analyze No issues found!
dart run build_runner build 256 outputs
tool/check_native_links.dart 0 error / 89 warning
(ベースライン 27 からの増分 62 はすべて
手書き switch との重複カテゴリ、既存警告の悪化なし)
ネイティブリンクの型検査 ~/ios-sdk (Autogen 適用版) に対して Build complete!
pokepay-sdk-generator: pokepay/pokepay-sdk-generator#77
ios-sdk: pokepay/ios-sdk#119
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
pokepay-sdk-generator#77 で、ios-sdk の生成コードが
Sources/Pokepay/Autogen/とAutogen.*型名前空間へ隔離されました(再生成で手書き 55 ファイルが黙って上書きされていたため)。ios-sdk#119 がその移行です。flutter-sdk の生成物
ios/Classes/AutogenMethodHandlers.swiftは ios-sdk の型を呼び出しますが、未修飾のBankAPI.<Tag>を指したままでした。ios-sdk 側の生成コードがAutogen.BankAPI.<Tag>へ移ったため、追随しないと手書き側に同名の型が無い操作でコンパイルできません。変更内容
1. Swift ネイティブリンクの呼び出し先(150 箇所)
未修飾の呼び出しはゼロになりました。
android/src/main/java/jp/pokepay/pokepay_sdk/AutogenMethodHandlers.javaは元からjp.pokepay.pokepaylib.BankAPI.autogen.*を import しており、パッケージ指定の変更は不要でした(android-sdk は元からBankAPI/autogen/{requests,responses}/に隔離できているため)。2. spec 拡大にともなう生成物の更新
pokepay-server の
api-response-validation-testsブランチでx-pokepay-mobile-sdkが 55 → 153 箇所に拡大したことによる更新です。影響範囲
手書きコードには一切変更がありません。 変更は
lib/generated/と両AutogenMethodHandlersに閉じています。手書きのSwiftPokepaySdkPlugin.swift/PokepaySdkPlugin.java/lib/bank_api/**は無変更です。pubspec.lockはpub getの副作用で差分が出ましたが、コード生成に効くパッケージ(json_serializable/json_annotation/source_gen/build_runner/dart_style)はすべて同一バージョンで、無関係な transitive 依存のドリフトだったため戻しています。検証
flutter analyzedart run build_runner buildtool/check_native_links.dartcheck_native_links の警告について
ベースライン(再生成前)が 27 warning、再生成後が 89 warning です。増分 62 件はすべて同一カテゴリで、「手書き switch と AutogenMethodHandlers の両方に case があり、手書き側が優先されて生成側は到達しない」というものです(iOS / Android 各 31 メソッド)。error はゼロ、既存警告の悪化もありません。
ビルドは壊れませんが生成側が死にコードになるため、手書き case を整理するかは別途の判断事項です。
ネイティブリンクの型検査について
この環境には Xcode が無いため(CLT のみ)、実機・シミュレータでのビルドは行えません。代わりに、生成物
AutogenMethodHandlers.swiftがimport Flutterするものの Flutter のシンボルを一切使わないことを利用し、空のFlutterモジュールとMethodCallTask(flutterEnvToSDKEnvとafterの 2 メソッドのみ)のシムを用意して、ios-sdk#119 適用済みの ios-sdk に対して型検査しました。1252 行すべてがAutogen.BankAPI.*の型と整合することを確認しています。マージ順序
Autogen.BankAPI.*が存在するようになる)Autogen.BankAPI.*を呼ぶようになる2 と 3 の間に依存があります。この PR を先にマージすると、ios-sdk に
Autogen.BankAPI.*がまだ無いためコンパイルできません。🤖 Generated with Claude Code