Skip to content

Commit 3c93b0a

Browse files
claudiamurialdoclaudiamurialdo
andauthored
Fix XML deserialization issue for GXCData (#1227)
Co-authored-by: claudiamurialdo <[email protected]>
1 parent 3adc692 commit 3c93b0a

File tree

7 files changed

+481
-14
lines changed

7 files changed

+481
-14
lines changed

dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,11 +2201,7 @@ public override short readxmlcollection(GXXMLReader oReader, string sName, strin
22012201
return 0;
22022202
}
22032203
}
2204-
#if !NETCORE
2205-
public class GXCData : Object, IXmlSerializable
2206-
#else
2207-
public class GXCData : Object
2208-
#endif
2204+
public class GXCData : IXmlSerializable
22092205
{
22102206
public string content;
22112207

@@ -2217,7 +2213,6 @@ public GXCData(string s)
22172213
{
22182214
content = s;
22192215
}
2220-
#if !NETCORE
22212216
public System.Xml.Schema.XmlSchema GetSchema()
22222217
{
22232218
return new System.Xml.Schema.XmlSchema();
@@ -2230,13 +2225,8 @@ public void WriteXml(System.Xml.XmlWriter writer)
22302225
{
22312226
writer.WriteCData(content);
22322227
}
2233-
#endif
22342228
}
2235-
#if !NETCORE
2236-
public class GXXmlRaw : Object, IXmlSerializable
2237-
#else
2238-
public class GXXmlRaw : Object
2239-
#endif
2229+
public class GXXmlRaw : IXmlSerializable
22402230
{
22412231
public string content;
22422232

@@ -2248,7 +2238,6 @@ public GXXmlRaw(string s)
22482238
{
22492239
content = s;
22502240
}
2251-
#if !NETCORE
22522241
public System.Xml.Schema.XmlSchema GetSchema()
22532242
{
22542243
return new System.Xml.Schema.XmlSchema();
@@ -2261,7 +2250,6 @@ public void WriteXml(System.Xml.XmlWriter writer)
22612250
{
22622251
writer.WriteRaw(content);
22632252
}
2264-
#endif
22652253
}
22662254

22672255
public class GXProperties : NameObjectCollectionBase, IGxJSONSerializable, IGxJSONAble

dotnet/test/DotNetCoreUnitTest/Domain/SdtXmlSerializationTest.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.IO;
12
using GeneXus.Application;
23
using GeneXus.Programs;
34
using Xunit;
@@ -25,5 +26,17 @@ public void EmptyValuesDeserializationTest()
2526
Assert.True(shouldSerializeField, "Departamento should be serialized since it was assigned during XML deserialization");
2627

2728
}
29+
30+
[Fact]
31+
public void GXCDataDeserializationTest()
32+
{
33+
GxContext context = new GxContext();
34+
SdtInvoicyretorno invoice = new SdtInvoicyretorno(context);
35+
string xml = File.ReadAllText("invoicy.xml");
36+
37+
invoice.FromXml(xml, null, "Invoicyretorno", "InvoiCy");
38+
Assert.Contains("40047", invoice.ToJSonString(), System.StringComparison.OrdinalIgnoreCase);
39+
40+
}
2841
}
2942
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
File: type_SdtInvoicyretorno
3+
Description: Invoicyretorno
4+
Author: Nemo 🐠 for C# (.NET) version 18.0.13.186668
5+
Program type: Callable routine
6+
Main DBMS:
7+
*/
8+
using GeneXus.Application;
9+
using GeneXus.Utils;
10+
using System.Collections;
11+
using System.Xml.Serialization;
12+
13+
14+
namespace GeneXus.Programs
15+
{
16+
[XmlRoot(ElementName="Invoicyretorno")]
17+
[XmlType(TypeName="Invoicyretorno" , Namespace="InvoiCy" )]
18+
public class SdtInvoicyretorno : GxUserType
19+
{
20+
public SdtInvoicyretorno( )
21+
{
22+
/* Constructor for serialization */
23+
}
24+
25+
public SdtInvoicyretorno(IGxContext context)
26+
{
27+
this.context = context;
28+
initialize();
29+
}
30+
31+
#region Json
32+
private static Hashtable mapper;
33+
public override string JsonMap(string value)
34+
{
35+
if (mapper == null)
36+
{
37+
mapper = new Hashtable();
38+
}
39+
return (string)mapper[value]; ;
40+
}
41+
42+
public override void ToJSON()
43+
{
44+
ToJSON(true) ;
45+
return;
46+
}
47+
48+
public override void ToJSON(bool includeState)
49+
{
50+
if (gxTv_SdtInvoicyretorno_Mensagem != null)
51+
{
52+
AddObjectProperty("Mensagem", gxTv_SdtInvoicyretorno_Mensagem, false);
53+
}
54+
return;
55+
}
56+
#endregion
57+
58+
#region Properties
59+
60+
[SoapElement(ElementName="Mensagem" )]
61+
[XmlArray(ElementName="Mensagem" )]
62+
[XmlArrayItemAttribute(ElementName="MensagemItem" , IsNullable=false )]
63+
public GXBaseCollection<SdtInvoicyretorno_MensagemItem> gxTpr_Mensagem
64+
{
65+
get {
66+
if ( gxTv_SdtInvoicyretorno_Mensagem == null )
67+
{
68+
gxTv_SdtInvoicyretorno_Mensagem = new GXBaseCollection<SdtInvoicyretorno_MensagemItem>( context, "Invoicyretorno.MensagemItem", "");
69+
}
70+
SetDirty("Mensagem");
71+
return gxTv_SdtInvoicyretorno_Mensagem;
72+
}
73+
set {
74+
gxTv_SdtInvoicyretorno_Mensagem_N = false;
75+
gxTv_SdtInvoicyretorno_Mensagem = value;
76+
SetDirty("Mensagem");
77+
}
78+
}
79+
80+
public void gxTv_SdtInvoicyretorno_Mensagem_SetNull()
81+
{
82+
gxTv_SdtInvoicyretorno_Mensagem_N = true;
83+
gxTv_SdtInvoicyretorno_Mensagem = null;
84+
}
85+
86+
public bool gxTv_SdtInvoicyretorno_Mensagem_IsNull()
87+
{
88+
return gxTv_SdtInvoicyretorno_Mensagem == null;
89+
}
90+
public bool ShouldSerializegxTpr_Mensagem_GxSimpleCollection_Json()
91+
{
92+
return gxTv_SdtInvoicyretorno_Mensagem != null && gxTv_SdtInvoicyretorno_Mensagem.Count > 0;
93+
94+
}
95+
96+
97+
public override bool ShouldSerializeSdtJson()
98+
{
99+
return (
100+
ShouldSerializegxTpr_Mensagem_GxSimpleCollection_Json() ||
101+
false);
102+
}
103+
104+
105+
106+
#endregion
107+
108+
#region Static Type Properties
109+
110+
[XmlIgnore]
111+
private static GXTypeInfo _typeProps;
112+
protected override GXTypeInfo TypeInfo { get { return _typeProps; } set { _typeProps = value; } }
113+
114+
#endregion
115+
116+
#region Initialization
117+
118+
public void initialize( )
119+
{
120+
gxTv_SdtInvoicyretorno_Mensagem_N = true;
121+
122+
return ;
123+
}
124+
125+
126+
127+
#endregion
128+
129+
#region Declaration
130+
131+
protected bool gxTv_SdtInvoicyretorno_Mensagem_N;
132+
protected GXBaseCollection<SdtInvoicyretorno_MensagemItem> gxTv_SdtInvoicyretorno_Mensagem = null;
133+
134+
135+
136+
#endregion
137+
}
138+
139+
}

0 commit comments

Comments
 (0)