Skip to content
Browse files

Fixed Issue #44: The ending TextLocation of an ArrayCreateExpression

is incorrect when the array is initialized with zero elements
  • Loading branch information...
1 parent 6a45cef commit 6f1325dea722cafa673a9bf0d3499995d3403618 @mkrueger mkrueger committed
View
2 ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
@@ -2850,7 +2850,7 @@ public override object Visit (ArrayCreation arrayCreationExpression)
next = next.Next;
}
- if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) {
+ if (arrayCreationExpression.Initializers != null) {
var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers);
ArrayInitializerExpression initializer = new ArrayInitializerExpression ();
View
13 ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ArrayCreateExpressionTests.cs
@@ -146,7 +146,18 @@ public void AssignmentInArrayInitializer()
}
}});
}
-
+
+ [Test]
+ public void EmptyArrayCreation()
+ {
+ var ace = ParseUtilCSharp.ParseExpression<ArrayCreateExpression>("new [] { }");
+ Assert.AreEqual(new Role[] {
+ Roles.LBrace,
+ Roles.RBrace
+ }, ace.Initializer.Children.Select(c => c.Role).ToArray());
+ }
+
+
[Test, Ignore("Parser bug")]
public void ArrayInitializerWithCommaAtEnd()
{

0 comments on commit 6f1325d

Please sign in to comment.
Something went wrong with that request. Please try again.