From 6886552f6c9d70f130b8b1dfff52f7595106b1b9 Mon Sep 17 00:00:00 2001 From: Bo Lopker Date: Wed, 29 Oct 2025 17:30:06 -0700 Subject: [PATCH] Fix #140: refine C# query, add C# dictionary --- crates/codebook/src/dictionaries/repo.rs | 4 ++++ crates/codebook/src/queries/csharp.scm | 4 +++- examples/example.cs | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/crates/codebook/src/dictionaries/repo.rs b/crates/codebook/src/dictionaries/repo.rs index 10fc49f..dd4c2b9 100644 --- a/crates/codebook/src/dictionaries/repo.rs +++ b/crates/codebook/src/dictionaries/repo.rs @@ -136,6 +136,10 @@ static TEXT_DICTIONARIES: LazyLock> = LazyLock::new(|| { text: Some(CODEBOOK_DICTIONARY), url: None, }, + TextRepo::new( + "csharp", + "https://raw.githubusercontent.com/streetsidesoftware/cspell-dicts/refs/heads/main/dictionaries/csharp/csharp.txt", + ), ] }); diff --git a/crates/codebook/src/queries/csharp.scm b/crates/codebook/src/queries/csharp.scm index bde6079..06a9ae4 100644 --- a/crates/codebook/src/queries/csharp.scm +++ b/crates/codebook/src/queries/csharp.scm @@ -54,9 +54,11 @@ (identifier) @identifier) ; String literals +(interpolated_string_expression + (string_content) @string) + [ (string_literal) (raw_string_literal) (verbatim_string_literal) - (interpolated_string_expression) ] @string diff --git a/examples/example.cs b/examples/example.cs index 46a4e29..fb93ae6 100644 --- a/examples/example.cs +++ b/examples/example.cs @@ -5,6 +5,28 @@ using System.Collections.Generic; using System.Linq; + +[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] +internal class Program +{ + private static void Main(string[] args) + { + // Incorrectly flagged + Console.WriteLine($"Hellooo, {nameof(Program)}!"); + + // Incorrectly flagged + Console.WriteLine( + $$""" + Hello {{nameof(Program)}}! + """); + } + private string GetDebuggerDisplay() + { + // OK + return nameof(Program); + } +} + namespace SpellcheckDemoo { // Interface with a mispelled name/methodd