From 2534124b3ec57597ba1942b42f178e0be3ddb184 Mon Sep 17 00:00:00 2001 From: exyi Date: Mon, 7 Aug 2017 14:01:23 +0000 Subject: [PATCH] Implitic property value now also works for bool? --- .../Parser/Dothtml/DothtmlParserTests.cs | 26 +++++++++---------- .../DothtmlTokenizerDirectivesTests.cs | 6 ++--- .../ControlTree/ControlTreeResolverBase.cs | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) mode change 100644 => 100755 src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlParserTests.cs mode change 100644 => 100755 src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlTokenizerDirectivesTests.cs mode change 100644 => 100755 src/DotVVM.Framework/Compilation/ControlTree/ControlTreeResolverBase.cs diff --git a/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlParserTests.cs b/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlParserTests.cs old mode 100644 new mode 100755 index 91135697cc..2f810da1f1 --- a/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlParserTests.cs +++ b/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlParserTests.cs @@ -200,7 +200,7 @@ @basetype Test Assert.AreEqual(1, result.Content.Count); Assert.IsInstanceOfType(result.Content[0], typeof(DothtmlLiteralNode)); - Assert.AreEqual("\r\nthis is a content", ((DothtmlLiteralNode)result.Content[0]).Value); + Assert.AreEqual("\nthis is a content", ((DothtmlLiteralNode)result.Content[0]).Value); } [TestMethod] @@ -218,7 +218,7 @@ public void DothtmlParser_Valid_Doctype() Assert.AreEqual(1, result.Content.Count); Assert.IsInstanceOfType(result.Content[0], typeof(DothtmlLiteralNode)); - Assert.AreEqual("\r\n\r\ntest", ((DothtmlLiteralNode)result.Content[0]).Value); + Assert.AreEqual("\n\ntest", ((DothtmlLiteralNode)result.Content[0]).Value); } @@ -391,7 +391,7 @@ public void DothtmlParser_Valid_CData() [TestMethod] public void DothtmlParser_Valid_CommentBeforeDirective() { - var markup = " @viewModel TestDirective\r\nTest"; + var markup = " @viewModel TestDirective\nTest"; var root = ParseMarkup(markup); var nodes = root.Content; @@ -414,7 +414,7 @@ public void DothtmlParser_Valid_CommentBeforeDirective() [TestMethod] public void DothtmlParser_Valid_CommentInsideDirectives() { - var markup = "@masterPage hello\r\n @viewModel TestDirective\r\nTest"; + var markup = "@masterPage hello\n @viewModel TestDirective\nTest"; var root = ParseMarkup(markup); var nodes = root.Content; @@ -450,11 +450,11 @@ public void BindingParser_TextBinding_Invalid_MissingName() [TestMethod] public void DothtmlParser_HierarchyBuildingVisitor_Element_InvalidTag() { - var markup = " @viewModel TestDirective\r\n
"; + var markup = " @viewModel TestDirective\n
"; var root = ParseMarkup(markup); var visitor = new HierarchyBuildingVisitor { - CursorPosition = 62 + CursorPosition = 61 }; root.Accept(visitor); @@ -479,12 +479,12 @@ public void DothtmlParser_HierarchyBuildingVisitor_Element_InvalidTag() [TestMethod] public void DothtmlParser_HierarchyBuildingVisitor_Element_UnclosedTagContent() { - var markup = " @viewModel TestDirective\r\n
  • \r\n\t\t\t\t
\r\n
"; + var markup = " @viewModel TestDirective\n
  • \n\t\t\t\t
\n
"; var root = ParseMarkup(markup); var visitor = new HierarchyBuildingVisitor { - CursorPosition = 83 + CursorPosition = 81 }; root.Accept(visitor); @@ -515,12 +515,12 @@ public void DothtmlParser_HierarchyBuildingVisitor_Element_UnclosedTagContent() [TestMethod] public void DothtmlParser_HierarchyBuildingVisitor_Element_Valid() { - var markup = " @viewModel TestDirective\r\n
  • item
link
"; + var markup = " @viewModel TestDirective\n
  • item
link
"; var root = ParseMarkup(markup); var visitor = new HierarchyBuildingVisitor { - CursorPosition = 62 + CursorPosition = 61 }; root.Accept(visitor); @@ -545,7 +545,7 @@ public void DothtmlParser_HierarchyBuildingVisitor_Element_Valid() [TestMethod] public void DothtmlParser_HierarchyBuildingVisitor_Attribute_TextValue() { - var markup = " @viewModel TestDirective\r\n
  • item
link
"; + var markup = " @viewModel TestDirective\n
  • item
link
"; var root = ParseMarkup(markup); var visitor = new HierarchyBuildingVisitor @@ -577,7 +577,7 @@ public void DothtmlParser_HierarchyBuildingVisitor_Attribute_TextValue() [TestMethod] public void DothtmlParser_HierarchyBuildingVisitor_Attribute_BindingValue() { - var markup = " @viewModel TestDirective\r\n
  • item
link
"; + var markup = " @viewModel TestDirective\n
  • item
link
"; var root = ParseMarkup(markup); var visitor = new HierarchyBuildingVisitor @@ -678,7 +678,7 @@ public void DothtmlParser_UnclosedTagImlicitlyClosed_WarningOnNode() public static DothtmlRootNode ParseMarkup(string markup) { var tokenizer = new DothtmlTokenizer(); - tokenizer.Tokenize(markup); + tokenizer.Tokenize(markup.Replace("\r\n", "\n")); var parser = new DothtmlParser(); var node = parser.Parse(tokenizer.Tokens); return node; diff --git a/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlTokenizerDirectivesTests.cs b/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlTokenizerDirectivesTests.cs old mode 100644 new mode 100755 index 6e9778b985..c128c20dbf --- a/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlTokenizerDirectivesTests.cs +++ b/src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlTokenizerDirectivesTests.cs @@ -208,7 +208,7 @@ public void DothtmlTokenizer_DirectiveParsing_Invalid_AtSymbol_DirectiveName_New Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(DothtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type); - Assert.AreEqual("\r\n", tokenizer.Tokens[i].Text); + Assert.AreEqual("\n", tokenizer.Tokens[i].Text); Assert.AreEqual(DothtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual("test", tokenizer.Tokens[i].Text); @@ -239,7 +239,7 @@ public void DothtmlTokenizer_DirectiveParsing_Invalid_AtSymbol_DirectiveName_Spa Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(DothtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type); - Assert.AreEqual("\r\n", tokenizer.Tokens[i].Text); + Assert.AreEqual("\n", tokenizer.Tokens[i].Text); Assert.AreEqual(DothtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual("test", tokenizer.Tokens[i].Text); @@ -272,7 +272,7 @@ public void DothtmlTokenizer_DirectiveParsing_Invalid_AtSymbol_Space_NewLine_Con Assert.AreEqual(0, tokenizer.Tokens[i].Length); Assert.AreEqual(DothtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type); - Assert.AreEqual("\r\n", tokenizer.Tokens[i].Text); + Assert.AreEqual("\n", tokenizer.Tokens[i].Text); Assert.AreEqual(DothtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type); Assert.AreEqual("test", tokenizer.Tokens[i].Text); diff --git a/src/DotVVM.Framework/Compilation/ControlTree/ControlTreeResolverBase.cs b/src/DotVVM.Framework/Compilation/ControlTree/ControlTreeResolverBase.cs old mode 100644 new mode 100755 index 6995b3fcf0..d6e242b27d --- a/src/DotVVM.Framework/Compilation/ControlTree/ControlTreeResolverBase.cs +++ b/src/DotVVM.Framework/Compilation/ControlTree/ControlTreeResolverBase.cs @@ -433,7 +433,7 @@ private void ProcessAttribute(DothtmlAttributeNode attribute, IAbstractControl c if (attribute.ValueNode == null) { // implicitly set boolean property - if (property.PropertyType.IsEqualTo(new ResolvedTypeDescriptor(typeof(bool)))) + if (property.PropertyType.IsEqualTo(new ResolvedTypeDescriptor(typeof(bool))) || property.PropertyType.IsEqualTo(new ResolvedTypeDescriptor(typeof(bool?)))) { string error; if (!treeBuilder.AddProperty(control, treeBuilder.BuildPropertyValue(property, true, attribute), out error)) attribute.AddError(error);