[ 
https://issues.apache.org/jira/browse/THRIFT-2942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14275693#comment-14275693
 ] 

Luca Sacchi commented on THRIFT-2942:
-------------------------------------

this is my quick fix. It's works for me..

index 05a084a..5a7a500 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -2525,6 +2525,14 @@ void 
t_csharp_generator::prepare_member_name_mapping(void* scope,
         newname += '_';
       }
 
+      // new name conflict with defined methods
+      if (newname.compare("Read") == 0 || newname.compare("Write") == 0) {
+        pverbose("struct %s: member %s conflicts with defined method\n",
+        structname.c_str(),
+        newname.c_str());
+        newname += '_';
+      }
+
       // new name conflicts with another member
       if (used_member_names.find(newname) != used_member_names.end()) {
         pverbose("struct %s: member %s conflicts with another member\n",

> CSharp generate invalid code for property named read or write
> -------------------------------------------------------------
>
>                 Key: THRIFT-2942
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2942
>             Project: Thrift
>          Issue Type: Bug
>          Components: C# - Compiler
>    Affects Versions: 0.9.2, 1.0
>            Reporter: Luca Sacchi
>            Assignee: Jens Geyer
>
> C# generator will produce invalid code for this
> struct CsFail {
> 1: optional bool read
> 2: optional bool write
> }
> this will generate code that that will not compile, due to name clash between 
> :
>   public bool Read
>   {
>     get
>     {
>       return _read;
>     }
>     set
>     {
>       __isset.@read = true;
>       this._read = value;
>     }
>   }
> and Read method implementation
> public void Read (TProtocol iprot)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to