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

Grpc.Tools: support generated filename corner cases #18470

Merged
merged 3 commits into from Mar 22, 2019

Conversation

kkm000
Copy link
Contributor

@kkm000 kkm000 commented Mar 22, 2019

protoc and gRPC codegens differently treat non-ASCII letter characters and symbols other than underscores when constructing their respective output filenames for generated .cs files. This change reproduces their respective behaviors exactly.

I added test cases similar to my hello.world.proto flop, and verified the built dll by dropping it into the .nuget directory on a Linux machine. Build failed with a repro of #17661 before, succeeded after.

Closes #17661

protoc and gRPC codegens differently treat non-ASCII letter
characters and symbols other than underscores when constructing
their respective output filenames for generated .cs files.
This change reproduces their respective behaviors exactly.

Fixes grpc#17661
@jtattermusch jtattermusch self-assigned this Mar 22, 2019
@jtattermusch jtattermusch added lang/C# release notes: yes Indicates if PR needs to be in release notes kokoro:run labels Mar 22, 2019
@@ -109,6 +108,26 @@ string LowerUnderscoreToUpperCamel(string str)
}
return result.ToString();
}

// This is how the protoc codegen constructs its output filename.
// See protobuf/compiler/csharp/csharp_helpers.cc:356.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, this is where I got it from. Looks like I gave a wrong line number, will fix in a moment.

I do not understand what is this last # check at the very end of the function, but it does not seem to be important?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

{
result.Append(cap ? upperC : c);
}
cap = !isAsciiLetter;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe there's still a subtle problem - after a digit, protoc will still capitalize the next letter:
I tested and one123two.cs generates One123Two.cs and One123twoGrpc.cs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uhhhh, thanks! I'll take care of this.

Copy link
Contributor Author

@kkm000 kkm000 Mar 22, 2019

Choose a reason for hiding this comment

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

This passes, I added a test and verified a real build, too. cap = !isAsciiLetter; will be true after a digit, as well as after any (non-emitted) other character. I'll push the test case tho, so that we have it, just in case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, aa40424.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, thanks for clarification!

Copy link
Contributor

@jtattermusch jtattermusch left a comment

Choose a reason for hiding this comment

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

LGTM.

@jtattermusch
Copy link
Contributor

Known failures:
#18477
#13379

@jtattermusch jtattermusch merged commit 1805e2e into grpc:master Mar 22, 2019
@jtattermusch jtattermusch changed the title C# tools: support generated filename corner cases C# Grpc.Tools: support generated filename corner cases Apr 9, 2019
@jtattermusch jtattermusch changed the title C# Grpc.Tools: support generated filename corner cases Grpc.Tools: support generated filename corner cases Apr 9, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang/C# release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grpc.Tools causes a build error when .proto file name contains dot
3 participants