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

Jens Geyer commented on THRIFT-1964:
------------------------------------

I have to admit that's more tricky than I thought. I extended the test case and 
added an optional field that is NOT set. 

{code}
namespace csharp Thrift.Test

struct A
{
  1: string message
  2: optional i32 value_not_set
}

struct B {
  1: bool isBool
  2: string message
  3: A a
}

struct C
{
  1:  A a
  2:  B b
}
{code}

Next, I added a second case where the data are serialized using the 
DataContractJsonSerializer, which also seems to use direct access instead of 
prop setters. Now, using Carls patch, I get the following results:


(1) Generated with *csharp* only, JSON succeeds but the XML case fails, because 
the isset is true after deserializing - the value from the "not set" field gets 
of course serialized and deserialized exactly as any other valid value, since 
the XmlSerializer does not care about our isset flag and just takes whatever 
value is there.

(2) Generated with *csharp:nullable*, both JSON and XML succeed. The JSON uses 
the "<type>k__BackingField" names in that case, but that's ok here.

(3) Generated with *csharp:serial*, both JSON and XML fail, for the same reason 
as XML fails at (1).

(4) Generated with *csharp:serial,nullable*, both JSON and XML succeed and use 
the proper names.

I have not tested WCF, but I add the modified test case.




                
> 'Isset' will cause xmlserializer crashed.
> -----------------------------------------
>
>                 Key: THRIFT-1964
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1964
>             Project: Thrift
>          Issue Type: Bug
>          Components: C# - Compiler
>    Affects Versions: 0.9
>         Environment: .net framework 3.5
>            Reporter: xq.gzh
>              Labels: Isset
>         Attachments: 1964-v2.patch, a.thrift, fix_isset_problem_test.zip, 
> fix_Isset_xmlserializer.patch, Program.cs, ReproduceTheIssue.zip, 
> THRIFT-1964_Isset_causes_xmlserializer_exeption.patch
>
>   Original Estimate: 8h
>  Remaining Estimate: 8h
>
> same class name 'Isset' in user defined class will cause xmlserializer 
> crashed. 
> below is the sample thrift:  
> struct A {
>  1: string x;
> }
> struct B {
>  1: string y;
> }
> struct C {
>  1:A a
>  2:B b
> }
> generate code and try xmlserialize instance of class C. it crashed.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to