You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For our use case, we add ~186 facts to the report. Sometimes the value is null, and the receiving party does not allow empty facts. So instead of adding 102 if-statements surrounding the AddFact methods we just cleanup the report afterwards.
We cannot just loop all facts and remove where Value is null, because the Remove method on the FactCollection will fail with a NullReferenceException. Because the base type collection relies on the GetHashCode and Equals methods of the Fact class, which both assume Value is never null.
Our solution is now to remove by index, but I felt like fixing this underlying issue would be the better approach:
for(inti=report.Facts.Count-1;i>=0;i--){if(string.IsNullOrEmpty(report.Facts[i].Value)){report.Facts.RemoveAt(i);// cannot use Remove(fact) here because of `NullReferenceException`}}
The text was updated successfully, but these errors were encountered:
For our use case, we add ~186 facts to the report. Sometimes the value is
null
, and the receiving party does not allow empty facts. So instead of adding 102 if-statements surrounding theAddFact
methods we just cleanup the report afterwards.We cannot just loop all facts and remove where Value is null, because the
Remove
method on theFactCollection
will fail with aNullReferenceException
. Because the base type collection relies on theGetHashCode
andEquals
methods of theFact
class, which both assumeValue
is never null.https://github.com/dgm9704/Xoxo/blob/main/Diwen.Xbrl/Xml/Fact.cs#L207
https://github.com/dgm9704/Xoxo/blob/main/Diwen.Xbrl/Xml/Fact.cs#L215
Our solution is now to remove by index, but I felt like fixing this underlying issue would be the better approach:
The text was updated successfully, but these errors were encountered: