Skip to content

Commit

Permalink
#328 Fix - Getting role ends with exception (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
zapadi authored Aug 29, 2023
1 parent 49a9eb6 commit 85fec9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
18 changes: 10 additions & 8 deletions src/redmine-net-api/Serialization/XmlRedmineSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public XmlRedmineSerializer(XmlWriterSettings xmlWriterSettings)
}
catch (Exception ex)
{
throw new RedmineException(ex.Message, ex);
throw new RedmineException(ex.GetBaseException().Message, ex);
}
}

Expand All @@ -62,7 +62,7 @@ public XmlRedmineSerializer(XmlWriterSettings xmlWriterSettings)
}
catch (Exception ex)
{
throw new RedmineException(ex.Message, ex);
throw new RedmineException(ex.GetBaseException().Message, ex);
}
}

Expand All @@ -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
Expand All @@ -91,7 +91,7 @@ public string Serialize<T>(T entity) where T : class
}
catch (Exception ex)
{
throw new RedmineException(ex.Message, ex);
throw new RedmineException(ex.GetBaseException().Message, ex);
}
}

Expand All @@ -109,12 +109,14 @@ public string Serialize<T>(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);

Expand Down
14 changes: 2 additions & 12 deletions src/redmine-net-api/Types/Permission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 85fec9b

Please sign in to comment.