Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
fix NullReferenceException if IEnumerable contains no elements
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Jan 28, 2012
1 parent d4e447a commit d4ce5d7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Expand Up @@ -14,7 +14,7 @@ public partial class Utils
public static IEnumerable<TreeNode> LazyGetChildNodesOfArray(TreeNode parent, Expression expression, ArrayDimensions dimensions)
{
if (dimensions.TotalElementCount == 0)
return new TreeNode[] { new TreeNode(null, "(empty)", null, null, parent, null) };
return new TreeNode[] { new TreeNode(null, "(empty)", null, null, parent, _ => null) };

return new ArrayRangeNode(parent, expression, dimensions, dimensions).ChildNodes;
}
Expand Down
Expand Up @@ -117,9 +117,9 @@ public static IEnumerable<TreeNode> LazyGetItemsOfIList(TreeNode parent, Express
error = e;
}
if (error != null) {
yield return new TreeNode(null, "(error)", error.Message, null, null, null);
yield return new TreeNode(null, "(error)", error.Message, null, null, _ => null);
} else if (count == 0) {
yield return new TreeNode(null, "(empty)", null, null, null, null);
yield return new TreeNode(null, "(empty)", null, null, null, _ => null);
} else {
for(int i = 0; i < count; i++) {
string imageName;
Expand Down
2 changes: 2 additions & 0 deletions src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs
Expand Up @@ -118,6 +118,8 @@ public TreeNode(TreeNode parent)
public TreeNode(IImage iconImage, string name, string text, string type, TreeNode parent, Func<TreeNode, IEnumerable<TreeNode>> childNodes)
: this(parent)
{
if (childNodes == null)
throw new ArgumentNullException("childNodes");
this.iconImage = iconImage;
this.name = name;
this.text = text;
Expand Down

0 comments on commit d4ce5d7

Please sign in to comment.