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

fix(volo-build): escape keywords in code generation for idl service method arguments #496

Merged
merged 4 commits into from
Sep 18, 2024

Conversation

Ggiggle
Copy link
Contributor

@Ggiggle Ggiggle commented Sep 14, 2024

Motivation

To solve the #495 when a argument name in an IDL service method conflicts with a Rust syntax keyword, which results in a compilation error in the generated code.

service HelloService {
    HelloResponse Hello1 (1: HelloRequest type)
    HelloResponse Hello2 (1: HelloRequest self)
}

Solution

In the above example, type is a keyword in rust, so we will generate this field name as r#type in code. And when you use volo cli tool to initialize your project, this field name will be generated as _type in the server code template, so you should rename it as r#type when using it. In the two scenes, keyword like self will be generated as _self.

@Ggiggle Ggiggle self-assigned this Sep 14, 2024
@Ggiggle Ggiggle requested review from a team as code owners September 14, 2024 10:04
@Ggiggle Ggiggle changed the title fix: escape keywords in code generation for idl service method arguments fix(volo-build): escape keywords in code generation for idl service method arguments Sep 14, 2024
PureWhiteWu
PureWhiteWu previously approved these changes Sep 14, 2024
Millione
Millione previously approved these changes Sep 18, 2024
@Ggiggle Ggiggle dismissed stale reviews from Millione and PureWhiteWu via 3bc9115 September 18, 2024 06:48
PureWhiteWu
PureWhiteWu previously approved these changes Sep 18, 2024
@PureWhiteWu PureWhiteWu merged commit 9d40521 into main Sep 18, 2024
7 of 15 checks passed
@PureWhiteWu PureWhiteWu deleted the fix/keyword_escape branch September 18, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants