Skip to content

Commit b2118cc

Browse files
committed
Final updates for initial release of the code analyzer
- 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.
1 parent 46cdb64 commit b2118cc

39 files changed

+1151
-191
lines changed

.editorconfig

Lines changed: 138 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -23,63 +23,162 @@ vsspell_exclusion_expressions_9f07c577adcd4fd7a93a42a503828225 = [a-z]{2}-([A-Z]
2323
vsspell_spell_check_as_you_type = false
2424
vsspell_include_in_project_spell_check = false
2525

26-
# XML files of various types
2726
[*.{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}]
27+
# XML files of various types
2828
indent_style = tab
29+
indent_size = 2
30+
tab_width = 2
2931

30-
# C#/VB settings
3132
[*.{cs,vb}]
33+
# C#/VB settings
3234
indent_size = 4
35+
tab_width = 4
3336

3437
dotnet_sort_system_directives_first = true
3538

39+
# Naming rules
40+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
41+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
42+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
43+
44+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
45+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
46+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
47+
48+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
49+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
50+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
51+
52+
# Symbol specifications
53+
dotnet_naming_symbols.interface.applicable_kinds = interface
54+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
55+
dotnet_naming_symbols.interface.required_modifiers =
56+
57+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
58+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
59+
dotnet_naming_symbols.types.required_modifiers =
60+
61+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
62+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
63+
dotnet_naming_symbols.non_field_members.required_modifiers =
64+
65+
# Naming styles
66+
dotnet_naming_style.begins_with_i.required_prefix = I
67+
dotnet_naming_style.begins_with_i.required_suffix =
68+
dotnet_naming_style.begins_with_i.word_separator =
69+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
70+
71+
dotnet_naming_style.pascal_case.required_prefix =
72+
dotnet_naming_style.pascal_case.required_suffix =
73+
dotnet_naming_style.pascal_case.word_separator =
74+
dotnet_naming_style.pascal_case.capitalization = pascal_case
75+
76+
dotnet_naming_style.pascal_case.required_prefix =
77+
dotnet_naming_style.pascal_case.required_suffix =
78+
dotnet_naming_style.pascal_case.word_separator =
79+
dotnet_naming_style.pascal_case.capitalization = pascal_case
80+
81+
# Code style settings
82+
dotnet_style_predefined_type_for_locals_parameters_members = true:none
83+
dotnet_style_predefined_type_for_member_access = false:error
84+
dotnet_style_coalesce_expression = true:suggestion
85+
dotnet_style_collection_initializer = true:suggestion
86+
dotnet_style_explicit_tuple_names = true:error
87+
dotnet_style_null_propagation = true:suggestion
88+
dotnet_style_object_initializer = true:suggestion
89+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
90+
dotnet_style_prefer_auto_properties = true:silent
91+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
92+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
93+
dotnet_style_prefer_conditional_expression_over_return = true:silent
94+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
95+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
96+
dotnet_style_prefer_compound_assignment = true:suggestion
97+
dotnet_style_prefer_simplified_interpolation = true:suggestion
98+
dotnet_style_namespace_match_folder = true:suggestion
99+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
100+
36101
# "This." and "Me." qualification. Use is preferred where true but the lightbulbs tend to show up in places
37102
# they aren't wanted (within static methods and nameof parameters etc.) so no suggestions are enabled.
38-
dotnet_style_qualification_for_event = true : none
39-
dotnet_style_qualification_for_field = false : none
40-
dotnet_style_qualification_for_method = true : none
41-
dotnet_style_qualification_for_property = true : none
42-
43-
# Language keywords vs framework type names
44-
dotnet_style_predefined_type_for_locals_parameters_members = true : none
45-
dotnet_style_predefined_type_for_member_access = false : error
46-
47-
# Modern language feature settings
48-
dotnet_style_coalesce_expression = true : suggestion
49-
dotnet_style_collection_initializer = true : suggestion
50-
dotnet_style_explicit_tuple_names = true : error
51-
dotnet_style_null_propagation = true : suggestion
52-
dotnet_style_object_initializer = true : suggestion
103+
dotnet_style_qualification_for_event = true:none
104+
dotnet_style_qualification_for_field = false:none
105+
dotnet_style_qualification_for_method = true:none
106+
dotnet_style_qualification_for_property = true:none
53107

54-
# CSharp code style settings
55-
[*.cs]
56-
csharp_style_var_elsewhere = false : none
57-
csharp_style_var_for_built_in_types = false : none
58-
csharp_style_var_when_type_is_apparent = false : none
59-
60-
csharp_style_expression_bodied_accessors = true : suggestion
61-
csharp_style_expression_bodied_constructors = false : none
62-
csharp_style_expression_bodied_indexers = true : suggestion
63-
csharp_style_expression_bodied_methods = false : none
64-
csharp_style_expression_bodied_operators = false : none
65-
csharp_style_expression_bodied_properties = true : suggestion
66-
67-
csharp_style_conditional_delegate_call = true : suggestion
68-
csharp_style_deconstructed_variable_declaration = false : none
69-
csharp_style_inlined_variable_declaration = true : suggestion
70-
csharp_style_pattern_local_over_anonymous_function = true : suggestion
71-
csharp_style_pattern_matching_over_as_with_null_check = true : suggestion
72-
csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion
73-
csharp_style_throw_expression = true : suggestion
74-
75-
csharp_prefer_simple_default_expression = true : suggestion
108+
# Code analyzer settings
109+
# CA1303: Do not pass literals as localized parameters
110+
dotnet_diagnostic.CA1303.severity = none
111+
112+
# IDE0010: Add missing cases
113+
dotnet_diagnostic.IDE0010.severity = none
114+
115+
# IDE0032: Use auto property
116+
dotnet_diagnostic.IDE0032.severity = none
117+
118+
# IDE0045: Convert to conditional expression
119+
dotnet_diagnostic.IDE0045.severity = none
120+
121+
# IDE0046: Convert to conditional expression
122+
dotnet_diagnostic.IDE0046.severity = none
123+
124+
# IDE0047: Remove unnecessary parentheses
125+
dotnet_diagnostic.IDE0047.severity = none
76126

127+
# IDE0055: Fix formatting
128+
dotnet_diagnostic.IDE0055.severity = none
129+
130+
# IDE0058: Expression value is never used
131+
dotnet_diagnostic.IDE0058.severity = none
132+
133+
# IDE1006: Naming Styles
134+
dotnet_diagnostic.IDE1006.severity = none
135+
136+
[*.cs]
137+
# CSharp code style settings
138+
csharp_style_var_elsewhere = false:none
139+
csharp_style_var_for_built_in_types = false:none
140+
csharp_style_var_when_type_is_apparent = false:none
141+
142+
csharp_style_expression_bodied_accessors = true:suggestion
143+
csharp_style_expression_bodied_constructors = false:none
144+
csharp_style_expression_bodied_indexers = true:suggestion
145+
csharp_style_expression_bodied_methods = false:none
146+
csharp_style_expression_bodied_operators = false:none
147+
csharp_style_expression_bodied_properties = true:suggestion
148+
149+
csharp_style_conditional_delegate_call = true:suggestion
150+
csharp_style_deconstructed_variable_declaration = false:none
151+
csharp_style_inlined_variable_declaration = true:suggestion
152+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
153+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
154+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
155+
csharp_style_throw_expression = true:suggestion
156+
csharp_style_namespace_declarations = block_scoped:silent
157+
csharp_style_prefer_method_group_conversion = true:silent
158+
csharp_style_prefer_top_level_statements = true:silent
159+
csharp_style_expression_bodied_lambdas = true:silent
160+
csharp_style_expression_bodied_local_functions = false:silent
161+
csharp_style_prefer_null_check_over_type_check = true:suggestion
162+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
163+
csharp_style_prefer_index_operator = true:suggestion
164+
csharp_style_prefer_range_operator = true:suggestion
165+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
166+
csharp_style_prefer_tuple_swap = true:suggestion
167+
csharp_style_prefer_utf8_string_literals = true:suggestion
168+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
169+
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
170+
171+
csharp_prefer_braces = when_multiline:none
172+
csharp_prefer_simple_default_expression = true:suggestion
173+
csharp_prefer_simple_using_statement = true:suggestion
77174
csharp_preserve_single_line_blocks = true
175+
csharp_using_directive_placement = outside_namespace:silent
78176

79177
# Indentation options
80178
csharp_indent_block_contents = true
81179
csharp_indent_braces = false
82180
csharp_indent_case_contents = true
181+
csharp_indent_labels = no_change
83182

84183
# New line options
85184
csharp_new_line_before_catch = true
@@ -109,31 +208,3 @@ csharp_space_between_method_call_parameter_list_parentheses = false
109208
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
110209
csharp_space_between_method_declaration_name_and_open_parenthesis = false
111210
csharp_space_between_method_declaration_parameter_list_parentheses = false
112-
113-
# CA1303: Do not pass literals as localized parameters
114-
dotnet_diagnostic.CA1303.severity = none
115-
116-
# IDE0010: Add missing cases
117-
dotnet_diagnostic.IDE0010.severity = none
118-
119-
# IDE0032: Use auto property
120-
dotnet_diagnostic.IDE0032.severity = none
121-
122-
# IDE0045: Convert to conditional expression
123-
dotnet_diagnostic.IDE0045.severity = none
124-
125-
# IDE0046: Convert to conditional expression
126-
dotnet_diagnostic.IDE0046.severity = none
127-
128-
# IDE0047: Remove unnecessary parentheses
129-
dotnet_diagnostic.IDE0047.severity = none
130-
131-
# IDE0055: Fix formatting
132-
dotnet_diagnostic.IDE0055.severity = none
133-
134-
# IDE0058: Expression value is never used
135-
dotnet_diagnostic.IDE0058.severity = none
136-
137-
# IDE1006: Naming Styles
138-
dotnet_diagnostic.IDE1006.severity = none
139-

Docs/Content/CodeAnalyzer.aml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<topic id="12d44ba0-2bef-4fac-a6f9-7990ecf057c2" revisionNumber="1">
3+
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
4+
<introduction>
5+
<para>The code analyzer in the spell checker extension is used to spell check identifiers in source code.
6+
Only C# is supported right now but future support for Visual Basic and, if possible, F# are planned. Code
7+
analyzer spell checking differs from the string and comments spell checker implemented using the tagger in the
8+
editor. Identifiers are always split up into separate words on capital letters and other separators such as the
9+
underscore. In addition, there are some extra options related to visibility and placement that can control when
10+
spell checking of identifiers occurs. See the <link xlink:href="09cc5bfa-9eba-47e5-ba5f-a36e04f09b0d" />
11+
configuration category topic for details. Due to the way code analyzers work, there are some limitations. See
12+
the <link xlink:href="a9ff4ce1-0d6b-4376-8d32-02dae64e2075" /> topic for more information.</para>
13+
</introduction>
14+
15+
<section address="Section1">
16+
<content>
17+
<para>The code analyzer contains two rules: <codeInline>VSSpell001</codeInline> used to flag misspelled
18+
words in identifiers and offer suggested fixes and <codeInline>VSSpell002</codeInline> used to offer an option
19+
to add the misspelling to an Ignore Spelling directive comment in the source code file. The first rule defaults
20+
to a warning and will show the usual warning underline on the misspellings. The second rule is hidden by default
21+
and only appears on the smart tag when it is opened.</para>
22+
23+
<para>Place the mouse over the misspelled identifier and click the down arrow on the smart tag to see the
24+
available options. Alternately, you can place the cursor anywhere in the identifier and press <ui>Ctrl+.</ui> or
25+
<ui>Shift+Alt+F10</ui> depending on your version of Visual Studio to show the smart tag options. Note that if an
26+
identifier consists of multiple words and more than one is misspelled, each misspelled part is flagged and
27+
corrected separately.</para>
28+
29+
<para>Select the "Correct spelling of 'XXX'" option to see the suggested replacements. If the
30+
misspelling represents only a part of the identifier, you will see the rest of the identifier in each suggestion.
31+
Select a suggestion to get a preview of the changes that will occur if it is selected. To add the misspelling to
32+
an Ignore spelling directive comment in the file, select the "Ignore word 'XXX'" option and a preview of the
33+
directive will be displayed. The directive comments is placed at the top of the file below any header comments
34+
and above the first directive, using statement, or namespace declaration. If a directive comment already exists
35+
in that location, the new ignored word will be added to it.</para>
36+
</content>
37+
</section>
38+
39+
<relatedTopics>
40+
<link xlink:href="3094ee74-88ae-4355-b702-23dcd55b4197" />
41+
<link xlink:href="a7120f4c-5191-4442-b366-c3e792060569" />
42+
<link xlink:href="83ff9063-294f-4a18-b765-1510c86ad0d4" />
43+
</relatedTopics>
44+
</developerConceptualDocument>
45+
</topic>

Docs/Content/ConfigOptions/CodeAnalysisDictionaries.aml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,43 @@ as shown in the example below.</para>
3333
<para><ui>Import project code analysis dictionaries if present</ui> - This option is enabled by
3434
default and controls whether or not the code analysis dictionaries are imported. If disabled, all of the
3535
following options are ignored.</para>
36+
37+
<code language="none" title=" ">
38+
vsspell_cad_import_code_analysis_dictionaries = [true|false]
39+
</code>
3640
</listItem>
3741

3842
<listItem>
3943
<para><ui>Treat unrecognized words as misspelled words</ui> - This option is enabled by default and
4044
will cause unrecognized words in the dictionary to be treated as misspelled words. Adding a
4145
<codeInline>SpellingAlternates</codeInline> attribute to the <codeInline>Word</codeInline> element allows you to
4246
specify a list of one or more comma-separated words to offer as suggested replacements.</para>
47+
48+
<code language="none" title=" ">
49+
vsspell_cad_treat_unrecognized_words_as_misspelled = [true|false]
50+
</code>
4351
</listItem>
4452

4553
<listItem>
4654
<para><ui>Treat deprecated terms as misspelled words</ui> - This option is enabled by default and
4755
will cause deprecated terms in the dictionary to be treated as misspelled words. The preferred alternate is
4856
offered as the suggested replacement. If the preferred alternate is camel cased, spaces are inserted before each
4957
capital letter.</para>
58+
59+
<code language="none" title=" ">
60+
vsspell_cad_treat_deprecated_terms_as_misspelled = [true|false]
61+
</code>
5062
</listItem>
5163

5264
<listItem>
5365
<para><ui>Treat compound terms as misspelled words</ui> - This option is enabled by default and will
5466
cause compound terms in the dictionary to be treated as misspelled words. The compound alternate is offered as
5567
the suggested replacement. If the compound alternate is camel cased, spaces are inserted before each capital
5668
letter.</para>
69+
70+
<code language="none" title=" ">
71+
vsspell_cad_treat_compound_terms_as_misspelled = [true|false]
72+
</code>
5773
</listItem>
5874

5975
<listItem>
@@ -63,6 +79,10 @@ in all uppercase or camel case. Camel cased words are always ignored. All uppe
6379
<ui>Ignore words in all uppercase</ui> option in the <ui>General Settings</ui> category is enabled. This option
6480
may be of use if that option is disabled so that acronyms in all uppercase within this category are not spell
6581
checked.</para>
82+
83+
<code language="none" title=" ">
84+
vsspell_cad_treat_casing_exceptions_as_ignored_words = [true|false]
85+
</code>
6686
</listItem>
6787

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

96116
</list>
117+
118+
<code language="none" title=" ">
119+
vsspell_cad_recognized_word_handling = [None|IgnoreAllWords|AddAllWords|AttributeDeterminesUsage]
120+
</code>
97121
</listItem>
98122

99123
</list>

0 commit comments

Comments
 (0)