Repository navigation
Add optional UniTask support (1.2.0) - #12
Merged
Merged
Conversation
New com.severnbli.localization-codegen.UniTask assembly, compiled only when UniTask (com.cysharp.unitask >= 2.0.0) is installed - via an asmdef version define - or when LOCALIZATION_CODEGEN_UNITASK is defined for projects that keep UniTask under Assets/. - LocalizedTablesUniTask.GetStringAsync / GetAssetAsync return UniTask and take a CancellationToken. Positional and named smart string arguments follow the same rules as the synchronous LocalizedTables methods; missing LocalizationSettings return the key / null like the synchronous helpers. - GetLocalizedStringUniTask() extension for LocalizedString (for Ref members and hand-written references). - Results are read in the completion callback because Localization auto-releases its operations; cancelling only stops the wait. - Runtime tests cover the no-settings fallbacks, pre-cancelled tokens, pending, cancelled, completed, failed and invalid operations. - The 2022.3 test project installs UniTask from OpenUPM; the 6000.3.1f1 project does not, so CI covers both the add-on and its absence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Ref class emitted `new LocalizedSprite(TableName, "Key")` for asset table entries, but LocalizedAsset<T> and its subclasses (LocalizedSprite, LocalizedObject, LocalizedMesh, LocalizedAudioClip, ...) only have a parameterless constructor, so any project with "Generate Reference Members" and an asset table got CS1729 errors in the generated code. Use an object initializer that sets TableReference and TableEntryReference instead. LocalizedString keeps its constructor. Found by the new generated-code compilation test (next commit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generator - New "UniTask Members" setting (GenerateUniTask). When enabled, every string and asset member also gets a ...Async method returning UniTask that takes a CancellationToken; smart string methods keep their parameters and forward them to LocalizedTablesUniTask. - Async names are claimed after every key's own name, so turning the option on never renames an existing member; a key that already ends in "Async" pushes the variant to a suffix. The token parameter avoids smart string parameter names. - The option only takes effect when the UniTask add-on assembly is compiled; otherwise generation warns and skips it, since the code would not compile. The generated asmdef references UniTask when used. - The option signature only changes when UniTask is enabled, so existing hashes and files stay valid after upgrading. Tests - GeneratedCodeCompilationTests compiles emitted code for three option sets (full features, PascalCase in the global namespace, 1.0 output) with Unity's AssemblyBuilder, -warnaserror and XML docs enabled, with and without UniTask. It found the Ref asset constructor bug fixed in the previous commit. - Emitter tests for async members, argument forwarding, token and member name collisions, the option signature and the generated asmdef. - Integration test for the option with and without the add-on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The repository README was an older, shorter copy of the package README (no smart strings, Ref, CI or most settings). Both are now the same file, and check-package.sh fails when the README or CHANGELOG copies drift apart again. - Add a quick start, a navigation bar, a UniTask badge and an updated feature table. - New UniTask section and settings row; UniTask in the requirements. - Explain what Ref members are for (references that follow locale changes, e.g. LocalizeStringEvent.StringReference and StringChanged), not just how they look. - Mention that CheckBatch catches hand-edited generated files and list the editor window buttons from the old root README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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.
Summary
This adds optional UniTask support and bumps the version to 1.2.0. Turn on UniTask Members and each generated member gets an awaitable
…Asyncvariant next to it:Projects without UniTask aren't affected at all. The new assembly compiles only when UniTask is installed.
Commits
fc504bfAdd optional UniTask runtime assemblycom.severnbli.localization-codegen.UniTaskassembly, gated by an asmdef version define oncom.cysharp.unitask(or theLOCALIZATION_CODEGEN_UNITASKdefine when UniTask lives underAssets/). It addsLocalizedTablesUniTask.GetStringAsync/GetAssetAsyncwith cancellation, plus aLocalizedString.GetLocalizedStringUniTask()extension. The result is read inside the completion callback because Localization releases its operations automatically. Comes with 10 runtime tests.e27f077Fix Ref members of asset tables not compilingRefemittednew LocalizedSprite(TableName, "Key"), butLocalizedAsset<T>and its subclasses only have a parameterless constructor. Any project with Generate Reference Members and an asset table got CS1729 errors. The emitter now uses an object initializer.ab4ac0fGenerate UniTask members and compile generated code in tests.asmdefreferences UniTask. NewGeneratedCodeCompilationTestscompiles the emitted code with Unity'sAssemblyBuilder, with warnings as errors and XML docs on, across 3 option sets, with and without UniTask. This test found theRefbug above.b1c4ac9Sync the READMEs, document UniTask and explain Ref memberscheck-package.shfails if the README or CHANGELOG copies drift apart. Adds a quick start, a nav bar, an updated feature table, the UniTask docs, and an explanation of whatRefis for.c75f7ecBump version to 1.2.0package.json,Installer.Version, the README install snippet, both changelogs.CI coverage
Test plan
commands/check-package.shpasses, and fails when a README copy drifts🤖 Generated with Claude Code