diff --git a/src/redmine-net-api/Serialization/XmlRedmineSerializer.cs b/src/redmine-net-api/Serialization/XmlRedmineSerializer.cs index 15d585d0..be1764a0 100644 --- a/src/redmine-net-api/Serialization/XmlRedmineSerializer.cs +++ b/src/redmine-net-api/Serialization/XmlRedmineSerializer.cs @@ -50,7 +50,7 @@ public XmlRedmineSerializer(XmlWriterSettings xmlWriterSettings) } catch (Exception ex) { - throw new RedmineException(ex.Message, ex); + throw new RedmineException(ex.GetBaseException().Message, ex); } } @@ -62,7 +62,7 @@ public XmlRedmineSerializer(XmlWriterSettings xmlWriterSettings) } catch (Exception ex) { - throw new RedmineException(ex.Message, ex); + throw new RedmineException(ex.GetBaseException().Message, ex); } } @@ -76,7 +76,7 @@ public XmlRedmineSerializer(XmlWriterSettings xmlWriterSettings) } catch (Exception ex) { - throw new RedmineException(ex.Message, ex); + throw new RedmineException(ex.GetBaseException().Message, ex); } } #pragma warning restore CA1822 @@ -91,7 +91,7 @@ public string Serialize(T entity) where T : class } catch (Exception ex) { - throw new RedmineException(ex.Message, ex); + throw new RedmineException(ex.GetBaseException().Message, ex); } } @@ -109,12 +109,14 @@ public string Serialize(T entity) where T : class throw new ArgumentNullException(nameof(xmlResponse), $"Could not deserialize null or empty input for type '{typeof(T).Name}'."); } - using (TextReader stringReader = new StringReader(xmlResponse)) + using (var stringReader = new StringReader(xmlResponse)) { - using (var xmlReader = XmlReader.Create(stringReader)) + using (var xmlReader = XmlTextReaderBuilder.Create(stringReader)) { - xmlReader.Read(); - xmlReader.Read(); + while (xmlReader.NodeType == XmlNodeType.None || xmlReader.NodeType == XmlNodeType.XmlDeclaration) + { + xmlReader.Read(); + } var totalItems = xmlReader.ReadAttributeAsInt(RedmineKeys.TOTAL_COUNT); diff --git a/src/redmine-net-api/Types/Permission.cs b/src/redmine-net-api/Types/Permission.cs index f912a2e9..13fb4e9d 100644 --- a/src/redmine-net-api/Types/Permission.cs +++ b/src/redmine-net-api/Types/Permission.cs @@ -54,19 +54,9 @@ public sealed class Permission : IXmlSerializable, IJsonSerializable, IEquatable public void ReadXml(XmlReader reader) { reader.Read(); - while (!reader.EOF) + if (reader.NodeType == XmlNodeType.Text) { - if (reader.IsEmptyElement && !reader.HasAttributes) - { - reader.Read(); - continue; - } - - switch (reader.Name) - { - case RedmineKeys.PERMISSION: Info = reader.ReadElementContentAsString(); break; - default: reader.Read(); break; - } + Info = reader.Value; } }