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

Protoc generates faulty C# namespace #13482

Closed
nickwinger opened this issue Aug 9, 2023 · 12 comments
Closed

Protoc generates faulty C# namespace #13482

nickwinger opened this issue Aug 9, 2023 · 12 comments
Assignees
Labels
c# inactive Denotes the issue/PR has not seen activity in the last 90 days.

Comments

@nickwinger
Copy link

nickwinger commented Aug 9, 2023

Hello,

i'm not sure if this is a bug or how to fix this, haven't found anything on the internet.
We have a package like "my.name.space._3".
This works in protobuf and java generated code.
However in C# generated code the unserscore gets removed, and then the C# Compiler tells an error about that namespace "my.name.space.3".
Seems like only having a number in the namespace in C# is not working.

So how to handle this issue ? And we cannot change the protobuf files, since they are delivered by 3rd party.

C:\protoc --version
libprotoc 24.0

actually it should have been fixed: #10268

Thanks for help,
Nick

@nickwinger nickwinger added the untriaged auto added to all issues by default when created. label Aug 9, 2023
@fowles fowles added c# and removed untriaged auto added to all issues by default when created. labels Aug 9, 2023
@jskeet
Copy link
Contributor

jskeet commented Aug 9, 2023

Please could you post your specific .proto file? (It's not clear what you mean by "namespace" here - protobuf package, or csharp_namespace option. If you want a specific C# namespace, the simple fix would be to specify it explicitly.)

@nickwinger
Copy link
Author

Hello,

i mean package in proto file, e.g.:

package my.scope._3

in C#:

namespace my.scope.3

the underscore gets removed which does not work in C#.
The bugfix i linked seem to only preserve the underscore before numbers at the beginning, but the routine has to check and preserve the underscore before numbers on every part of the package/namespace string separated by dots.

@jskeet
Copy link
Contributor

jskeet commented Aug 9, 2023

Right. I'd expect that to actually be modified to My.Scope.3.

I would suggest you just use an explicit namespace option for the moment, which will allow you to avoid both the capitalization and the underscore removal:

option csharp_namespace = "my.scope._3";

I'd expect that to work fine.

@nickwinger
Copy link
Author

Thank you for the suggestion, i will try it out as a workaround. However it’s not the best solution as we have to modify and scan the delivered 3rd party proto files

@jskeet
Copy link
Contributor

jskeet commented Aug 9, 2023

Thank you for the suggestion, i will try it out as a workaround. However it’s not the best solution as we have to modify and scan the delivered 3rd party proto files

Hopefully I'll be able to fix this at some point, but given that Protobuf isn't my main work and there is a workaround (which isn't true for some issues in the C# space), it's likely that it'll be a while before I get to this. If you were to contribute a PR that fixes this, that would be likely to speed things up.

@nickwinger
Copy link
Author

I will try to do a PR based on the fix that has already been made

@nickwinger
Copy link
Author

here is the PR: #13504

Copy link

github-actions bot commented Nov 9, 2023

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Nov 9, 2023
@jskeet
Copy link
Contributor

jskeet commented Nov 9, 2023

We still intend to address this, but it's unlikely to be in 2023 due to higher-priority issues.

@jskeet
Copy link
Contributor

jskeet commented Nov 9, 2023

(#13504 is merged, so presumably this is at least better than it was - but I believe there are still improvements we want to make.)

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Nov 10, 2023
Copy link

github-actions bot commented Feb 8, 2024

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Feb 8, 2024
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c# inactive Denotes the issue/PR has not seen activity in the last 90 days.
Projects
None yet
Development

No branches or pull requests

3 participants