Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change JSON type suffix to $JSON #123

Merged
merged 1 commit into from Apr 25, 2024
Merged

Change JSON type suffix to $JSON #123

merged 1 commit into from Apr 25, 2024

Conversation

sidepelican
Copy link
Collaborator

以下のようなコードにおいて、重複したシンボルが生成されるという問題があります。

struct Foo {
  struct JSON {}}

FooのTS側JSON型としてFoo_JSONが。
Foo.JSONのTS側Entity型としてFoo_JSONが生成され、衝突します。

この問題の原因は、ネームスペース結合の記号とJSON型のSuffix結合の記号が同一の_であることだと思います。
片方の結合に用いる記号を変更することで回避ができます。

もちろん、Swift側の型名で_$が使われていた場合に似たような壊れが起こると思いますが、それは特殊なケースなので諦めます。

@@ -38,7 +38,7 @@ public struct DefaultTypeConverter {
}

public static func jsonName(entityName: String) -> String {
return "\(entityName)_JSON"
return "\(entityName)$JSON"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本質的な変更はここだけです

@sidepelican sidepelican requested a review from omochi April 25, 2024 02:48
Copy link
Owner

@omochi omochi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます
小さな変更に対して見かけの差分が派手だ。

@omochi omochi merged commit a3c1246 into main Apr 25, 2024
1 check passed
@omochi omochi deleted the json-suffix branch April 25, 2024 03:02
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.

None yet

2 participants