diff --git a/src/ExtendedXmlSerializer/ExtensionModel/Xml/XmlReader.cs b/src/ExtendedXmlSerializer/ExtensionModel/Xml/XmlReader.cs index b6d96cdfa..b63931427 100644 --- a/src/ExtendedXmlSerializer/ExtensionModel/Xml/XmlReader.cs +++ b/src/ExtendedXmlSerializer/ExtensionModel/Xml/XmlReader.cs @@ -1,8 +1,8 @@ -using System.Reflection; -using System.Xml; using ExtendedXmlSerializer.ContentModel.Content; using ExtendedXmlSerializer.ContentModel.Format; using ExtendedXmlSerializer.ContentModel.Identification; +using System.Reflection; +using System.Xml; namespace ExtendedXmlSerializer.ExtensionModel.Xml { @@ -43,6 +43,7 @@ public string Content() { switch (_reader.NodeType) { + case XmlNodeType.Attribute: return _reader.Value; default: @@ -61,7 +62,7 @@ public string Content() var result = isNull ? null : _reader.Value; - if (!string.IsNullOrEmpty(result)) + if (!string.IsNullOrEmpty(result) || _reader.NodeType == XmlNodeType.CDATA) { _reader.Read(); Set(); diff --git a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue442Tests.cs b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue442Tests.cs new file mode 100644 index 000000000..9c84da075 --- /dev/null +++ b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue442Tests.cs @@ -0,0 +1,74 @@ +using ExtendedXmlSerializer.Configuration; +using ExtendedXmlSerializer.Tests.ReportedIssues.Shared.Issue442; +using ExtendedXmlSerializer.Tests.ReportedIssues.Support; +using FluentAssertions; +using Xunit; + +namespace ExtendedXmlSerializer.Tests.ReportedIssues +{ + public sealed class Issue442Tests + { + [Fact] + public void Verify() + { + const string content = @" + #Q_ValveA#, + Q_ValveB => #Q_ValveB#, + Q_ValveOpenClamping => #Q_ValveOpenClamping#);]]> + + + + + + + 16 + + + + + + + + + + + + + "; + + var serializer = new ConfigurationContainer().InspectingType() + .EnableImplicitTyping(typeof(SiemensDeviceTemplate)) + .Create() + .ForTesting(); + + serializer.Deserialize(content) + .WatchAndForceTableEntires.Should() + .NotBeNull() + .And.Subject.Should() + .NotBeEmpty(); + } + } +} \ No newline at end of file diff --git a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/IDeviceTemplate.cs b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/IDeviceTemplate.cs new file mode 100644 index 000000000..128625d36 --- /dev/null +++ b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/IDeviceTemplate.cs @@ -0,0 +1,4 @@ +namespace ExtendedXmlSerializer.Tests.ReportedIssues.Shared.Issue442 +{ + public interface IDeviceTemplate {} +} \ No newline at end of file diff --git a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/SiemensDeviceTemplate.cs b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/SiemensDeviceTemplate.cs new file mode 100644 index 000000000..456eacd46 --- /dev/null +++ b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/SiemensDeviceTemplate.cs @@ -0,0 +1,43 @@ +using ExtendedXmlSerializer.ContentModel.Content; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace ExtendedXmlSerializer.Tests.ReportedIssues.Shared.Issue442 +{ + [XmlRoot("Device", Namespace = "")] + public class SiemensDeviceTemplate : IDeviceTemplate + { + [XmlAttribute("fb")] + public string FB { get; set; } + + [Verbatim] + [XmlElement("Definition")] + public string Definition { get; set; } + + [Verbatim] + [XmlElement("DeviceDataDb")] + public string DeviceDataDb { get; set; } + + [Verbatim] + [XmlElement("ServiceHandler")] + public string ServiceHandler { get; set; } + + [Verbatim] + [XmlElement("ParameterDb")] + public string ParameterDb { get; set; } + + [Verbatim] + [XmlElement(ElementName = "Releases")] + public string Releases { get; set; } + + [XmlAttribute("commandStruct")] + public string CommandStruct { get; set; } + + [Verbatim] + [XmlElement("CommandStart")] + public string CommandStart { get; set; } + + [XmlElement("WatchAndForceTable")] + public List WatchAndForceTableEntires { get; set; } + } +} diff --git a/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/WatchAndForceTableTemplate.cs b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/WatchAndForceTableTemplate.cs new file mode 100644 index 000000000..75d3c6393 --- /dev/null +++ b/test/ExtendedXmlSerializer.Tests.ReportedIssues/Shared/Issue442/WatchAndForceTableTemplate.cs @@ -0,0 +1,11 @@ +using System.Xml.Serialization; + +namespace ExtendedXmlSerializer.Tests.ReportedIssues.Shared.Issue442 +{ + [XmlRoot("WatchAndForceTableEntry")] + public class WatchAndForceTableTemplate + { + [XmlAttribute("name")] + public string Name { get; set; } + } +} \ No newline at end of file