diff --git a/samples/StandaloneApp/Pages/Counter.cshtml b/samples/StandaloneApp/Pages/Counter.cshtml index 3677204440..a90b296a50 100644 --- a/samples/StandaloneApp/Pages/Counter.cshtml +++ b/samples/StandaloneApp/Pages/Counter.cshtml @@ -1,14 +1,15 @@ @page "/counter" +@using Microsoft.AspNetCore.Blazor
Current count: @currentCount
- + @functions { int currentCount = 0; - void IncrementCount() + void IncrementCount(UIMouseEventArgs e) { currentCount++; } diff --git a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorDiagnosticFactory.cs b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorDiagnosticFactory.cs index b00be81793..c99f32c662 100644 --- a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorDiagnosticFactory.cs +++ b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorDiagnosticFactory.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using AngleSharp; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -13,6 +12,43 @@ namespace Microsoft.AspNetCore.Blazor.Razor { internal static class BlazorDiagnosticFactory { + public static readonly RazorDiagnosticDescriptor CodeBlockInAttribute = + new RazorDiagnosticDescriptor( + "BL9979", + () => + "Code blocks delimited by '@{...}' like '@{{ {0} }}' for attributes are no longer supported " + + "These features have been changed to use attribute syntax. " + + "Use 'attr=\"@(x => {... }\"'.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_CodeBlockInAttribute(SourceSpan? source, string expression) + { + var diagnostic = RazorDiagnostic.Create( + CodeBlockInAttribute, + source ?? SourceSpan.Undefined, + expression); + return diagnostic; + } + + public static readonly RazorDiagnosticDescriptor ExpressionInAttributeList = + new RazorDiagnosticDescriptor( + "BL9980", + () => + "Expressions like '{0}' inside of a tag must be part of an attribute. " + + "Previous releases of Blazor supported constructs like '@onclick(...)' or '@bind(...)'." + + "These features have been changed to use attribute syntax. " + + "Use 'onclick=\"@...\"' or 'bind=\"...\" respectively.", + RazorDiagnosticSeverity.Error); + + public static RazorDiagnostic Create_ExpressionInAttributeList(SourceSpan? source, string expression) + { + var diagnostic = RazorDiagnostic.Create( + ExpressionInAttributeList, + source ?? SourceSpan.Undefined, + expression); + return diagnostic; + } + public static readonly RazorDiagnosticDescriptor UnexpectedClosingTag = new RazorDiagnosticDescriptor( "BL9981", () => "Unexpected closing tag '{0}' with no matching start tag.", diff --git a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorRuntimeNodeWriter.cs b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorRuntimeNodeWriter.cs index 0b281e4ae4..b59d7e212d 100644 --- a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorRuntimeNodeWriter.cs +++ b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorRuntimeNodeWriter.cs @@ -5,14 +5,12 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using AngleSharp; using AngleSharp.Html; using AngleSharp.Parser.Html; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.CodeGeneration; using Microsoft.AspNetCore.Razor.Language.Intermediate; -using Microsoft.CodeAnalysis.CSharp; namespace Microsoft.AspNetCore.Blazor.Razor { @@ -27,15 +25,11 @@ namespace Microsoft.AspNetCore.Blazor.Razor = new HashSet