From b7624ab47112ea279db9ad180d4426c1a05c9154 Mon Sep 17 00:00:00 2001 From: Samuel Meenzen Date: Thu, 2 May 2024 17:56:37 +0200 Subject: [PATCH] Add support for Razor Components (#992) --- languages.json | 7 +++-- tests/data/razor.cshtml | 55 +++++++++++++++++++++++++++++++++ tests/data/razorcomponent.razor | 45 +++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 tests/data/razor.cshtml create mode 100644 tests/data/razorcomponent.razor diff --git a/languages.json b/languages.json index afd638266..bd399d434 100644 --- a/languages.json +++ b/languages.json @@ -1283,8 +1283,11 @@ "extensions": ["raku", "rakumod", "rakutest", "pm6", "pl6", "p6"] }, "Razor": { - "multi_line_comments": [[""], ["@*", "*@"]], - "extensions": ["cshtml"] + "line_comment": ["//"], + "multi_line_comments": [[""], ["@*", "*@"], ["/*", "*/"]], + "quotes": [["\\\"", "\\\""]], + "verbatim_quotes": [["@\\\"", "\\\""]], + "extensions": ["cshtml", "razor"] }, "Red": { "line_comment": [";"], diff --git a/tests/data/razor.cshtml b/tests/data/razor.cshtml new file mode 100644 index 000000000..fcdb312b9 --- /dev/null +++ b/tests/data/razor.cshtml @@ -0,0 +1,55 @@ +@* 55 lines 35 code 15 comments 5 blanks *@ +@page "/" +@using Microsoft.AspNetCore.Components.Web +@namespace temp.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + +@{ + // foo + string foo = "bar"; + + /* + * bar + */ + string bar = "foo"; +} + + + + + + + + + + + + + + + @* + + multi-line comment + + *@ + + +
+ + An error has occurred. This application may no longer respond until reloaded. + + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + diff --git a/tests/data/razorcomponent.razor b/tests/data/razorcomponent.razor new file mode 100644 index 000000000..01d5b6a20 --- /dev/null +++ b/tests/data/razorcomponent.razor @@ -0,0 +1,45 @@ +@* 45 lines 16 code 21 comments 8 blanks *@ +@page "/counter" + +@{ + // foo + string foo = "bar"; + + /* + * bar + */ + string bar = "foo"; +} + +Counter + +@* + +multi-line comment + +*@ +

Counter

+ +

Current count: @currentCount

+ + + + +@code { + /* + + C# style multi-line comment + + */ + private int currentCount = 0; + + private void IncrementCount() + { + // increment the count + currentCount++; + } +}