From 0fb47684c8c9f40b580c1279949ae4daac0d409c Mon Sep 17 00:00:00 2001 From: Ryan Nowak <nowakra@gmail.com> Date: Thu, 7 Jun 2018 11:56:09 -0700 Subject: [PATCH] Fix #974 The root cause here was that we weren't setting the language version in MSBuild, which is only for the command line version. (cherry picked from commit 319e31f71a150e9b0d91e724f0e358390caec4c2) --- .../targets/RazorCompilation.targets | 2 ++ .../Tests/ComponentRenderingTest.cs | 13 ++++++++++++- test/testapps/BasicTestApp/DataDashComponent.cshtml | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/testapps/BasicTestApp/DataDashComponent.cshtml diff --git a/src/Microsoft.AspNetCore.Blazor.Build/targets/RazorCompilation.targets b/src/Microsoft.AspNetCore.Blazor.Build/targets/RazorCompilation.targets index 2d6896c5eb2..fa40d6c86f9 100644 --- a/src/Microsoft.AspNetCore.Blazor.Build/targets/RazorCompilation.targets +++ b/src/Microsoft.AspNetCore.Blazor.Build/targets/RazorCompilation.targets @@ -14,6 +14,8 @@ <!-- Deactivates the Razor SDK's build-time compilation. We do our own --> <RazorCompileOnBuild>false</RazorCompileOnBuild> + <RazorLangVersion>Experimental</RazorLangVersion> + <!-- This version is used to build our RazorConfiguration, and is hardcoded into the tools in VS. If you change This to a value that doesn't match VS, then the Blazor Razor experience won't work for those documents. diff --git a/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs b/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs index 5b716e29fa8..ef77b7cfee6 100644 --- a/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs +++ b/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -40,6 +40,17 @@ namespace Microsoft.AspNetCore.Blazor.E2ETest.Tests Assert.Equal("Hello from TextOnlyComponent", appElement.Text); } + // This verifies that we've correctly configured the Razor language version via MSBuild. + // See #974 + [Fact] + public void CanRenderComponentWithDataDash() + { + var appElement = MountTestComponent<DataDashComponent>(); + var element = appElement.FindElement(By.Id("cool_beans")); + Assert.Equal("17", element.GetAttribute("data-tab")); + Assert.Equal("17", element.Text); + } + [Fact] public void CanRenderComponentWithAttributes() { diff --git a/test/testapps/BasicTestApp/DataDashComponent.cshtml b/test/testapps/BasicTestApp/DataDashComponent.cshtml new file mode 100644 index 00000000000..ae00ab1bc92 --- /dev/null +++ b/test/testapps/BasicTestApp/DataDashComponent.cshtml @@ -0,0 +1,5 @@ +<div id="cool_beans" data-tab="@TabId">@TabId</div> + +@functions { + string TabId = "17"; +} -- GitLab