Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue regarding reloading and custom dictionaries and code analysis #281

Open
antonioatom opened this issue May 11, 2023 · 14 comments
Open

Comments

@antonioatom
Copy link

antonioatom commented May 11, 2023

Just migrated everything to the new .editorconfig but I ran into some problems

  1. As stated in the documentation the file should be the language name "en-US.dic" for example. This doesn't seem to work. I needed to change the name of the file to the one used in the global settings "en-US_User.dic". This is not clear in the documentation since it cleary states the dictionary should have the language name as the filename (it is also mentioned here: Files names for custom dictionaries #204)
  2. You state in the documentation that any changes done to the .editorconfig file might only be read if you reload the solution but this doesn't seem to be the case. Few scenarios:
  • Changing branch within visual studio where the .editorconfig and the dictionaries are the same: it will sometimes fail the spell checks like the custom dictionaries and ignored words are not setup. I know this to be the case because if I manually run the spell check and try to add a word to custom dictionary or ignored words it will use the global files and not the local files in the solution
  • Changing .editorconfig and closing and reopening the solution: new settings are not read forcing me to completely close visual studio and open it again to read those.
  1. Another problem is running manually the spell check in the entire solution shows no errors but running the code analysis on the solution shows some VSSpelll001 errors of words that are in the ignore file:
image image

Using VS 17.5.5. Extension version: 2023.5.8.0.

Current .editorconfig in the root of the solution

[*]
vsspell_section_id = 7c96fdaf1b6247398b8f206b0699cba2
vsspell_determine_resource_file_language_from_name = false
vsspell_additional_dictionary_folders_7c96fdaf1b6247398b8f206b0699cba2 = .\CodeAnalysis\Dictionaries
vsspell_dictionary_languages_7c96fdaf1b6247398b8f206b0699cba2 = en-US
vsspell_spell_check_as_you_type = true
vsspell_include_in_project_spell_check = true
vsspell_code_analyzers_enabled = true
vsspell_detect_doubled_words = true
vsspell_ignore_words_with_digits = true
vsspell_ignore_words_in_all_uppercase = true
vsspell_ignore_words_in_mixed_case = true
vsspell_ignore_format_specifiers = true
vsspell_ignore_filenames_and_email_addresses = true
vsspell_ignore_xml_elements_in_text = true
vsspell_treat_underscore_as_separator = true
vsspell_ignore_mnemonics = true
vsspell_ignored_character_class = None
vsspell_code_analyzer_ignore_xml_doc_comments = false
vsspell_code_analyzer_ignore_delimited_comments = true
vsspell_code_analyzer_ignore_standard_single_line_comments = false
vsspell_code_analyzer_ignore_quadruple_slash_comments = true
vsspell_code_analyzer_ignore_normal_strings = false
vsspell_code_analyzer_ignore_verbatim_strings = true
vsspell_code_analyzer_ignore_interpolated_strings = true
vsspell_code_analyzer_apply_to_all_c_style_languages = true
vsspell_ignored_words_7c96fdaf1b6247398b8f206b0699cba2 = File:CodeAnalysis\Dictionaries\Solution.sln.IgnoredWords.dic
vsspell_exclusion_expressions_7c96fdaf1b6247398b8f206b0699cba2 = (omitted for simplicity)
vsspell_cad_import_code_analysis_dictionaries = true
vsspell_cad_treat_unrecognized_words_as_misspelled = true
vsspell_cad_treat_deprecated_terms_as_misspelled = true
vsspell_cad_treat_compound_terms_as_misspelled = true
vsspell_cad_treat_casing_exceptions_as_ignored_words = false
vsspell_cad_recognized_word_handling = IgnoreAllWords
vsspell_ignored_classifications_7c96fdaf1b6247398b8f206b0699cba2 =  (omitted for simplicity)
vsspell_code_analyzer_ignore_if_compiler_generated = true
vsspell_code_analyzer_ignore_quadruple_slash_comments = true
vsspell_code_analyzer_ignore_verbatim_strings = true
vsspell_code_analyzer_ignore_identifier_if_all_uppercase = true
@EWSoftware
Copy link
Owner

EWSoftware commented May 13, 2023

In item 1, are you referring to actual dictionaries (the pair of files *.aff and *.dic) or the user dictionary where words are added while spell checking (the _User.dic)? User dictionaries do need to be named "_User.dic".

Can you supply an example that demonstrates the issues in item 1 and item 2? I don't need branches, just the general structure of the folders and files so that I can better understand what you are doing. There is a bug in how the additional dictionary folders are resolved so that that may be affecting this. I've fixed that for the next release.

Item 3 is to be expected. As noted in the documentation, the code analyzers run in a separate process so there is no way to have their results show in either the Spell Check Current Document or Solution/Project Spell Check tool windows. They will only show string/comment misspellings.

@antonioatom
Copy link
Author

Item 1. Yes I was refering to custom dictionaries.

Regarding the folder structure I have:

CodeAnalysis (in the root of the solution)
-- Dictionaries
---- Solution.sln.IgnoredWords.dic
---- en-US_User.dic
.editorconfig (this is in the root of the solution. the file has the root = true in the first line)
[FolderPerProject]
-- .editorconfig (this file is only there for some projects where I want to exclude something)

I was able to fix most of the issues but everytime I build or run the analyzer I get more errors that were not found before.

One example I can give now is the following:
I have a specific .editorconfig in my web project where I want him to ignore the cshtml files:

[*.cshtml]
vsspell_spell_check_as_you_type = false
vsspell_include_in_project_spell_check = false
vsspell_code_analyzers_enabled = false

I'm getting this error in the error list:
image

As you can see it's giving several errors for the same file and the word "Mvc" does not exist on that file.
The error is underlined in @model

In any case I assume with the rule for *.cshtml I added above in the .editorconfig in the root of that project it shouldn't check for any cshtml files.

I'll try to get other examples but this is very hit and miss. Sometimes it shows errors on the error list, I double click to check the error and the error just goes away. I got a VSSpell error for the work "cancelation" in a cancelation token variable, when I double clicked to see the error the error just vanished although the word was still wrong. After I've fixed it and rebuilt it showed the same error although it was fixed. The same with other spelling errors that I've found.

This is another example I could screenshot before the error went away:
image

I had an error with "appplication", I've fixed it. The error got away. Rebuilt. The error showed up again. Double click the error, I go to the file and the error disappears. If I then call "Run Code Analysis On Solution" the errors reappear as well.

So I have 3 VSSpell001 errors there of things I've fixed:

  • I tried to close and open the solution but the errors still show after reopening.
  • Tried a rebuild solution. Errors are still there.
  • Ran Code Analysis on Solution. Errors are still there.
  • If double click the file, the errors are gone until next rebuild.
  • Just for kicks I decided after this to run the spell checker and I got a lot of errors of words that are in the dictionary or in the ignored list (this is related to the other issue I reported where I think when we reopen the solution or change branch in git the spell checker ignores the .editorconfig files or at very least the dictionaries)
  • Closed visual studio completely. Reopened VS with the solution.
  • Ran spell checker: 0 errors found, as expected.
  • Rebuild solution: no VSSpell001 errors.
  • Ran Code Analysis on Solution: no VSSpell001 errors found.
  • Purposely changed one of the errors I was getting before on variable "stx".
catch (RequestFailedException stx)
{
    this.logger.LogError(stx, "Error while deleting Blob.");
    throw;
}
  • Did a full rebuild. No errors
  • Ran code analysis on that project, no error.
  • Ran code analysis on solution, no error.
  • So the spelling error I introduced is not being caught anymore.

It seems everyday I open the solution I get different errors.

@EWSoftware
Copy link
Owner

I've just published an update that fixes an issue resolving dictionary paths and the default ignored words file. It should be available shortly. See if that has an effect.

If not, can you supply an actual set of files I can download and test? It's much easier to do that than to try and reproduce the example based on a description alone as I may not do everything the same way that you have. Case in point, your spelling issues are showing up as errors. They're only set to report as warnings by default.

Regarding building the projects, you won't see any identifier spelling warnings there since as I recall, it needs a NuGet package to apply them during the build which I did not create. You won't see anything unless you open file with code or run the code analysis option that causes them to be reported.

@antonioatom
Copy link
Author

Hi... It's hard to share my code due to privacy reason. Regarind VSSpell001 showing as error this is by design of the solution "Show all warnings as errors".

Just a note on what I reported yesterday: I left my solution open with 0 errors and just went on my life. Today when opening the computer I had 16 new VSSpell001 errors. It seems the spell check keeps running in the background even if code analysis is not running. Could be something with Visual Studio. Just wanted to let you know.

I'll test the new version of the package as soon as i I can. I can see it in the pending extension updates as version 2023.5.15.1.

@antonioatom
Copy link
Author

antonioatom commented May 16, 2023

Another update... Using the new version 2023.5.15.1. Added the word "env" to the ignore dictionary and still the error shows up as a VSSpell001. Again if I leave VS open without doing anything it will find new spelling errors that didn't find before. I cannot find a way to trigger a full code analysis with the VSSpell so I can fix all spelling errors all at once.

Run Code Analysis for solution or for project does not trigger new spelling errors.

Already tried with "Run Code Analysis in separate process" on and off. Same result.

The behavior of showing a spelling error, you click on the error, it opens the file and the error just goes away from the error list even if I don't fix it.

If I close the file the error shows up again in the error list even if I corrected it.

I did a small video showing this:

2023-05-16.13-45-10.mp4

@antonioatom
Copy link
Author

Using the new version 2023.5.15.1 the problem with closing and opening the solution doesn't load the dictionaries.
Steps:

  1. Ran spell checker for the solution and realized that it was not ignoring the words from the ignore dictionary or the words on the user dictionary
  2. Closed solution
  3. Reopen
  4. Ran spell checker again. Same errors.
  5. Closed Visual Studio
  6. Open Visual Studio with the solution
  7. Ran spell checker, no errors as expected
  8. As a test I've closed and reopend the solution
  9. Ran spell checker and everything has error now so the dictionaries are ignore whenever you close and open the solution apparently.

So I think the fix for loading the dictionaries on close / open solution it's not working.

@antonioatom
Copy link
Author

Any updates on this issue?

@EWSoftware
Copy link
Owner

I haven't had a chance to look at it yet. I'm not sure I understand what you mean by "ran spell checker" unless you mean you did a solution/project spell check or are you just referring to opening/closing a file for the code analyzer to run?

@antonioatom
Copy link
Author

Ran spell checker -> solution/project spell check
My visual studio is set to run analysis on Entire Solution but I manually run the "Run Code Analysis" for solution manually if I want to check the full project.

@BDisp
Copy link

BDisp commented Jun 26, 2023

I'm also having this issue. How can I set the severity from Error to another value? I already tried by right click on the item and Set severity with other value, but the value doesn't change. It's annoying to have many errors in the Error List for names I choose for namespaces, classes, parameters, etc.

@EWSoftware
Copy link
Owner

@BDisp Disable the code analyzer option in the global configuration if you don't want to use it at all. If you have the "all warnings as errors" option set, you can change the VSSpell01 diagnostic to a suggestion in the .editorconfig file. That changes the warning/error underlines to gray dots instead. You can also set it to silent or none which gets rid of all the markers but that's effectively turning it off so you might as well use the spelling configuration option.

[*.{cs,vb}]
# Treat spell checker issues as suggestions rather than warnings (or errors if treating all warnings as errors)
dotnet_diagnostic.VSSpell001.severity = suggestion

# Or turn off the code analyzer completely so that no identifier spell checking is performed
vsspell_code_analyzers_enabled = false

@BDisp
Copy link

BDisp commented Jul 8, 2023

Thanks for the response. I really don't want to disable it because I like it a lot to speller check on xml documents, commits, etc. But I also don't like to insert it on a .editorconfig at solution level file because others users may not be using the extension. That why I prefer to put it on a global config. What I don't understand is why on some solutions the speller check show as error and on others show as warning (which is what I want). Note that I also don't have the global configuration file in the C:\Users\Luis\AppData\Local\EWSoftware\Visual Studio Spell Checker\VSSpellChecker.editorconfig. I think it assumes different behaviors if it's a ConsoleApp, WebApp or BlazorApp.

@EWSoftware
Copy link
Owner

The global configuration file doesn't need to exist. If it doesn't, there are defaults it uses. Disabling the code analyzer won't disable spell checking of strings, comments, and plain text as they're separate. The code analyzer only handles identifiers. If they're showing as errors in some cases, it's likely that the project has the "show all warnings as errors" option set.

@BDisp
Copy link

BDisp commented Jul 9, 2023

Thank you very much. I had in the Directory.Build.props file <TreatWarningsAsErrors>true</TreatWarningsAsErrors> and was showing as errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants