Skip to content

Commit

Permalink
Fixed missing ranges for Qualified Assembly node
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Mikuš committed Nov 10, 2023
1 parent 1a327d1 commit 5e9bd67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public BindingParserNode ReadDirectiveTypeName()
}
}

return new AssemblyQualifiedNameBindingParserNode(typeName, assemblyName); //TODO: create node
return CreateNode(new AssemblyQualifiedNameBindingParserNode(typeName, assemblyName), startIndex);
}
else if (Peek() is BindingToken token)
{
Expand Down
19 changes: 11 additions & 8 deletions src/Tests/Parser/Binding/BindingParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -830,20 +830,23 @@ public void BindingParser_GenericExpression_MemberAccessInsteadOfType_Invalid()
}

[TestMethod]
[DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Domain.Company.Product")]
[DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Product")]
[DataRow("Domain.Company.Product.DotVVM.Feature.Type<string>[], Domain.Company.Product")]
[DataRow("Domain.Company.Product.DotVVM.Feature.Type<string>[], Product")]
public void BindingParser_ArrayType_AssemblyQualifiedName_ValidAssemblyName(string binding)
[DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Domain.Company.Product", "Domain.Company.Product.DotVVM.Feature.Type[]")]
[DataRow("Domain.Company.Product.DotVVM.Feature.Type[], Product", "Domain.Company.Product.DotVVM.Feature.Type[]")]
[DataRow("Domain.Company.Product.DotVVM.Feature.Type<string>[], Domain.Company.Product", "Domain.Company.Product.DotVVM.Feature.Type<string>[]")]
[DataRow("Domain.Company.Product.DotVVM.Feature.Type<string>[], Product", "Domain.Company.Product.DotVVM.Feature.Type<string>[]")]
public void BindingParser_ArrayType_AssemblyQualifiedName_ValidAssemblyName(string binding, string type)
{
var parser = bindingParserNodeFactory.SetupParser(binding);
var node = parser.ReadDirectiveTypeName() as AssemblyQualifiedNameBindingParserNode;
Assert.IsNotNull(node, "expected qualified name node.");
AssertNode(node, binding, 0, binding.Length);

var array = node.TypeName as ArrayTypeReferenceBindingParserNode;

Assert.IsNotNull(array, "Expected array type reference");
Assert.IsFalse(node.AssemblyName.HasNodeErrors);

AssertNode(array, type, 0, type.Length);
}

[TestMethod]
Expand Down Expand Up @@ -967,7 +970,7 @@ public void BindingParser_Lambda_WithTypeInfo_SingleParameter(string expr, strin

Assert.AreEqual(1, parameters.Count);

AssertNode(parameters[0].Type, type, 1, type.Length+1);
AssertNode(parameters[0].Type, type, 1, type.Length + 1);
AssertNode(parameters[0].Name, "arg", type.Length + 2, 3);
AssertNode(body, "Method(arg)", type.Length + 10, 11);
}
Expand Down Expand Up @@ -1432,7 +1435,7 @@ public void BindingParser_GenericMethodCall_SimpleName()
var typeArgument = generic.TypeArguments[0].As<TypeReferenceBindingParserNode>();

AssertNode(root, source, 0, source.Length);
AssertNode(generic, "GetType<string>", 0, source.Length-12);
AssertNode(generic, "GetType<string>", 0, source.Length - 12);
AssertNode(typeArgument, "string", 8, 6);
}

Expand All @@ -1449,7 +1452,7 @@ public void BindingParser_GenericMethodCall_MemberAccessName()
var typeArgument = generic.TypeArguments[0].As<TypeReferenceBindingParserNode>();

AssertNode(root, source, 0, source.Length);
AssertNode(memberAccess, "service.GetType<string?>", 0, source.Length-12);
AssertNode(memberAccess, "service.GetType<string?>", 0, source.Length - 12);
AssertNode(generic, "GetType<string?>", 8, source.Length - 20);

AssertNode(typeArgument, "string?", 16, 7);
Expand Down

0 comments on commit 5e9bd67

Please sign in to comment.