Skip to content

Commit

Permalink
Merge pull request #1550 from riganti/fix/case-insensitive-directives
Browse files Browse the repository at this point in the history
Fixed directives to be case-insensitive again
  • Loading branch information
acizmarik authored Jan 17, 2023
2 parents 434a4fe + 24cc4b2 commit bcc3c9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public MarkupDirectiveCompilerPipeline(IAbstractTreeBuilder treeBuilder, IContro

public MarkupPageMetadata Compile(DothtmlRootNode dothtmlRoot, string fileName)
{
var directivesByName = dothtmlRoot.Directives.GroupBy(d => d.Name, StringComparer.OrdinalIgnoreCase).ToDictionary(d => d.Key, d => (IReadOnlyList<DothtmlDirectiveNode>)d.ToList());
var directivesByName = dothtmlRoot.Directives
.GroupBy(d => d.Name, StringComparer.OrdinalIgnoreCase)
.ToDictionary(d => d.Key, d => (IReadOnlyList<DothtmlDirectiveNode>)d.ToList(), StringComparer.OrdinalIgnoreCase);

var resolvedDirectives = new Dictionary<string, IReadOnlyList<IAbstractDirective>>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,16 @@ public void ResolvedTree_ViewModel_TypeFromGlobalImportedNamespace()
Assert.IsFalse(root.Directives.Any(d => d.Value.Any(dd => dd.DothtmlNode.HasNodeErrors)));
Assert.AreEqual(typeof(TestViewModel), root.DataContextTypeStack.DataContextType);
}

[TestMethod]
[DataRow("@viewModel")]
[DataRow("@viewmodel")]
public void ResolvedTree_ViewModel_DirectiveIdentifier_CaseInsensitivity(string directive)
{
var root = ParseSource($"{directive} System.String");

Assert.IsFalse(root.Directives.Any(d => d.Value.Any(dd => dd.DothtmlNode.HasNodeErrors)));
Assert.AreEqual(typeof(string), root.DataContextTypeStack.DataContextType);
}
}
}

0 comments on commit bcc3c9a

Please sign in to comment.