From 19325616f44ef85ff553c5a37f9c09d424b6bdfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Goupil?= Date: Mon, 21 Jun 2021 08:21:22 -0700 Subject: [PATCH 1/2] Fixing potential null in some iterations. --- src/QbXml/QbXmlResponse.cs | 13 ++++++++----- src/XsdGenerator/MemberEnhancer.cs | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/QbXml/QbXmlResponse.cs b/src/QbXml/QbXmlResponse.cs index 8b8b6ef..53e91cf 100644 --- a/src/QbXml/QbXmlResponse.cs +++ b/src/QbXml/QbXmlResponse.cs @@ -87,15 +87,18 @@ public IEnumerable GetItemsFromResponse(string response, System.Type typ private IEnumerable SearchFor(QBXML qbXml, System.Type type) { - foreach (var item in qbXml.Items) + if (qbXml.Items != null) { - if (item is QBXMLMsgsRs typedItem) + foreach (var item in qbXml.Items) { - foreach (var innerItem in typedItem.Items) + if (item is QBXMLMsgsRs typedItem && typedItem.Items != null) { - if (innerItem.GetType() == type || type.IsAssignableFrom(innerItem.GetType())) + foreach (var innerItem in typedItem.Items) { - yield return innerItem; + if (innerItem.GetType() == type || type.IsAssignableFrom(innerItem.GetType())) + { + yield return innerItem; + } } } } diff --git a/src/XsdGenerator/MemberEnhancer.cs b/src/XsdGenerator/MemberEnhancer.cs index 04978b4..fca365d 100644 --- a/src/XsdGenerator/MemberEnhancer.cs +++ b/src/XsdGenerator/MemberEnhancer.cs @@ -390,7 +390,7 @@ private XmlSchemaElement GetSchemaElement(XmlSchemaComplexType xmlSchemaComplexT .FirstOrDefault(m => m.QualifiedName?.Name == name); // Let's try to search in the choices. - if (xmlSchemaElementFound == null) + if (xmlSchemaElementFound == null && xmlSchemaSequence.Items != null) { foreach (var choice in xmlSchemaSequence.Items.OfType()) { From 0cc6b6873cb3d2145e0faa9582db845f771ef85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Goupil?= Date: Mon, 21 Jun 2021 08:22:24 -0700 Subject: [PATCH 2/2] Bumping version. --- src/QbXml/QbXml.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QbXml/QbXml.csproj b/src/QbXml/QbXml.csproj index 915440c..24acf81 100644 --- a/src/QbXml/QbXml.csproj +++ b/src/QbXml/QbXml.csproj @@ -8,7 +8,7 @@ Jean-Sébastien Goupil Jean-Sébastien Goupil Copyright © Jean-Sébastien Goupil 2015-2021 - 3.0.1 + 3.0.2 QbSync.QbXml QbSync.QbXml QbSync.QbXml