Joslian / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Referenced namespaces are not CamelCased in generated C# #98

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. Create a.proto with:
------------------------------------
package com.test.a.messages;

message TestA {
    required string value = 1;
}
------------------------------------

2. Create b.proto with:
------------------------------------
import "a.proto";
package com.test.b.messages;

message TestB {
    required com.test.a.messages.TestA ref = 1;
}
------------------------------------

3. Generate C# code with the fixCase option.

4. Note that the namespace at the top of the generated C# was camel cased 
to "Com.Test.A.Messages", but the ref param is "com.test.a.messages.TestA".

Original issue reported on code.google.com by scoo...@gmail.com on 3 Mar 2010 at 12:26

GoogleCodeExporter commented 9 years ago
Sorry for the confusion, it turns out this is not a problem with imported 
namespaces... it is only a problem with packaged .proto files that have rpc 
definitions and use fixCase, for example:

------------------------------------
package com.test.a.messages;

message TestA {
    required string value = 1;
}

service Renewal
{
    rpc TestMethod(TestA) returns (TestA);
}
------------------------------------

The above (with fixCase) will put TestA in "Com.Test.A.Messages", but will 
define 
TestMethod as:
com.test.a.messages.TestA TestMethod(com.test.a.messages.TestA request);

... the fix for this was pretty easy, I replaced:
  <xsl:template match="MethodDescriptorProto/input_type | 
MethodDescriptorProto/output_type">
    <xsl:value-of select="substring-after(.,'.')"/>
  </xsl:template>

with:
  <xsl:template match="MethodDescriptorProto/input_type | 
MethodDescriptorProto/output_type">
    <xsl:call-template name="pascal">
      <xsl:with-param name="value" select="substring-after(.,'.')"/>
    </xsl:call-template>
  </xsl:template>

Original comment by scoo...@gmail.com on 3 Mar 2010 at 1:30

GoogleCodeExporter commented 9 years ago
OK - I'll investigate. Thanks.

Original comment by marc.gravell on 3 Mar 2010 at 7:48