Skip to content

Commit

Permalink
Merge pull request #1757 from riganti/parser-fix
Browse files Browse the repository at this point in the history
Incorrect child nodes for array initializer fixed
  • Loading branch information
Mylan719 authored Jan 6, 2024
2 parents 80b626f + 63680a2 commit d376126
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public ArrayInitializerExpression(List<BindingParserNode> elementInitializers)
ElementInitializers = elementInitializers;
}

public override IEnumerable<BindingParserNode> EnumerateChildNodes() => base.EnumerateNodes().Concat(ElementInitializers);
public override IEnumerable<BindingParserNode> EnumerateChildNodes() => ElementInitializers;

public override string ToDisplayString() => $"[ {(string.Join(", ", ElementInitializers.Select(arg => arg.ToDisplayString())))} ]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,21 @@ @viewModel object

Assert.IsTrue(error.Contains("Cannot assign"), "Expected error about failed assignment into the attribute property.");
}

[TestMethod]
public void ResolvedTree_PropertyDirectiveArrayInicializer_ResolvedCorrectly()
{
var root = ParseSource(@$"
@viewModel object
@property string a=[, MarkupOptionsAttribute.Required = true");

var property = root.Directives["property"].SingleOrDefault() as IAbstractPropertyDeclarationDirective;

var nodes = property.InitializerSyntax.EnumerateChildNodes();

Assert.IsFalse(nodes.Any(n => n == property.InitializerSyntax));

Assert.AreEqual(2,nodes.Count());
}
}
}

0 comments on commit d376126

Please sign in to comment.