diff --git a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BindLoweringPass.cs b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BindLoweringPass.cs index 07bc3bc09e..3df03f85eb 100644 --- a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BindLoweringPass.cs +++ b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BindLoweringPass.cs @@ -281,7 +281,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor var segments = attributeName.Split('-'); for (var i = 0; i < segments.Length; i++) { - if (string.IsNullOrEmpty(segments[0])) + if (string.IsNullOrEmpty(segments[i])) { return false; } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/BindRazorIntegrationTest.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/BindRazorIntegrationTest.cs index 47e8434ec2..d709c3412e 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/BindRazorIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/BindRazorIntegrationTest.cs @@ -486,5 +486,26 @@ namespace Test frame => AssertFrame.Whitespace(frame, 6), frame => AssertFrame.Whitespace(frame, 7)); } + + [Fact] + public void Render_Bind_With_IncorrectAttributeNames() + { + //more than 3 parts + Assert.Throws(() => CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public string Text { get; set; } = ""text""; +}")); + + //ends with '-' + Assert.Throws(() => CompileToComponent(@" +@addTagHelper *, TestAssembly + +@functions { + public string Text { get; set; } = ""text""; +}")); + + } } }