EWSoftware / VSSpellChecker

A Visual Studio spell checker editor extension that checks the spelling of comments, strings, and plain text as you type. Supports configuration and various languages.
Other
377 stars 65 forks source link

Extension throw exception after upgrade to version 2023.5.15.1 and migrate configuration to .editorconfig in VS 2017 with Web Site project #287

Closed SylwesterZarebski closed 1 year ago

SylwesterZarebski commented 1 year ago

After installing new version 2023.5.15.1 (today) of extension and migrating configurations (global and local) to .editorconfig in VS 2017 15.9.93 i've got exception in Web Site project (with ASPX files). In Activity.log there is:

System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at VisualStudio.SpellChecker.ProjectSpellCheck.ClassifierFactory.SupportsOldStyleXmlDocComments(String filename)
   at VisualStudio.SpellChecker.Tagging.CommentTextTagger.CommentTextTaggerProvider.CreateTagger[T](ITextBuffer buffer)
   at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)

My local .editorconfig is:

[*]
# VSSPELL: Spell checker settings from Wydruki.Aspx.sln.vsspell
vsspell_section_id = 96a1c04c727e461fb5ea8ffc9905688d
vsspell_dictionary_languages_96a1c04c727e461fb5ea8ffc9905688d = inherited,de-DE,ru-RU

PS. Extension still works after above exception.

EWSoftware commented 1 year ago

What's the extension on the file being edited? The only location I can find where this might have happened would involve an invalid Classifications.config file. Do you have a custom one in your %LOCALAPPDATA%\EWSoftware\Visual Studio Spell Checker folder?

SylwesterZarebski commented 1 year ago

It is ASPX file (extension .aspx). I do not have any custom Classifications.config file. I've had old VSSpellChecker.vsspell config file, but deleting it did not fix an error. Maybe the problem is that ASPX file is partially HTML/JS/CSS, and partially C#?

I think buffer.GetFilename() returns null (because Path.GetExtension(null) returns null), which then throw exception in TryGetValue().

SylwesterZarebski commented 1 year ago

How to reproduce:

  1. Open VS 2017.
  2. Create new project ASP.NET Empty Web Site: obraz
  3. Outside VS (i.e. in notepad) create new file test.aspx with content:
    <%@ Page Language="C#" AutoEventWireup="true" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    <script runat="server">
    </script>
    </head>
    <body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
    </body>
    </html>
  4. Refresh VS explorer view and open above file in VS -> exception.

PS. Exception is only on first open file, all subsequent tries do not give exception. To get exception you need to close and reopen VS.