Skip to content

Prefix json_annotation helpers when imported with a prefix - #1588

Open
AzazelSensei wants to merge 1 commit into
google:masterfrom
AzazelSensei:fix/json-annotation-import-prefix-1199
Open

Prefix json_annotation helpers when imported with a prefix#1588
AzazelSensei wants to merge 1 commit into
google:masterfrom
AzazelSensei:fix/json-annotation-import-prefix-1199

Conversation

@AzazelSensei

Copy link
Copy Markdown

Summary

  • Add a single jsonAnnotationHelperPrefix helper that returns '' or 'prefix.' for the package:json_annotation import.
  • Qualify generated $checkedCreate, $checkKeys, and $enumDecode / $enumDecodeNullable calls with that prefix.
  • Leave $checkedConvert unqualified; it is the local callback parameter name inside $checkedCreate.

Fixes #1199
Fixes #1115

Follows the review direction from #1116: one prefix helper, no scattered ifs.

Test plan

  • dart test test/json_serializable_test.dart (includes new CheckedWithPrefix / EnumWithPrefix goldens)
  • dart test test/integration/integration_test.dart (includes new prefixed import round-trip)
  • dart test test/enum_helper_test.dart

Generated `$checkedCreate`, `$checkKeys`, and `$enumDecode*` calls now
honor an import prefix on `package:json_annotation`, fixing checked-mode
and enum decode analyze errors.

Fixes google#1199
Fixes google#1115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid code generated for checked: true when json_annotation is imported with a prefix Allow usage of prefix for the import of json_annotation.dart

1 participant