[ 
https://issues.apache.org/jira/browse/THRIFT-5414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Bruggink updated THRIFT-5414:
------------------------------------
    Description: 
The csharp service client generator creates some local variables that prevent 
the usage of those names in the Thrift file.

 For example the following thrift file breaks:

{code:c++}
service Test {
    void Calculate( 
                1 : i32 x, # This breaks because the variable name x is the 
same as the TApplicationException variable name x
                2 : i32 result, # This breaks because the variable name result 
is the same as the InternalStructs variable name result
        )
}
{code}
The above example will generate the following C# code which does not compile 
because x and result are also used below:
{code:c#}
public async global::System.Threading.Tasks.Task Calculate(int x, int result, 
CancellationToken cancellationToken = default)
{
    await OutputProtocol.WriteMessageBeginAsync(new TMessage("Calculate", 
TMessageType.Call, SeqId), cancellationToken);
    
    var args = new InternalStructs.CalculateArgs() {
        X = x,
        Result = result,
    };
    
    await args.WriteAsync(OutputProtocol, cancellationToken);
    await OutputProtocol.WriteMessageEndAsync(cancellationToken);
    await OutputProtocol.Transport.FlushAsync(cancellationToken);
    
    var msg = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
    if (msg.Type == TMessageType.Exception)
    {
        var x = await TApplicationException.ReadAsync(InputProtocol, 
cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        throw x;
    }

    var result = new InternalStructs.CalculateResult();
    await result.ReadAsync(InputProtocol, cancellationToken);
    await InputProtocol.ReadMessageEndAsync(cancellationToken);
    return;
}
{code}
When compiling this code with `-gen java` the generated sources build fine.


  was:
The csharp service client generator creates some local variables that prevent 
the usage of those names in the Thrift file.

 For example the following thrift file breaks:

{code:c++}
service Test {
    void Calculate( 
                1 : i32 x, # This breaks because the variable name x is the 
same as the TApplicationException variable name x
                2 : i32 result, # This breaks because the variable name result 
is the same as the TApplicationException variable name x
        )
}
{code}
The above example will generate the following C# code which does not compile 
because x and result are also used below:
{code:c#}
public async global::System.Threading.Tasks.Task Calculate(int x, int result, 
CancellationToken cancellationToken = default)
{
    await OutputProtocol.WriteMessageBeginAsync(new TMessage("Calculate", 
TMessageType.Call, SeqId), cancellationToken);
    
    var args = new InternalStructs.CalculateArgs() {
        X = x,
        Result = result,
    };
    
    await args.WriteAsync(OutputProtocol, cancellationToken);
    await OutputProtocol.WriteMessageEndAsync(cancellationToken);
    await OutputProtocol.Transport.FlushAsync(cancellationToken);
    
    var msg = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
    if (msg.Type == TMessageType.Exception)
    {
        var x = await TApplicationException.ReadAsync(InputProtocol, 
cancellationToken);
        await InputProtocol.ReadMessageEndAsync(cancellationToken);
        throw x;
    }

    var result = new InternalStructs.CalculateResult();
    await result.ReadAsync(InputProtocol, cancellationToken);
    await InputProtocol.ReadMessageEndAsync(cancellationToken);
    return;
}
{code}
When compiling this code with `-gen java` the generated sources build fine.



> Use of specific parameter names breaks csharp build
> ---------------------------------------------------
>
>                 Key: THRIFT-5414
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5414
>             Project: Thrift
>          Issue Type: Bug
>            Reporter: Thomas Bruggink
>            Priority: Minor
>
> The csharp service client generator creates some local variables that prevent 
> the usage of those names in the Thrift file.
>  For example the following thrift file breaks:
> {code:c++}
> service Test {
>     void Calculate( 
>               1 : i32 x, # This breaks because the variable name x is the 
> same as the TApplicationException variable name x
>               2 : i32 result, # This breaks because the variable name result 
> is the same as the InternalStructs variable name result
>       )
> }
> {code}
> The above example will generate the following C# code which does not compile 
> because x and result are also used below:
> {code:c#}
> public async global::System.Threading.Tasks.Task Calculate(int x, int result, 
> CancellationToken cancellationToken = default)
> {
>     await OutputProtocol.WriteMessageBeginAsync(new TMessage("Calculate", 
> TMessageType.Call, SeqId), cancellationToken);
>     
>     var args = new InternalStructs.CalculateArgs() {
>         X = x,
>         Result = result,
>     };
>     
>     await args.WriteAsync(OutputProtocol, cancellationToken);
>     await OutputProtocol.WriteMessageEndAsync(cancellationToken);
>     await OutputProtocol.Transport.FlushAsync(cancellationToken);
>     
>     var msg = await InputProtocol.ReadMessageBeginAsync(cancellationToken);
>     if (msg.Type == TMessageType.Exception)
>     {
>         var x = await TApplicationException.ReadAsync(InputProtocol, 
> cancellationToken);
>         await InputProtocol.ReadMessageEndAsync(cancellationToken);
>         throw x;
>     }
>     var result = new InternalStructs.CalculateResult();
>     await result.ReadAsync(InputProtocol, cancellationToken);
>     await InputProtocol.ReadMessageEndAsync(cancellationToken);
>     return;
> }
> {code}
> When compiling this code with `-gen java` the generated sources build fine.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to