Skip to content

Commit

Permalink
Final updates for initial release of the code analyzer
Browse files Browse the repository at this point in the history
- Added an Ignore Word option to the code analyzer to add the ignored word to an Ignore Spelling directive comment.  It's the best I can do for now as it doesn't appear to be possible to add them to the ignored words file or user dictionary.
- Updated the documentation for the initial release of the code analyzer.  Closes #111.
  • Loading branch information
EWSoftware committed May 8, 2023
1 parent 46cdb64 commit b2118cc
Show file tree
Hide file tree
Showing 39 changed files with 1,151 additions and 191 deletions.
205 changes: 138 additions & 67 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,162 @@ vsspell_exclusion_expressions_9f07c577adcd4fd7a93a42a503828225 = [a-z]{2}-([A-Z]
vsspell_spell_check_as_you_type = false
vsspell_include_in_project_spell_check = false

# XML files of various types
[*.{aml,asax,ascx,asmx,asp,aspx,axml,config,content,cshtml,csproj,database,datasource,dbml,disco,discomap,dtsx,edmx,exclude,fxcop,htm,html,items,layout,maml,manifest,master,msha,myapp,nunit,nuspec,proj,projitems,props,publishproj,pubxml,rdl,rdlc,resx,ruleset,settings,shfbproj,shproj,sitemap,snippets,soap,svc,svcinfo,svcmap,targets,tasks,tokens,vbhtml,vbproj,vcxproj,vcxproj.filters,vsct,vsixmanifest,vstemplate,webinfo,wsdl,xaml,xamlcfg,xml,xsd,xsl,xslt,xsx}]
# XML files of various types
indent_style = tab
indent_size = 2
tab_width = 2

# C#/VB settings
[*.{cs,vb}]
# C#/VB settings
indent_size = 4
tab_width = 4

dotnet_sort_system_directives_first = true

# Naming rules
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

# Code style settings
dotnet_style_predefined_type_for_locals_parameters_members = true:none
dotnet_style_predefined_type_for_member_access = false:error
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:error
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line

# "This." and "Me." qualification. Use is preferred where true but the lightbulbs tend to show up in places
# they aren't wanted (within static methods and nameof parameters etc.) so no suggestions are enabled.
dotnet_style_qualification_for_event = true : none
dotnet_style_qualification_for_field = false : none
dotnet_style_qualification_for_method = true : none
dotnet_style_qualification_for_property = true : none

# Language keywords vs framework type names
dotnet_style_predefined_type_for_locals_parameters_members = true : none
dotnet_style_predefined_type_for_member_access = false : error

# Modern language feature settings
dotnet_style_coalesce_expression = true : suggestion
dotnet_style_collection_initializer = true : suggestion
dotnet_style_explicit_tuple_names = true : error
dotnet_style_null_propagation = true : suggestion
dotnet_style_object_initializer = true : suggestion
dotnet_style_qualification_for_event = true:none
dotnet_style_qualification_for_field = false:none
dotnet_style_qualification_for_method = true:none
dotnet_style_qualification_for_property = true:none

# CSharp code style settings
[*.cs]
csharp_style_var_elsewhere = false : none
csharp_style_var_for_built_in_types = false : none
csharp_style_var_when_type_is_apparent = false : none

csharp_style_expression_bodied_accessors = true : suggestion
csharp_style_expression_bodied_constructors = false : none
csharp_style_expression_bodied_indexers = true : suggestion
csharp_style_expression_bodied_methods = false : none
csharp_style_expression_bodied_operators = false : none
csharp_style_expression_bodied_properties = true : suggestion

csharp_style_conditional_delegate_call = true : suggestion
csharp_style_deconstructed_variable_declaration = false : none
csharp_style_inlined_variable_declaration = true : suggestion
csharp_style_pattern_local_over_anonymous_function = true : suggestion
csharp_style_pattern_matching_over_as_with_null_check = true : suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion
csharp_style_throw_expression = true : suggestion

csharp_prefer_simple_default_expression = true : suggestion
# Code analyzer settings
# CA1303: Do not pass literals as localized parameters
dotnet_diagnostic.CA1303.severity = none

# IDE0010: Add missing cases
dotnet_diagnostic.IDE0010.severity = none

# IDE0032: Use auto property
dotnet_diagnostic.IDE0032.severity = none

# IDE0045: Convert to conditional expression
dotnet_diagnostic.IDE0045.severity = none

# IDE0046: Convert to conditional expression
dotnet_diagnostic.IDE0046.severity = none

# IDE0047: Remove unnecessary parentheses
dotnet_diagnostic.IDE0047.severity = none

# IDE0055: Fix formatting
dotnet_diagnostic.IDE0055.severity = none

# IDE0058: Expression value is never used
dotnet_diagnostic.IDE0058.severity = none

# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = none

[*.cs]
# CSharp code style settings
csharp_style_var_elsewhere = false:none
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:none

csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_properties = true:suggestion

csharp_style_conditional_delegate_call = true:suggestion
csharp_style_deconstructed_variable_declaration = false:none
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent

csharp_prefer_braces = when_multiline:none
csharp_prefer_simple_default_expression = true:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_preserve_single_line_blocks = true
csharp_using_directive_placement = outside_namespace:silent

# Indentation options
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_labels = no_change

# New line options
csharp_new_line_before_catch = true
Expand Down Expand Up @@ -109,31 +208,3 @@ csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false

# CA1303: Do not pass literals as localized parameters
dotnet_diagnostic.CA1303.severity = none

# IDE0010: Add missing cases
dotnet_diagnostic.IDE0010.severity = none

# IDE0032: Use auto property
dotnet_diagnostic.IDE0032.severity = none

# IDE0045: Convert to conditional expression
dotnet_diagnostic.IDE0045.severity = none

# IDE0046: Convert to conditional expression
dotnet_diagnostic.IDE0046.severity = none

# IDE0047: Remove unnecessary parentheses
dotnet_diagnostic.IDE0047.severity = none

# IDE0055: Fix formatting
dotnet_diagnostic.IDE0055.severity = none

# IDE0058: Expression value is never used
dotnet_diagnostic.IDE0058.severity = none

# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = none

45 changes: 45 additions & 0 deletions Docs/Content/CodeAnalyzer.aml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<topic id="12d44ba0-2bef-4fac-a6f9-7990ecf057c2" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<introduction>
<para>The code analyzer in the spell checker extension is used to spell check identifiers in source code.
Only C# is supported right now but future support for Visual Basic and, if possible, F# are planned. Code
analyzer spell checking differs from the string and comments spell checker implemented using the tagger in the
editor. Identifiers are always split up into separate words on capital letters and other separators such as the
underscore. In addition, there are some extra options related to visibility and placement that can control when
spell checking of identifiers occurs. See the <link xlink:href="09cc5bfa-9eba-47e5-ba5f-a36e04f09b0d" />
configuration category topic for details. Due to the way code analyzers work, there are some limitations. See
the <link xlink:href="a9ff4ce1-0d6b-4376-8d32-02dae64e2075" /> topic for more information.</para>
</introduction>

<section address="Section1">
<content>
<para>The code analyzer contains two rules: <codeInline>VSSpell001</codeInline> used to flag misspelled
words in identifiers and offer suggested fixes and <codeInline>VSSpell002</codeInline> used to offer an option
to add the misspelling to an Ignore Spelling directive comment in the source code file. The first rule defaults
to a warning and will show the usual warning underline on the misspellings. The second rule is hidden by default
and only appears on the smart tag when it is opened.</para>

<para>Place the mouse over the misspelled identifier and click the down arrow on the smart tag to see the
available options. Alternately, you can place the cursor anywhere in the identifier and press <ui>Ctrl+.</ui> or
<ui>Shift+Alt+F10</ui> depending on your version of Visual Studio to show the smart tag options. Note that if an
identifier consists of multiple words and more than one is misspelled, each misspelled part is flagged and
corrected separately.</para>

<para>Select the "Correct spelling of 'XXX'" option to see the suggested replacements. If the
misspelling represents only a part of the identifier, you will see the rest of the identifier in each suggestion.
Select a suggestion to get a preview of the changes that will occur if it is selected. To add the misspelling to
an Ignore spelling directive comment in the file, select the "Ignore word 'XXX'" option and a preview of the
directive will be displayed. The directive comments is placed at the top of the file below any header comments
and above the first directive, using statement, or namespace declaration. If a directive comment already exists
in that location, the new ignored word will be added to it.</para>
</content>
</section>

<relatedTopics>
<link xlink:href="3094ee74-88ae-4355-b702-23dcd55b4197" />
<link xlink:href="a7120f4c-5191-4442-b366-c3e792060569" />
<link xlink:href="83ff9063-294f-4a18-b765-1510c86ad0d4" />
</relatedTopics>
</developerConceptualDocument>
</topic>
24 changes: 24 additions & 0 deletions Docs/Content/ConfigOptions/CodeAnalysisDictionaries.aml
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,43 @@ as shown in the example below.</para>
<para><ui>Import project code analysis dictionaries if present</ui> - This option is enabled by
default and controls whether or not the code analysis dictionaries are imported. If disabled, all of the
following options are ignored.</para>

<code language="none" title=" ">
vsspell_cad_import_code_analysis_dictionaries = [true|false]
</code>
</listItem>

<listItem>
<para><ui>Treat unrecognized words as misspelled words</ui> - This option is enabled by default and
will cause unrecognized words in the dictionary to be treated as misspelled words. Adding a
<codeInline>SpellingAlternates</codeInline> attribute to the <codeInline>Word</codeInline> element allows you to
specify a list of one or more comma-separated words to offer as suggested replacements.</para>

<code language="none" title=" ">
vsspell_cad_treat_unrecognized_words_as_misspelled = [true|false]
</code>
</listItem>

<listItem>
<para><ui>Treat deprecated terms as misspelled words</ui> - This option is enabled by default and
will cause deprecated terms in the dictionary to be treated as misspelled words. The preferred alternate is
offered as the suggested replacement. If the preferred alternate is camel cased, spaces are inserted before each
capital letter.</para>

<code language="none" title=" ">
vsspell_cad_treat_deprecated_terms_as_misspelled = [true|false]
</code>
</listItem>

<listItem>
<para><ui>Treat compound terms as misspelled words</ui> - This option is enabled by default and will
cause compound terms in the dictionary to be treated as misspelled words. The compound alternate is offered as
the suggested replacement. If the compound alternate is camel cased, spaces are inserted before each capital
letter.</para>

<code language="none" title=" ">
vsspell_cad_treat_compound_terms_as_misspelled = [true|false]
</code>
</listItem>

<listItem>
Expand All @@ -63,6 +79,10 @@ in all uppercase or camel case. Camel cased words are always ignored. All uppe
<ui>Ignore words in all uppercase</ui> option in the <ui>General Settings</ui> category is enabled. This option
may be of use if that option is disabled so that acronyms in all uppercase within this category are not spell
checked.</para>

<code language="none" title=" ">
vsspell_cad_treat_casing_exceptions_as_ignored_words = [true|false]
</code>
</listItem>

<listItem>
Expand Down Expand Up @@ -94,6 +114,10 @@ the word is not imported and will be spell checked in the normal manner.</para>
</listItem>

</list>

<code language="none" title=" ">
vsspell_cad_recognized_word_handling = [None|IgnoreAllWords|AddAllWords|AttributeDeterminesUsage]
</code>
</listItem>

</list>
Expand Down
Loading

0 comments on commit b2118cc

Please sign in to comment.