From 20cb4dca2805a97c1b3d7d0f8cee9bc6186e163e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 16 May 2022 13:50:10 +0200 Subject: [PATCH 001/107] Move content into subdirectory. --- .editorconfig => Lombiq.Analyzers/.editorconfig | 0 Build.props => Lombiq.Analyzers/Build.props | 0 .../CommonPackages.props | 0 {Docs => Lombiq.Analyzers/Docs}/AddingAnalyzers.md | 0 .../Docs}/ConfiguringAnalyzers.md | 0 .../Docs}/UsingAnalyzersDuringCommandLineBuilds.md | 0 .../Docs}/UsingAnalyzersDuringDevelopment.md | 0 License.md => Lombiq.Analyzers/License.md | 0 .../Lombiq.Analyzers.csproj | 0 .../NetFx.Build.props | 0 NuGetIcon.png => Lombiq.Analyzers/NuGetIcon.png | Bin Readme.md => Lombiq.Analyzers/Readme.md | 0 SonarLint.xml => Lombiq.Analyzers/SonarLint.xml | 0 .../VisualStudioExtension.Build.props | 0 .../build}/Lombiq.Analyzers.props | 0 general.ruleset => Lombiq.Analyzers/general.ruleset | 0 .../orchard1.ruleset | 0 .../orchardcore.ruleset | 0 stylecop.json => Lombiq.Analyzers/stylecop.json | 0 .../visualstudioextension.ruleset | 0 20 files changed, 0 insertions(+), 0 deletions(-) rename .editorconfig => Lombiq.Analyzers/.editorconfig (100%) rename Build.props => Lombiq.Analyzers/Build.props (100%) rename CommonPackages.props => Lombiq.Analyzers/CommonPackages.props (100%) rename {Docs => Lombiq.Analyzers/Docs}/AddingAnalyzers.md (100%) rename {Docs => Lombiq.Analyzers/Docs}/ConfiguringAnalyzers.md (100%) rename {Docs => Lombiq.Analyzers/Docs}/UsingAnalyzersDuringCommandLineBuilds.md (100%) rename {Docs => Lombiq.Analyzers/Docs}/UsingAnalyzersDuringDevelopment.md (100%) rename License.md => Lombiq.Analyzers/License.md (100%) rename Lombiq.Analyzers.csproj => Lombiq.Analyzers/Lombiq.Analyzers.csproj (100%) rename NetFx.Build.props => Lombiq.Analyzers/NetFx.Build.props (100%) rename NuGetIcon.png => Lombiq.Analyzers/NuGetIcon.png (100%) rename Readme.md => Lombiq.Analyzers/Readme.md (100%) rename SonarLint.xml => Lombiq.Analyzers/SonarLint.xml (100%) rename VisualStudioExtension.Build.props => Lombiq.Analyzers/VisualStudioExtension.Build.props (100%) rename {build => Lombiq.Analyzers/build}/Lombiq.Analyzers.props (100%) rename general.ruleset => Lombiq.Analyzers/general.ruleset (100%) rename orchard1.ruleset => Lombiq.Analyzers/orchard1.ruleset (100%) rename orchardcore.ruleset => Lombiq.Analyzers/orchardcore.ruleset (100%) rename stylecop.json => Lombiq.Analyzers/stylecop.json (100%) rename visualstudioextension.ruleset => Lombiq.Analyzers/visualstudioextension.ruleset (100%) diff --git a/.editorconfig b/Lombiq.Analyzers/.editorconfig similarity index 100% rename from .editorconfig rename to Lombiq.Analyzers/.editorconfig diff --git a/Build.props b/Lombiq.Analyzers/Build.props similarity index 100% rename from Build.props rename to Lombiq.Analyzers/Build.props diff --git a/CommonPackages.props b/Lombiq.Analyzers/CommonPackages.props similarity index 100% rename from CommonPackages.props rename to Lombiq.Analyzers/CommonPackages.props diff --git a/Docs/AddingAnalyzers.md b/Lombiq.Analyzers/Docs/AddingAnalyzers.md similarity index 100% rename from Docs/AddingAnalyzers.md rename to Lombiq.Analyzers/Docs/AddingAnalyzers.md diff --git a/Docs/ConfiguringAnalyzers.md b/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md similarity index 100% rename from Docs/ConfiguringAnalyzers.md rename to Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md diff --git a/Docs/UsingAnalyzersDuringCommandLineBuilds.md b/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md similarity index 100% rename from Docs/UsingAnalyzersDuringCommandLineBuilds.md rename to Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md diff --git a/Docs/UsingAnalyzersDuringDevelopment.md b/Lombiq.Analyzers/Docs/UsingAnalyzersDuringDevelopment.md similarity index 100% rename from Docs/UsingAnalyzersDuringDevelopment.md rename to Lombiq.Analyzers/Docs/UsingAnalyzersDuringDevelopment.md diff --git a/License.md b/Lombiq.Analyzers/License.md similarity index 100% rename from License.md rename to Lombiq.Analyzers/License.md diff --git a/Lombiq.Analyzers.csproj b/Lombiq.Analyzers/Lombiq.Analyzers.csproj similarity index 100% rename from Lombiq.Analyzers.csproj rename to Lombiq.Analyzers/Lombiq.Analyzers.csproj diff --git a/NetFx.Build.props b/Lombiq.Analyzers/NetFx.Build.props similarity index 100% rename from NetFx.Build.props rename to Lombiq.Analyzers/NetFx.Build.props diff --git a/NuGetIcon.png b/Lombiq.Analyzers/NuGetIcon.png similarity index 100% rename from NuGetIcon.png rename to Lombiq.Analyzers/NuGetIcon.png diff --git a/Readme.md b/Lombiq.Analyzers/Readme.md similarity index 100% rename from Readme.md rename to Lombiq.Analyzers/Readme.md diff --git a/SonarLint.xml b/Lombiq.Analyzers/SonarLint.xml similarity index 100% rename from SonarLint.xml rename to Lombiq.Analyzers/SonarLint.xml diff --git a/VisualStudioExtension.Build.props b/Lombiq.Analyzers/VisualStudioExtension.Build.props similarity index 100% rename from VisualStudioExtension.Build.props rename to Lombiq.Analyzers/VisualStudioExtension.Build.props diff --git a/build/Lombiq.Analyzers.props b/Lombiq.Analyzers/build/Lombiq.Analyzers.props similarity index 100% rename from build/Lombiq.Analyzers.props rename to Lombiq.Analyzers/build/Lombiq.Analyzers.props diff --git a/general.ruleset b/Lombiq.Analyzers/general.ruleset similarity index 100% rename from general.ruleset rename to Lombiq.Analyzers/general.ruleset diff --git a/orchard1.ruleset b/Lombiq.Analyzers/orchard1.ruleset similarity index 100% rename from orchard1.ruleset rename to Lombiq.Analyzers/orchard1.ruleset diff --git a/orchardcore.ruleset b/Lombiq.Analyzers/orchardcore.ruleset similarity index 100% rename from orchardcore.ruleset rename to Lombiq.Analyzers/orchardcore.ruleset diff --git a/stylecop.json b/Lombiq.Analyzers/stylecop.json similarity index 100% rename from stylecop.json rename to Lombiq.Analyzers/stylecop.json diff --git a/visualstudioextension.ruleset b/Lombiq.Analyzers/visualstudioextension.ruleset similarity index 100% rename from visualstudioextension.ruleset rename to Lombiq.Analyzers/visualstudioextension.ruleset From 9d5ea7452dfaf4f4699809f54813954cf22bd8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 16 May 2022 19:49:50 +0200 Subject: [PATCH 002/107] Add TestSolutions. --- TestSolutions/AnalyzerViolations.cs | 11 + TestSolutions/Directory.Build.props | 6 + .../.editorconfig | 294 ++++++++++++++++++ .../Lombiq.Analyzers.PackageReference.csproj | 19 ++ .../Lombiq.Analyzers.PackageReference.sln | 22 ++ .../.editorconfig | 293 +++++++++++++++++ .../Lombiq.Analyzers.ProjectReference.csproj | 17 + .../Lombiq.Analyzers.ProjectReference.sln | 28 ++ 8 files changed, 690 insertions(+) create mode 100644 TestSolutions/AnalyzerViolations.cs create mode 100644 TestSolutions/Directory.Build.props create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln create mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig create mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj create mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln diff --git a/TestSolutions/AnalyzerViolations.cs b/TestSolutions/AnalyzerViolations.cs new file mode 100644 index 00000000..d58e74f3 --- /dev/null +++ b/TestSolutions/AnalyzerViolations.cs @@ -0,0 +1,11 @@ +namespace Lombiq.Analyzers.ProjectReference; + +// This file has intentional analyzer violations. +public class Class1 +{ + private int Number; + public Class1(int number) + { + Number = number; + } +} diff --git a/TestSolutions/Directory.Build.props b/TestSolutions/Directory.Build.props new file mode 100644 index 00000000..2e839409 --- /dev/null +++ b/TestSolutions/Directory.Build.props @@ -0,0 +1,6 @@ + + + + true + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig new file mode 100644 index 00000000..f61b5467 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig @@ -0,0 +1,294 @@ +# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will +# be overwritten. + +# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference +# If you found some issue then try to fix it, which you can also do from VS Quick Actions: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles +# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. + +# All files +[*] + +# Basics + +charset = utf-8 +guidelines = 120 1px dotted 80ff0000, 150 1px solid 80ff0000 + +# Indentation and spacing +indent_size = 4 +indent_style = space +trim_trailing_whitespace = true + + +# New line preferences +end_of_line = crlf +insert_final_newline = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_auto_properties = true:warning + +# C# files +[*.cs] + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:warning +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_property = false:warning + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = always:warning + +# Expression-level preferences +dotnet_style_coalesce_expression = true:warning +dotnet_style_collection_initializer = true:warning +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_object_initializer = true:warning +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_return = false +dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning +dotnet_style_prefer_inferred_tuple_names = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_simplified_interpolation = true:warning + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = non_pubic:suggestion + +#### C# Style Rules #### + +#IDE* rules are managed here. + +# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced +# during build, see: https://github.com/dotnet/roslyn/issues/44201. + +# Default severity for analyzer diagnostics with category 'Style' (escalated to build warnings) +dotnet_analyzer_diagnostic.category-Style.severity = warning + +# IDE0011: Add braces to 'if' statement. +# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn +# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. +dotnet_diagnostic.IDE0011.severity = none +# IDE0050: Convert to tuple +# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and +# those can fail on this silently in runtime while building correctly. +dotnet_diagnostic.IDE0050.severity = none +# IDE0052: Private member can be removed as the value assigned to it is never used. +# We use S4487 for that. +dotnet_diagnostic.IDE0052.severity = none +# IDE0072: Populate switch +# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. +dotnet_diagnostic.IDE0072.severity = none +# "Namespace 'Foo' does not match folder structure, expected 'Foo'" +dotnet_diagnostic.IDE0130.severity = none + +# While these are in the Style category, they need to be explicitly set for some reason. +# IDE0079 Remove unnecessary suppression +dotnet_diagnostic.IDE0079.severity = warning +dotnet_diagnostic.IDE0022.severity = warning + +# 'var' preferences +dotnet_diagnostic.IDE0007.severity = warning +dotnet_diagnostic.IDE0008.severity = none + +#### C# Coding Conventions #### + +# 'var' preferences +# These won't take effect during build due to this bug: +# https://github.com/dotnet/roslyn/issues/44250 +csharp_style_var_elsewhere = true:warning +# If this is not turned off then there will be messages for e.g. integers too, like in for loops. +csharp_style_var_for_built_in_types = false:none +csharp_style_var_when_type_is_apparent = true:warning + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:warning +csharp_style_expression_bodied_constructors = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_lambdas = true:warning +csharp_style_expression_bodied_local_functions = true:warning +csharp_style_expression_bodied_methods = true:warning +csharp_style_expression_bodied_operators = true:warning +csharp_style_expression_bodied_properties = true:warning + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_prefer_switch_expression = true:warning + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:warning + +# Modifier preferences +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_simple_using_statement = true:warning +# IDE0160: Convert to block-scoped namespace +csharp_style_namespace_declarations = file_scoped:warning + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:warning +csharp_style_deconstructed_variable_declaration = false:silent +csharp_style_inlined_variable_declaration = true:warning +csharp_style_pattern_local_over_anonymous_function = true:warning +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_range_operator = true:warning +csharp_style_throw_expression = true:warning +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:none + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +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 +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# 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 = * +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = * +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 = * +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +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.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 + +# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. +dotnet_diagnostic.CA1031.severity = silent +# Disabling "do not nest type" suggestion. +dotnet_diagnostic.CA1034.severity = silent +# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. +dotnet_diagnostic.CA1810.severity = none + +# Don't apply "CA1822: Mark members as static" to the public API +dotnet_code_quality.ca1822.api_surface = private, internal +csharp_prefer_braces = true:silent + +# Various config files +[*.{config,csproj,json,props,targets}] + +indent_size = 2 + +# Markdown files +[*.md] + +trim_trailing_whitespace = false + +# JavaScript files +[*.js] + +# Placeholder, no unique rules for JS files at the moment. + + +# SCSS files +[*.scss] + +# Placeholder, no unique rules for SCSS files at the moment. + +# PowerShell files +[*.ps1] + +# Placeholder, no unique rules for PS files at the moment. diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj new file mode 100644 index 00000000..4fbe427b --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + + + + + AnalyzerViolations.cs + + + + + + + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln new file mode 100644 index 00000000..efd16391 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers.PackageReference", "Lombiq.Analyzers.PackageReference.csproj", "{431AE877-59B7-438C-91AE-825AC847B447}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {431AE877-59B7-438C-91AE-825AC847B447}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {431AE877-59B7-438C-91AE-825AC847B447}.Debug|Any CPU.Build.0 = Debug|Any CPU + {431AE877-59B7-438C-91AE-825AC847B447}.Release|Any CPU.ActiveCfg = Release|Any CPU + {431AE877-59B7-438C-91AE-825AC847B447}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig new file mode 100644 index 00000000..82b4d841 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig @@ -0,0 +1,293 @@ +# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will +# be overwritten. + +# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference +# If you found some issue then try to fix it, which you can also do from VS Quick Actions: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles +# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. + +# All files +[*] + +# Basics +charset = utf-8 +guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000 + +# Indentation and spacing +indent_size = 4 +indent_style = space +trim_trailing_whitespace = true + + +# New line preferences +end_of_line = crlf +insert_final_newline = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_auto_properties = true:warning + +# C# files +[*.cs] + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:warning +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_property = false:warning + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = always:warning + +# Expression-level preferences +dotnet_style_coalesce_expression = true:warning +dotnet_style_collection_initializer = true:warning +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_object_initializer = true:warning +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_return = false +dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning +dotnet_style_prefer_inferred_tuple_names = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_simplified_interpolation = true:warning + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = non_pubic:suggestion + +#### C# Style Rules #### + +#IDE* rules are managed here. + +# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced +# during build, see: https://github.com/dotnet/roslyn/issues/44201. + +# Default severity for analyzer diagnostics with category 'Style' (escalated to build warnings) +dotnet_analyzer_diagnostic.category-Style.severity = warning + +# IDE0011: Add braces to 'if' statement. +# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn +# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. +dotnet_diagnostic.IDE0011.severity = none +# IDE0050: Convert to tuple +# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and +# those can fail on this silently in runtime while building correctly. +dotnet_diagnostic.IDE0050.severity = none +# IDE0052: Private member can be removed as the value assigned to it is never used. +# We use S4487 for that. +dotnet_diagnostic.IDE0052.severity = none +# IDE0072: Populate switch +# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. +dotnet_diagnostic.IDE0072.severity = none +# "Namespace 'Foo' does not match folder structure, expected 'Foo'" +dotnet_diagnostic.IDE0130.severity = none + +# While these are in the Style category, they need to be explicitly set for some reason. +# IDE0079 Remove unnecessary suppression +dotnet_diagnostic.IDE0079.severity = warning +dotnet_diagnostic.IDE0022.severity = warning + +# 'var' preferences +dotnet_diagnostic.IDE0007.severity = warning +dotnet_diagnostic.IDE0008.severity = none + +#### C# Coding Conventions #### + +# 'var' preferences +# These won't take effect during build due to this bug: +# https://github.com/dotnet/roslyn/issues/44250 +csharp_style_var_elsewhere = true:warning +# If this is not turned off then there will be messages for e.g. integers too, like in for loops. +csharp_style_var_for_built_in_types = false:none +csharp_style_var_when_type_is_apparent = true:warning + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:warning +csharp_style_expression_bodied_constructors = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_lambdas = true:warning +csharp_style_expression_bodied_local_functions = true:warning +csharp_style_expression_bodied_methods = true:warning +csharp_style_expression_bodied_operators = true:warning +csharp_style_expression_bodied_properties = true:warning + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_prefer_switch_expression = true:warning + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:warning + +# Modifier preferences +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_simple_using_statement = true:warning +# IDE0160: Convert to block-scoped namespace +csharp_style_namespace_declarations = file_scoped:warning + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:warning +csharp_style_deconstructed_variable_declaration = false:silent +csharp_style_inlined_variable_declaration = true:warning +csharp_style_pattern_local_over_anonymous_function = true:warning +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_range_operator = true:warning +csharp_style_throw_expression = true:warning +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:none + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +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 +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# 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 = * +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = * +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 = * +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +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.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 + +# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. +dotnet_diagnostic.CA1031.severity = silent +# Disabling "do not nest type" suggestion. +dotnet_diagnostic.CA1034.severity = silent +# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. +dotnet_diagnostic.CA1810.severity = none + +# Don't apply "CA1822: Mark members as static" to the public API +dotnet_code_quality.ca1822.api_surface = private, internal +csharp_prefer_braces = true:silent + +# Various config files +[*.{config,csproj,json,props,targets}] + +indent_size = 2 + +# Markdown files +[*.md] + +trim_trailing_whitespace = false + +# JavaScript files +[*.js] + +# Placeholder, no unique rules for JS files at the moment. + + +# SCSS files +[*.scss] + +# Placeholder, no unique rules for SCSS files at the moment. + +# PowerShell files +[*.ps1] + +# Placeholder, no unique rules for PS files at the moment. diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj new file mode 100644 index 00000000..6be2523b --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + AnalyzerViolations.cs + + + + + + diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln new file mode 100644 index 00000000..4e308081 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers.ProjectReference", "Lombiq.Analyzers.ProjectReference.csproj", "{E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers", "..\..\Lombiq.Analyzers\Lombiq.Analyzers.csproj", "{E4090872-11F2-49D1-A746-65E15DC4977E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E43F83B6-F5D0-4FD9-AD3D-2FB071B777A6}.Release|Any CPU.Build.0 = Release|Any CPU + {E4090872-11F2-49D1-A746-65E15DC4977E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4090872-11F2-49D1-A746-65E15DC4977E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4090872-11F2-49D1-A746-65E15DC4977E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4090872-11F2-49D1-A746-65E15DC4977E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal From 86783ee2053258c032d1a2f591f5f611d5024513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 16 May 2022 20:25:50 +0200 Subject: [PATCH 003/107] Added tests. --- .../AnalyzerViolationTests.cs | 62 +++++++++++++++++++ .../Lombiq.Analyzers.Tests.csproj | 21 +++++++ 2 files changed, 83 insertions(+) create mode 100644 Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs create mode 100644 Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs new file mode 100644 index 00000000..20bdd142 --- /dev/null +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -0,0 +1,62 @@ +using Lombiq.HelpfulLibraries.Cli; +using Shouldly; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Lombiq.Analyzers.Tests.Failure; + +public class AnalyzerViolationTests +{ + [Theory] + [MemberData(nameof(Data))] + public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) + { + var exception = (InvalidOperationException)await Should.ThrowAsync( + () => ExecuteStaticCodeAnalysisAsync(solutionRelativePath), + typeof(InvalidOperationException)); + + // Excepted exception codes: + // error IDE0021: Use expression body for constructors. + // error IDE0044: Make field readonly. + // error S2933: Make 'Number' 'readonly'. + // error S4487: Remove this unread private field 'Number' or refactor the code to use its value. + + var exceptionCodes = new[] { "IDE0021", "IDE0044", "S2933", "S4487" }; + + exception + .Message + .Split(new[] { '\n', '\r' }, StringSplitOptions.None) + .Where(line => line.Contains(" error ")) + .Select(line => line.RegexReplace(@"^.* error ([^:]+):.*$", "$1")) + .OrderBy(line => line) + .ShouldBe(exceptionCodes); + } + + // See https://github.com/Lombiq/.NET-Analyzers/blob/dev/Docs/UsingAnalyzersDuringCommandLineBuilds.md#net-code-style-analysis + private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath) => + CliProgram.DotNet.ExecuteAsync( + CancellationToken.None, + "build", + Path.Combine("..", "..", "..", "..", "TestSolutions", solutionPath), + "--no-incremental", + "-warnaserror", + "/p:TreatWarningsAsErrors=true", + "/p:RunAnalyzersDuringBuild=true", + "-nologo", + "-consoleLoggerParameters:NoSummary", + "-verbosity:quiet"); + + public static IEnumerable Data() + { + static object[] FromProjectName(string projectName) => + new object[] { Path.Combine(projectName, projectName + ".csproj") }; + + yield return FromProjectName("Lombiq.Analyzers.PackageReference"); + yield return FromProjectName("Lombiq.Analyzers.ProjectReference"); + } +} diff --git a/Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj b/Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj new file mode 100644 index 00000000..e5d997b7 --- /dev/null +++ b/Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj @@ -0,0 +1,21 @@ + + + + net6.0 + Lombiq.Analyzers.Tests.Failure + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + From dec7cfe23f8b63af2383c765a04079119c142900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 16 May 2022 22:14:33 +0200 Subject: [PATCH 004/107] project cleanup --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 2 +- Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj | 1 - .../Lombiq.Analyzers.PackageReference.csproj | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index 20bdd142..c8ef33d3 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Xunit; -namespace Lombiq.Analyzers.Tests.Failure; +namespace Lombiq.Analyzers.Tests; public class AnalyzerViolationTests { diff --git a/Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj b/Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj index e5d997b7..0670df6a 100644 --- a/Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj +++ b/Lombiq.Analyzers.Tests/Lombiq.Analyzers.Tests.csproj @@ -2,7 +2,6 @@ net6.0 - Lombiq.Analyzers.Tests.Failure diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 4fbe427b..18c72df3 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,7 +11,7 @@ AnalyzerViolations.cs - + From 6b48bff488bc85a846fffdd8dfddecd482873555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 18 May 2022 01:44:24 +0200 Subject: [PATCH 005/107] Update TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj Co-authored-by: 0liver <0liver@users.noreply.github.com> --- .../Lombiq.Analyzers.PackageReference.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 18c72df3..191cb7aa 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,7 +11,6 @@ AnalyzerViolations.cs - From 84fee235cd9ecd84a46e6607bdb1af4bb9f12220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 19 May 2022 16:58:40 +0200 Subject: [PATCH 006/107] Make RunAnalyzersDuringBuild conditional. --- Lombiq.Analyzers/Build.props | 8 ++++++-- TestSolutions/Directory.Build.props | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 283abe5e..d0808f37 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -2,8 +2,6 @@ $(MSBuildThisFileDirectory)orchardcore.ruleset true - - false @@ -24,6 +22,12 @@ <_SkipUpgradeNetAnalyzersNuGetWarning>true + + + false + + diff --git a/TestSolutions/Directory.Build.props b/TestSolutions/Directory.Build.props index 2e839409..890609b6 100644 --- a/TestSolutions/Directory.Build.props +++ b/TestSolutions/Directory.Build.props @@ -1,5 +1,8 @@ + true From c528e7bc7e1c6293ab37eef9c696bdf21afd2ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 19 May 2022 16:58:58 +0200 Subject: [PATCH 007/107] Improve solutions. --- .../Lombiq.Analyzers.PackageReference.csproj | 3 +-- .../Lombiq.Analyzers.PackageReference.sln | 5 +++++ .../Lombiq.Analyzers.ProjectReference.sln | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 191cb7aa..6869271c 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -10,8 +10,7 @@ AnalyzerViolations.cs - - + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln index efd16391..5b85c186 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln @@ -5,6 +5,11 @@ VisualStudioVersion = 16.0.30114.105 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers.PackageReference", "Lombiq.Analyzers.PackageReference.csproj", "{431AE877-59B7-438C-91AE-825AC847B447}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0533C5D5-F4D0-4231-A810-80E7342F9C33}" + ProjectSection(SolutionItems) = preProject + ..\Directory.Build.props = ..\Directory.Build.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln index 4e308081..80f6336c 100644 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.sln @@ -7,6 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers.ProjectRef EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers", "..\..\Lombiq.Analyzers\Lombiq.Analyzers.csproj", "{E4090872-11F2-49D1-A746-65E15DC4977E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE857933-4E64-44B8-A1CA-3489F88475AB}" + ProjectSection(SolutionItems) = preProject + ..\Directory.Build.props = ..\Directory.Build.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From 0f02f846de85cc6d45f6061358e98d4e6e587bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 19 May 2022 17:03:09 +0200 Subject: [PATCH 008/107] Spacing. --- TestSolutions/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/TestSolutions/Directory.Build.props b/TestSolutions/Directory.Build.props index 890609b6..26f93c00 100644 --- a/TestSolutions/Directory.Build.props +++ b/TestSolutions/Directory.Build.props @@ -3,6 +3,7 @@ + true From 4604db852b9a5c291804763b036319d5f063bcf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 19 May 2022 17:11:12 +0200 Subject: [PATCH 009/107] Add root solution file for nuget publishing. --- Lombiq.Analyzers.sln | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Lombiq.Analyzers.sln diff --git a/Lombiq.Analyzers.sln b/Lombiq.Analyzers.sln new file mode 100644 index 00000000..d7b048a3 --- /dev/null +++ b/Lombiq.Analyzers.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers", "Lombiq.Analyzers\Lombiq.Analyzers.csproj", "{1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal From 13d4023ef4fa6504ac673af572ce5ac3dd292f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 19 May 2022 17:17:59 +0200 Subject: [PATCH 010/107] Update package version. --- Lombiq.Analyzers/Build.props | 2 +- .../Lombiq.Analyzers.PackageReference.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index d0808f37..7f4a2192 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -24,7 +24,7 @@ - + false diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 6869271c..95a5afda 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,7 +11,7 @@ AnalyzerViolations.cs - + From 981233df8c15c4095c045401937ee69fb296406c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 20 May 2022 00:16:45 +0200 Subject: [PATCH 011/107] Use msbuild for CLI static code analysis. --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 15 +++++++-------- .../Docs/UsingAnalyzersDuringCommandLineBuilds.md | 6 ++++++ .../.editorconfig | 1 - 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index c8ef33d3..86efc90b 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -37,19 +37,18 @@ public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) .ShouldBe(exceptionCodes); } + // Runs dotnet msbuild {solutionPath}.sln -t:Clean,Build -v:quiet -p:RunAnalyzersDuringBuild=true -p:TreatWarningsAsErrors=true -warnAsError // See https://github.com/Lombiq/.NET-Analyzers/blob/dev/Docs/UsingAnalyzersDuringCommandLineBuilds.md#net-code-style-analysis private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath) => CliProgram.DotNet.ExecuteAsync( CancellationToken.None, - "build", + "msbuild", Path.Combine("..", "..", "..", "..", "TestSolutions", solutionPath), - "--no-incremental", - "-warnaserror", - "/p:TreatWarningsAsErrors=true", - "/p:RunAnalyzersDuringBuild=true", - "-nologo", - "-consoleLoggerParameters:NoSummary", - "-verbosity:quiet"); + "-t:Clean,Build", + "-v:quiet", + "-p:RunAnalyzersDuringBuild=true", + "-p:TreatWarningsAsErrors=true", + "-warnAsError"); public static IEnumerable Data() { diff --git a/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md b/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md index 9d3503ac..48808b48 100644 --- a/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md +++ b/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md @@ -41,6 +41,12 @@ Or if you only want to see the errors and not the full build output (including e dotnet build MySolution.sln --no-incremental -warnaserror /p:TreatWarningsAsErrors=true /p:RunAnalyzersDuringBuild=true -nologo -consoleLoggerParameters:NoSummary -verbosity:quiet ``` +If you are using the NuGet package you have to call it with MsBuild instead: + +```ps +dotnet msbuild {solutionPath}.sln -t:Clean,Build -v:quiet -p:RunAnalyzersDuringBuild=true -p:TreatWarningsAsErrors=true -warnAsError +``` + Note that code style analysis is experimental in the .NET 5 SDK and [may change in later versions](https://github.com/dotnet/roslyn/issues/49044). diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig index f61b5467..837b2850 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig @@ -11,7 +11,6 @@ [*] # Basics - charset = utf-8 guidelines = 120 1px dotted 80ff0000, 150 1px solid 80ff0000 From 82fe04e96ca62e9d77456c9d141c249335170c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 20 May 2022 01:17:29 +0200 Subject: [PATCH 012/107] Restore before msbuild in the tests too. --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index 86efc90b..ee2c61b6 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -39,8 +39,11 @@ public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) // Runs dotnet msbuild {solutionPath}.sln -t:Clean,Build -v:quiet -p:RunAnalyzersDuringBuild=true -p:TreatWarningsAsErrors=true -warnAsError // See https://github.com/Lombiq/.NET-Analyzers/blob/dev/Docs/UsingAnalyzersDuringCommandLineBuilds.md#net-code-style-analysis - private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath) => - CliProgram.DotNet.ExecuteAsync( + private static async Task ExecuteStaticCodeAnalysisAsync(string solutionPath) + { + await CliProgram.DotNet.ExecuteAsync(CancellationToken.None, "restore"); + + await CliProgram.DotNet.ExecuteAsync( CancellationToken.None, "msbuild", Path.Combine("..", "..", "..", "..", "TestSolutions", solutionPath), @@ -49,6 +52,7 @@ private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath) => "-p:RunAnalyzersDuringBuild=true", "-p:TreatWarningsAsErrors=true", "-warnAsError"); + } public static IEnumerable Data() { From 801c7ffb01b8fc0dad03139326fdd54e79d573e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 20 May 2022 01:27:12 +0200 Subject: [PATCH 013/107] use solution path too --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index ee2c61b6..9fa0ce6b 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -41,12 +41,14 @@ public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) // See https://github.com/Lombiq/.NET-Analyzers/blob/dev/Docs/UsingAnalyzersDuringCommandLineBuilds.md#net-code-style-analysis private static async Task ExecuteStaticCodeAnalysisAsync(string solutionPath) { - await CliProgram.DotNet.ExecuteAsync(CancellationToken.None, "restore"); + var relativeSolutionPath = Path.Combine("..", "..", "..", "..", "TestSolutions", solutionPath); + + await CliProgram.DotNet.ExecuteAsync(CancellationToken.None, "restore", relativeSolutionPath); await CliProgram.DotNet.ExecuteAsync( CancellationToken.None, "msbuild", - Path.Combine("..", "..", "..", "..", "TestSolutions", solutionPath), + relativeSolutionPath, "-t:Clean,Build", "-v:quiet", "-p:RunAnalyzersDuringBuild=true", From a5547ba1b9f228058a68c83635ed838a3a1d4fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 20 May 2022 17:28:53 +0200 Subject: [PATCH 014/107] Compress CommonPackages. --- Lombiq.Analyzers/CommonPackages.props | 48 ++++++------------- .../Lombiq.Analyzers.PackageReference.csproj | 7 +++ 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/Lombiq.Analyzers/CommonPackages.props b/Lombiq.Analyzers/CommonPackages.props index 0fbeab8d..77d99821 100644 --- a/Lombiq.Analyzers/CommonPackages.props +++ b/Lombiq.Analyzers/CommonPackages.props @@ -2,42 +2,24 @@ + - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - + + + + + + + + + + + + + all runtime; build; native; contentfiles; analyzers; + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 95a5afda..34721548 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -14,4 +14,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; + + + From b38a73ca33de31582f510e7395a3c2bce49f682f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 03:19:22 +0200 Subject: [PATCH 015/107] Update packages from `dev` branch. --- Lombiq.Analyzers/CommonPackages.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lombiq.Analyzers/CommonPackages.props b/Lombiq.Analyzers/CommonPackages.props index 77d99821..06300ab6 100644 --- a/Lombiq.Analyzers/CommonPackages.props +++ b/Lombiq.Analyzers/CommonPackages.props @@ -6,13 +6,13 @@ - - + + - - + + From 5a1272fc2c34613a580c50ae6fff9ad1fbe52b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 06:51:57 +0200 Subject: [PATCH 016/107] Make the csproj `netstandard2.0`. --- Lombiq.Analyzers/Lombiq.Analyzers.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers/Lombiq.Analyzers.csproj b/Lombiq.Analyzers/Lombiq.Analyzers.csproj index e007f007..81d972c8 100644 --- a/Lombiq.Analyzers/Lombiq.Analyzers.csproj +++ b/Lombiq.Analyzers/Lombiq.Analyzers.csproj @@ -1,7 +1,7 @@ - net6.0 + netstandard2.0 $(DefaultItemExcludes);.git*; @@ -29,5 +29,5 @@ - + From 567eacfd7bb8bae1f275f53e7c14558245bb3c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 07:06:28 +0200 Subject: [PATCH 017/107] Change `verify`'s branch selector. --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 93bf3594..2c800486 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -5,4 +5,4 @@ on: jobs: call-verify-workflow: - uses: Lombiq/GitHub-Actions/.github/workflows/verify.yml@dev + uses: Lombiq/GitHub-Actions/.github/workflows/verify.yml@issue/OSOE-110 From bb34d926ed6d4c4de34bcabf8c8119e0088beb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 21:12:39 +0200 Subject: [PATCH 018/107] Remove unneeded files. --- .../.editorconfig | 293 ------------------ .../.editorconfig | 293 ------------------ 2 files changed, 586 deletions(-) delete mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig delete mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig deleted file mode 100644 index 837b2850..00000000 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig +++ /dev/null @@ -1,293 +0,0 @@ -# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will -# be overwritten. - -# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference -# If you found some issue then try to fix it, which you can also do from VS Quick Actions: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles -# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. - -# All files -[*] - -# Basics -charset = utf-8 -guidelines = 120 1px dotted 80ff0000, 150 1px solid 80ff0000 - -# Indentation and spacing -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true - - -# New line preferences -end_of_line = crlf -insert_final_newline = true -dotnet_style_operator_placement_when_wrapping = beginning_of_line -tab_width = 4 -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_auto_properties = true:warning - -# C# files -[*.cs] - -#### .NET Coding Conventions #### - -# Organize usings -dotnet_separate_import_directive_groups = false -dotnet_sort_system_directives_first = false - -# this. and Me. preferences -dotnet_style_qualification_for_event = false:warning -dotnet_style_qualification_for_field = false:warning -dotnet_style_qualification_for_method = false:warning -dotnet_style_qualification_for_property = false:warning - -# Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:warning -dotnet_style_predefined_type_for_member_access = true:warning - -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent - -# Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning - -# Expression-level preferences -dotnet_style_coalesce_expression = true:warning -dotnet_style_collection_initializer = true:warning -dotnet_style_explicit_tuple_names = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_object_initializer = true:warning -dotnet_style_prefer_auto_properties = true:warning -dotnet_style_prefer_compound_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_return = false -dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning -dotnet_style_prefer_inferred_tuple_names = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_simplified_interpolation = true:warning - -# Field preferences -dotnet_style_readonly_field = true:warning - -# Parameter preferences -dotnet_code_quality_unused_parameters = non_pubic:suggestion - -#### C# Style Rules #### - -#IDE* rules are managed here. - -# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced -# during build, see: https://github.com/dotnet/roslyn/issues/44201. - -# Default severity for analyzer diagnostics with category 'Style' (escalated to build warnings) -dotnet_analyzer_diagnostic.category-Style.severity = warning - -# IDE0011: Add braces to 'if' statement. -# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn -# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. -dotnet_diagnostic.IDE0011.severity = none -# IDE0050: Convert to tuple -# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and -# those can fail on this silently in runtime while building correctly. -dotnet_diagnostic.IDE0050.severity = none -# IDE0052: Private member can be removed as the value assigned to it is never used. -# We use S4487 for that. -dotnet_diagnostic.IDE0052.severity = none -# IDE0072: Populate switch -# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. -dotnet_diagnostic.IDE0072.severity = none -# "Namespace 'Foo' does not match folder structure, expected 'Foo'" -dotnet_diagnostic.IDE0130.severity = none - -# While these are in the Style category, they need to be explicitly set for some reason. -# IDE0079 Remove unnecessary suppression -dotnet_diagnostic.IDE0079.severity = warning -dotnet_diagnostic.IDE0022.severity = warning - -# 'var' preferences -dotnet_diagnostic.IDE0007.severity = warning -dotnet_diagnostic.IDE0008.severity = none - -#### C# Coding Conventions #### - -# 'var' preferences -# These won't take effect during build due to this bug: -# https://github.com/dotnet/roslyn/issues/44250 -csharp_style_var_elsewhere = true:warning -# If this is not turned off then there will be messages for e.g. integers too, like in for loops. -csharp_style_var_for_built_in_types = false:none -csharp_style_var_when_type_is_apparent = true:warning - -# Expression-bodied members -csharp_style_expression_bodied_accessors = true:warning -csharp_style_expression_bodied_constructors = true:warning -csharp_style_expression_bodied_indexers = true:warning -csharp_style_expression_bodied_lambdas = true:warning -csharp_style_expression_bodied_local_functions = true:warning -csharp_style_expression_bodied_methods = true:warning -csharp_style_expression_bodied_operators = true:warning -csharp_style_expression_bodied_properties = true:warning - -# Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:warning -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_prefer_switch_expression = true:warning - -# Null-checking preferences -csharp_style_conditional_delegate_call = true:warning - -# Modifier preferences -csharp_prefer_static_local_function = true:warning -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent - -# Code-block preferences -csharp_prefer_simple_using_statement = true:warning -# IDE0160: Convert to block-scoped namespace -csharp_style_namespace_declarations = file_scoped:warning - -# Expression-level preferences -csharp_prefer_simple_default_expression = true:warning -csharp_style_deconstructed_variable_declaration = false:silent -csharp_style_inlined_variable_declaration = true:warning -csharp_style_pattern_local_over_anonymous_function = true:warning -csharp_style_prefer_index_operator = true:warning -csharp_style_prefer_range_operator = true:warning -csharp_style_throw_expression = true:warning -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:none - -# 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent - -#### C# Formatting Rules #### - -# New line preferences -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_open_brace = all -csharp_new_line_between_query_expression_clauses = true - -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_case_contents_when_block = true -csharp_indent_labels = no_change -csharp_indent_switch_labels = true - -# Space preferences -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -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 -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -# Wrapping preferences -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true - -#### Naming styles #### - -# 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 = * -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.types.applicable_accessibilities = * -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 = * -dotnet_naming_symbols.non_field_members.required_modifiers = - -# Naming styles - -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.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 - -# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. -dotnet_diagnostic.CA1031.severity = silent -# Disabling "do not nest type" suggestion. -dotnet_diagnostic.CA1034.severity = silent -# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. -dotnet_diagnostic.CA1810.severity = none - -# Don't apply "CA1822: Mark members as static" to the public API -dotnet_code_quality.ca1822.api_surface = private, internal -csharp_prefer_braces = true:silent - -# Various config files -[*.{config,csproj,json,props,targets}] - -indent_size = 2 - -# Markdown files -[*.md] - -trim_trailing_whitespace = false - -# JavaScript files -[*.js] - -# Placeholder, no unique rules for JS files at the moment. - - -# SCSS files -[*.scss] - -# Placeholder, no unique rules for SCSS files at the moment. - -# PowerShell files -[*.ps1] - -# Placeholder, no unique rules for PS files at the moment. diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig deleted file mode 100644 index 82b4d841..00000000 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig +++ /dev/null @@ -1,293 +0,0 @@ -# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will -# be overwritten. - -# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference -# If you found some issue then try to fix it, which you can also do from VS Quick Actions: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles -# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. - -# All files -[*] - -# Basics -charset = utf-8 -guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000 - -# Indentation and spacing -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true - - -# New line preferences -end_of_line = crlf -insert_final_newline = true -dotnet_style_operator_placement_when_wrapping = beginning_of_line -tab_width = 4 -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_auto_properties = true:warning - -# C# files -[*.cs] - -#### .NET Coding Conventions #### - -# Organize usings -dotnet_separate_import_directive_groups = false -dotnet_sort_system_directives_first = false - -# this. and Me. preferences -dotnet_style_qualification_for_event = false:warning -dotnet_style_qualification_for_field = false:warning -dotnet_style_qualification_for_method = false:warning -dotnet_style_qualification_for_property = false:warning - -# Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:warning -dotnet_style_predefined_type_for_member_access = true:warning - -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent - -# Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning - -# Expression-level preferences -dotnet_style_coalesce_expression = true:warning -dotnet_style_collection_initializer = true:warning -dotnet_style_explicit_tuple_names = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_object_initializer = true:warning -dotnet_style_prefer_auto_properties = true:warning -dotnet_style_prefer_compound_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_return = false -dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning -dotnet_style_prefer_inferred_tuple_names = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_simplified_interpolation = true:warning - -# Field preferences -dotnet_style_readonly_field = true:warning - -# Parameter preferences -dotnet_code_quality_unused_parameters = non_pubic:suggestion - -#### C# Style Rules #### - -#IDE* rules are managed here. - -# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced -# during build, see: https://github.com/dotnet/roslyn/issues/44201. - -# Default severity for analyzer diagnostics with category 'Style' (escalated to build warnings) -dotnet_analyzer_diagnostic.category-Style.severity = warning - -# IDE0011: Add braces to 'if' statement. -# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn -# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. -dotnet_diagnostic.IDE0011.severity = none -# IDE0050: Convert to tuple -# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and -# those can fail on this silently in runtime while building correctly. -dotnet_diagnostic.IDE0050.severity = none -# IDE0052: Private member can be removed as the value assigned to it is never used. -# We use S4487 for that. -dotnet_diagnostic.IDE0052.severity = none -# IDE0072: Populate switch -# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. -dotnet_diagnostic.IDE0072.severity = none -# "Namespace 'Foo' does not match folder structure, expected 'Foo'" -dotnet_diagnostic.IDE0130.severity = none - -# While these are in the Style category, they need to be explicitly set for some reason. -# IDE0079 Remove unnecessary suppression -dotnet_diagnostic.IDE0079.severity = warning -dotnet_diagnostic.IDE0022.severity = warning - -# 'var' preferences -dotnet_diagnostic.IDE0007.severity = warning -dotnet_diagnostic.IDE0008.severity = none - -#### C# Coding Conventions #### - -# 'var' preferences -# These won't take effect during build due to this bug: -# https://github.com/dotnet/roslyn/issues/44250 -csharp_style_var_elsewhere = true:warning -# If this is not turned off then there will be messages for e.g. integers too, like in for loops. -csharp_style_var_for_built_in_types = false:none -csharp_style_var_when_type_is_apparent = true:warning - -# Expression-bodied members -csharp_style_expression_bodied_accessors = true:warning -csharp_style_expression_bodied_constructors = true:warning -csharp_style_expression_bodied_indexers = true:warning -csharp_style_expression_bodied_lambdas = true:warning -csharp_style_expression_bodied_local_functions = true:warning -csharp_style_expression_bodied_methods = true:warning -csharp_style_expression_bodied_operators = true:warning -csharp_style_expression_bodied_properties = true:warning - -# Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:warning -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_prefer_switch_expression = true:warning - -# Null-checking preferences -csharp_style_conditional_delegate_call = true:warning - -# Modifier preferences -csharp_prefer_static_local_function = true:warning -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent - -# Code-block preferences -csharp_prefer_simple_using_statement = true:warning -# IDE0160: Convert to block-scoped namespace -csharp_style_namespace_declarations = file_scoped:warning - -# Expression-level preferences -csharp_prefer_simple_default_expression = true:warning -csharp_style_deconstructed_variable_declaration = false:silent -csharp_style_inlined_variable_declaration = true:warning -csharp_style_pattern_local_over_anonymous_function = true:warning -csharp_style_prefer_index_operator = true:warning -csharp_style_prefer_range_operator = true:warning -csharp_style_throw_expression = true:warning -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:none - -# 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent - -#### C# Formatting Rules #### - -# New line preferences -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_open_brace = all -csharp_new_line_between_query_expression_clauses = true - -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_case_contents_when_block = true -csharp_indent_labels = no_change -csharp_indent_switch_labels = true - -# Space preferences -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -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 -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -# Wrapping preferences -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true - -#### Naming styles #### - -# 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 = * -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.types.applicable_accessibilities = * -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 = * -dotnet_naming_symbols.non_field_members.required_modifiers = - -# Naming styles - -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.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 - -# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. -dotnet_diagnostic.CA1031.severity = silent -# Disabling "do not nest type" suggestion. -dotnet_diagnostic.CA1034.severity = silent -# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. -dotnet_diagnostic.CA1810.severity = none - -# Don't apply "CA1822: Mark members as static" to the public API -dotnet_code_quality.ca1822.api_surface = private, internal -csharp_prefer_braces = true:silent - -# Various config files -[*.{config,csproj,json,props,targets}] - -indent_size = 2 - -# Markdown files -[*.md] - -trim_trailing_whitespace = false - -# JavaScript files -[*.js] - -# Placeholder, no unique rules for JS files at the moment. - - -# SCSS files -[*.scss] - -# Placeholder, no unique rules for SCSS files at the moment. - -# PowerShell files -[*.ps1] - -# Placeholder, no unique rules for PS files at the moment. From 059456222cd937b7ab72e72ee19fc0e698788c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 21:12:54 +0200 Subject: [PATCH 019/107] Update package reference version. --- .../Lombiq.Analyzers.PackageReference.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 34721548..2715c27c 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,7 +11,7 @@ AnalyzerViolations.cs - + From 86d47a37c4d37bb5d8417eae9adfc4680e09fd91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 21:16:58 +0200 Subject: [PATCH 020/107] Import common packages. --- Lombiq.Analyzers/Lombiq.Analyzers.csproj | 4 + .../.editorconfig | 310 ++++++++++++++++++ 2 files changed, 314 insertions(+) create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig diff --git a/Lombiq.Analyzers/Lombiq.Analyzers.csproj b/Lombiq.Analyzers/Lombiq.Analyzers.csproj index 81d972c8..9eb6ea9e 100644 --- a/Lombiq.Analyzers/Lombiq.Analyzers.csproj +++ b/Lombiq.Analyzers/Lombiq.Analyzers.csproj @@ -30,4 +30,8 @@ + + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig new file mode 100644 index 00000000..6996c6f3 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig @@ -0,0 +1,310 @@ +# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will +# be overwritten. + +# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference +# If you found some issue then try to fix it, which you can also do from VS Quick Actions: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles +# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. + +# All files +[*] + +# Basics +charset = utf-8 +guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000 + +# Indentation and spacing +indent_size = 4 +indent_style = space +trim_trailing_whitespace = true + + +# New line preferences +end_of_line = crlf +insert_final_newline = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_auto_properties = true:warning + +# C# files +[*.cs] + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:warning +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_property = false:warning + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = always:warning + +# Expression-level preferences +dotnet_style_coalesce_expression = true:warning +dotnet_style_collection_initializer = true:warning +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_object_initializer = true:warning +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_return = false +dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning +dotnet_style_prefer_inferred_tuple_names = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_simplified_interpolation = true:warning + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = non_pubic:suggestion + +#### C# Style Rules #### + +#IDE* rules are managed here. + +# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced +# during build, see: https://github.com/dotnet/roslyn/issues/44201. + +# Default severity for analyzer diagnostics for all categories (escalated to build warnings). See +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/categories for the list of categories. +dotnet_analyzer_diagnostic.category-Design.severity = warning +dotnet_analyzer_diagnostic.category-Documentation.severity = warning +dotnet_analyzer_diagnostic.category-Globalization.severity = warning +dotnet_analyzer_diagnostic.category-Interoperability.severity = warning +dotnet_analyzer_diagnostic.category-Maintainability.severity = warning +dotnet_analyzer_diagnostic.category-Naming.severity = warning +dotnet_analyzer_diagnostic.category-Performance.severity = warning +dotnet_analyzer_diagnostic.category-SingleFile.severity = warning +dotnet_analyzer_diagnostic.category-Reliability.severity = warning +dotnet_analyzer_diagnostic.category-Security.severity = warning +dotnet_analyzer_diagnostic.category-Style.severity = warning +dotnet_analyzer_diagnostic.category-Usage.severity = warning +dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning + +# IDE0011: Add braces to 'if' statement. +# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn +# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. +dotnet_diagnostic.IDE0011.severity = none +# IDE0050: Convert to tuple +# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and +# those can fail on this silently in runtime while building correctly. +dotnet_diagnostic.IDE0050.severity = none +# IDE0052: Private member can be removed as the value assigned to it is never used. +# We use S4487 for that. +dotnet_diagnostic.IDE0052.severity = none +# IDE0072: Populate switch +# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. +dotnet_diagnostic.IDE0072.severity = none +# "Namespace 'Foo' does not match folder structure, expected 'Foo'" +dotnet_diagnostic.IDE0130.severity = none + +# While these are in the Style category, they need to be explicitly set for some reason. +# IDE0079 Remove unnecessary suppression +dotnet_diagnostic.IDE0079.severity = warning +dotnet_diagnostic.IDE0022.severity = warning + +# 'var' preferences +dotnet_diagnostic.IDE0007.severity = warning +dotnet_diagnostic.IDE0008.severity = none + +# We don't want to decorate every public member with XML comments, only public APIs - so turn CS1591 off. +# CS1591 Missing XML Comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = none + +#### C# Coding Conventions #### + +# 'var' preferences +# These won't take effect during build due to this bug: +# https://github.com/dotnet/roslyn/issues/44250 +csharp_style_var_elsewhere = true:warning +# If this is not turned off then there will be messages for e.g. integers too, like in for loops. +csharp_style_var_for_built_in_types = false:none +csharp_style_var_when_type_is_apparent = true:warning + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:warning +csharp_style_expression_bodied_constructors = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_lambdas = true:warning +csharp_style_expression_bodied_local_functions = true:warning +csharp_style_expression_bodied_methods = true:warning +csharp_style_expression_bodied_operators = true:warning +csharp_style_expression_bodied_properties = true:warning + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_prefer_switch_expression = true:warning + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:warning + +# Modifier preferences +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_simple_using_statement = true:warning +# IDE0160: Convert to block-scoped namespace +csharp_style_namespace_declarations = file_scoped:warning + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:warning +csharp_style_deconstructed_variable_declaration = false:silent +csharp_style_inlined_variable_declaration = true:warning +csharp_style_pattern_local_over_anonymous_function = true:warning +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_range_operator = true:warning +csharp_style_throw_expression = true:warning +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:none + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +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 +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# 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 = * +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = * +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 = * +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +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.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 + +# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. +dotnet_diagnostic.CA1031.severity = silent +# Disabling "do not nest type" suggestion. +dotnet_diagnostic.CA1034.severity = silent +# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. +dotnet_diagnostic.CA1810.severity = none + +# Don't apply "CA1822: Mark members as static" to the public API +dotnet_code_quality.ca1822.api_surface = private, internal +csharp_prefer_braces = true:silent + +# Various config files +[*.{config,csproj,json,props,targets}] + +indent_size = 2 + +# Markdown files +[*.md] + +trim_trailing_whitespace = false + +# JavaScript files +[*.js] + +# Placeholder, no unique rules for JS files at the moment. + + +# SCSS files +[*.scss] + +# Placeholder, no unique rules for SCSS files at the moment. + +# PowerShell files +[*.ps1] + +# Placeholder, no unique rules for PS files at the moment. From 7168f1038a2dfacf7e83d3cc3d441fc021b4d734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 22:37:43 +0200 Subject: [PATCH 021/107] Add dependencies.xml to be used by the publish-nuget github action. --- Lombiq.Analyzers/dependencies.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Lombiq.Analyzers/dependencies.xml diff --git a/Lombiq.Analyzers/dependencies.xml b/Lombiq.Analyzers/dependencies.xml new file mode 100644 index 00000000..7d5da354 --- /dev/null +++ b/Lombiq.Analyzers/dependencies.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file From 14db2e3339e1e1ee534fedd4b9bcfff41a27fde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 22:38:30 +0200 Subject: [PATCH 022/107] Generate CommonPackages using XSLT like it's 1999! --- Lombiq.Analyzers/Build.props | 6 +++ Lombiq.Analyzers/CommonPackages.props | 58 ++++++++++++++++++--------- Lombiq.Analyzers/CommonPackages.xslt | 31 ++++++++++++++ Lombiq.Analyzers/NetFx.Build.props | 6 +++ 4 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 Lombiq.Analyzers/CommonPackages.xslt diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index bb994d3d..e81a01e7 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -28,6 +28,12 @@ false + + + + diff --git a/Lombiq.Analyzers/CommonPackages.props b/Lombiq.Analyzers/CommonPackages.props index 06300ab6..fb2d4971 100644 --- a/Lombiq.Analyzers/CommonPackages.props +++ b/Lombiq.Analyzers/CommonPackages.props @@ -1,25 +1,45 @@ + + - - - - - - - - - - - - - - - + + all + runtime; build; native; contentfiles; analyzers; + + + all + runtime; build; native; contentfiles; analyzers; + + + all + runtime; build; native; contentfiles; analyzers; + + + all + runtime; build; native; contentfiles; analyzers; + + + all + runtime; build; native; contentfiles; analyzers; + + + all + runtime; build; native; contentfiles; analyzers; + + + all + runtime; build; native; contentfiles; analyzers; + + + all + runtime; build; native; contentfiles; analyzers; + + all runtime; build; native; contentfiles; analyzers; - - + \ No newline at end of file diff --git a/Lombiq.Analyzers/CommonPackages.xslt b/Lombiq.Analyzers/CommonPackages.xslt new file mode 100644 index 00000000..29c74338 --- /dev/null +++ b/Lombiq.Analyzers/CommonPackages.xslt @@ -0,0 +1,31 @@ + + + + + + + + + This file is generated on build. Please edit dependencies.xml instead and then build Lombiq.Analyzers + project twice. It has to be twice, because a transformation can only run in Targets, but Import can't be in + Targets so it will necessarily happen before the transformation can update this file. + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; + + + + + + \ No newline at end of file diff --git a/Lombiq.Analyzers/NetFx.Build.props b/Lombiq.Analyzers/NetFx.Build.props index a405a2ef..e5bd5e20 100644 --- a/Lombiq.Analyzers/NetFx.Build.props +++ b/Lombiq.Analyzers/NetFx.Build.props @@ -24,6 +24,12 @@ false + + + + From 49fa46bfb69d4357d236379a24bbc173f506c779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 22:39:13 +0200 Subject: [PATCH 023/107] Cleanup. --- .gitignore | 1 + Lombiq.Analyzers/Lombiq.Analyzers.csproj | 4 ---- .../Lombiq.Analyzers.PackageReference.csproj | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 0d410d77..d4fe79a7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ wwwroot/ node_modules/ *.user .pnpm-debug.log +/TestSolutions/Lombiq.Analyzers.*/.editorconfig diff --git a/Lombiq.Analyzers/Lombiq.Analyzers.csproj b/Lombiq.Analyzers/Lombiq.Analyzers.csproj index 9eb6ea9e..81d972c8 100644 --- a/Lombiq.Analyzers/Lombiq.Analyzers.csproj +++ b/Lombiq.Analyzers/Lombiq.Analyzers.csproj @@ -30,8 +30,4 @@ - - - diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 2715c27c..6563d048 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,7 +11,7 @@ AnalyzerViolations.cs - + From caf6310095ef8a1c909f398bde36a0803ae00294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 22:39:58 +0200 Subject: [PATCH 024/107] Update `publish` branch selector. --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f64e9da9..e784ca02 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,6 +7,6 @@ on: jobs: call-publish-workflow: - uses: Lombiq/GitHub-Actions/.github/workflows/publish.yml@dev + uses: Lombiq/GitHub-Actions/.github/workflows/publish.yml@issue/OSOE-110 secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }} From 4411da847246319ad168ca65702fe1c30d2d355f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 30 Jun 2022 22:49:21 +0200 Subject: [PATCH 025/107] update gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d4fe79a7..392a5326 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules/ *.user .pnpm-debug.log /TestSolutions/Lombiq.Analyzers.*/.editorconfig +/.editorconfig From 2ef2be325a2f2e2cc89e64cc823282034e5fddea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 1 Jul 2022 21:40:29 +0200 Subject: [PATCH 026/107] Don't do XSLT after all. --- Lombiq.Analyzers/Build.props | 12 ++-- Lombiq.Analyzers/CommonPackages.props | 62 +++++++------------ Lombiq.Analyzers/CommonPackages.xslt | 31 ---------- Lombiq.Analyzers/NetFx.Build.props | 6 -- Lombiq.Analyzers/dependencies.xml | 15 ----- .../Lombiq.Analyzers.PackageReference.csproj | 9 +-- 6 files changed, 30 insertions(+), 105 deletions(-) delete mode 100644 Lombiq.Analyzers/CommonPackages.xslt delete mode 100644 Lombiq.Analyzers/dependencies.xml diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index e81a01e7..e78f03a1 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -28,12 +28,6 @@ false - - - - @@ -76,4 +70,10 @@ + + + True + true + True + diff --git a/Lombiq.Analyzers/CommonPackages.props b/Lombiq.Analyzers/CommonPackages.props index fb2d4971..8609dbaa 100644 --- a/Lombiq.Analyzers/CommonPackages.props +++ b/Lombiq.Analyzers/CommonPackages.props @@ -1,45 +1,29 @@ - - + + - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - - all - runtime; build; native; contentfiles; analyzers; - - + + + + + + + + + + + + + all runtime; build; native; contentfiles; analyzers; - \ No newline at end of file + + + + + + diff --git a/Lombiq.Analyzers/CommonPackages.xslt b/Lombiq.Analyzers/CommonPackages.xslt deleted file mode 100644 index 29c74338..00000000 --- a/Lombiq.Analyzers/CommonPackages.xslt +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - This file is generated on build. Please edit dependencies.xml instead and then build Lombiq.Analyzers - project twice. It has to be twice, because a transformation can only run in Targets, but Import can't be in - Targets so it will necessarily happen before the transformation can update this file. - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; - - - - - - \ No newline at end of file diff --git a/Lombiq.Analyzers/NetFx.Build.props b/Lombiq.Analyzers/NetFx.Build.props index e5bd5e20..a405a2ef 100644 --- a/Lombiq.Analyzers/NetFx.Build.props +++ b/Lombiq.Analyzers/NetFx.Build.props @@ -24,12 +24,6 @@ false - - - - diff --git a/Lombiq.Analyzers/dependencies.xml b/Lombiq.Analyzers/dependencies.xml deleted file mode 100644 index 7d5da354..00000000 --- a/Lombiq.Analyzers/dependencies.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 6563d048..600aa9e6 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,14 +11,7 @@ AnalyzerViolations.cs - - - - - - all - runtime; build; native; contentfiles; analyzers; - + From 0c0fa7bb00fb29ddb3af539db853291b443725ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 14:28:55 +0200 Subject: [PATCH 027/107] Create a nuspec file from tempate. --- .gitignore | 1 + ConvertTo-Nuspec.ps1 | 19 ++++++++++++++++ Lombiq.Analyzers/Lombiq.Analyzers.csproj | 19 +++++----------- .../Lombiq.Analyzers.nuspec.template | 22 +++++++++++++++++++ 4 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 ConvertTo-Nuspec.ps1 create mode 100644 Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template diff --git a/.gitignore b/.gitignore index 392a5326..49020d3c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ node_modules/ .pnpm-debug.log /TestSolutions/Lombiq.Analyzers.*/.editorconfig /.editorconfig +/Lombiq.Analyzers/Lombiq.Analyzers.nuspec diff --git a/ConvertTo-Nuspec.ps1 b/ConvertTo-Nuspec.ps1 new file mode 100644 index 00000000..9e367ed9 --- /dev/null +++ b/ConvertTo-Nuspec.ps1 @@ -0,0 +1,19 @@ +param($Version) + +$templateFileName = [System.IO.Path]::Combine($PWD, 'Lombiq.Analyzers', 'Lombiq.Analyzers.nuspec.template') +$nuspec = [xml](Get-Content $templateFileName) +$group = $nuspec.package.metadata.dependencies.group + +foreach($dependency in ([xml](Get-Content "CommonPackages.props")).Project.ItemGroup.AnalyzerPackage) +{ + $id = $dependency.Include + if (-not $id) { continue } + + $node = $nuspec.CreateElement('dependency') + $node.SetAttribute('id', $id) + $node.SetAttribute('version', $dependency.Version) + + $group.AppendChild($node) +} + +$nuspec.Save([System.IO.Path]::Combine($PWD, 'Lombiq.Analyzers.nuspec')) diff --git a/Lombiq.Analyzers/Lombiq.Analyzers.csproj b/Lombiq.Analyzers/Lombiq.Analyzers.csproj index 81d972c8..4bd3bc25 100644 --- a/Lombiq.Analyzers/Lombiq.Analyzers.csproj +++ b/Lombiq.Analyzers/Lombiq.Analyzers.csproj @@ -5,19 +5,12 @@ $(DefaultItemExcludes);.git*; - - Lombiq .NET Analyzers - Lombiq Technologies - Copyright © 2020, Lombiq Technologies Ltd. - Lombiq .NET Analyzers: .NET code analyzers and code convention settings for Lombiq (https://lombiq.com) projects, predominantly for Orchard Core (https://www.orchardcore.net/) apps but also any .NET apps. See the project website for detailed documentation. - NuGetIcon.png - OrchardCore;Lombiq;AspNetCore;CodeAnalysis;DotNetAnalyzers;Analyzer;Analyzers;Diagnostic;Roslyn;Refactoring;AsyncFixer;Meziantou.Analyzer;StyleCop - https://github.com/Lombiq/.NET-Analyzers - https://github.com/Lombiq/.NET-Analyzers - License.md - true - - + + diff --git a/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template b/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template new file mode 100644 index 00000000..7665f170 --- /dev/null +++ b/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template @@ -0,0 +1,22 @@ + + + + Lombiq.Analyzers + $version$ + Lombiq .NET Analyzers + Lombiq Technologies + License.md + https://github.com/Lombiq/.NET-Analyzers/blob/dev/License.md + NuGetIcon.png + https://github.com/Lombiq/.NET-Analyzers + Lombiq .NET Analyzers: .NET code analyzers and code convention settings for Lombiq (https://lombiq.com) projects, predominantly for Orchard Core (https://www.orchardcore.net/) apps but also any .NET apps. See the project website for detailed documentation. + Copyright © 2020, Lombiq Technologies Ltd. + OrchardCore Lombiq AspNetCore CodeAnalysis DotNetAnalyzers Analyzer Analyzers Diagnostic Roslyn Refactoring AsyncFixer Meziantou.Analyzer StyleCop + + + + + + + + From 2a69380da03af1329bc038f7969d1b576eb36f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 15:55:36 +0200 Subject: [PATCH 028/107] Fix `ConvertTo-Nuspec` and the template file. --- ConvertTo-Nuspec.ps1 | 13 +++++++++---- Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ConvertTo-Nuspec.ps1 b/ConvertTo-Nuspec.ps1 index 9e367ed9..c6ddca83 100644 --- a/ConvertTo-Nuspec.ps1 +++ b/ConvertTo-Nuspec.ps1 @@ -1,10 +1,14 @@ param($Version) -$templateFileName = [System.IO.Path]::Combine($PWD, 'Lombiq.Analyzers', 'Lombiq.Analyzers.nuspec.template') -$nuspec = [xml](Get-Content $templateFileName) +$projectPath = Join-Path $PWD Lombiq.Analyzers +function Open-Xml([string]$File) { [xml](Get-Content (Join-Path $projectPath $File)) } + +$nuspec = Open-Xml Lombiq.Analyzers.nuspec.template $group = $nuspec.package.metadata.dependencies.group -foreach($dependency in ([xml](Get-Content "CommonPackages.props")).Project.ItemGroup.AnalyzerPackage) +$nuspec.package.metadata.GetElementsByTagName('version')[0].InnerXml = $Version + +foreach($dependency in (Open-Xml CommonPackages.props).Project.ItemGroup.AnalyzerPackage) { $id = $dependency.Include if (-not $id) { continue } @@ -16,4 +20,5 @@ foreach($dependency in ([xml](Get-Content "CommonPackages.props")).Project.ItemG $group.AppendChild($node) } -$nuspec.Save([System.IO.Path]::Combine($PWD, 'Lombiq.Analyzers.nuspec')) +$outputPath = Join-Path $projectPath Lombiq.Analyzers.nuspec +$nuspec.Save($outputPath) diff --git a/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template b/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template index 7665f170..b1883391 100644 --- a/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template +++ b/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template @@ -6,7 +6,7 @@ Lombiq .NET Analyzers Lombiq Technologies License.md - https://github.com/Lombiq/.NET-Analyzers/blob/dev/License.md + https://aka.ms/deprecateLicenseUrl NuGetIcon.png https://github.com/Lombiq/.NET-Analyzers Lombiq .NET Analyzers: .NET code analyzers and code convention settings for Lombiq (https://lombiq.com) projects, predominantly for Orchard Core (https://www.orchardcore.net/) apps but also any .NET apps. See the project website for detailed documentation. From a51d460373d19234223d054186dbd4b6edf82c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 21:26:22 +0200 Subject: [PATCH 029/107] Fix NU5128 error. --- ConvertTo-Nuspec.ps1 | 4 ++-- Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ConvertTo-Nuspec.ps1 b/ConvertTo-Nuspec.ps1 index c6ddca83..31b9cc0f 100644 --- a/ConvertTo-Nuspec.ps1 +++ b/ConvertTo-Nuspec.ps1 @@ -4,7 +4,7 @@ $projectPath = Join-Path $PWD Lombiq.Analyzers function Open-Xml([string]$File) { [xml](Get-Content (Join-Path $projectPath $File)) } $nuspec = Open-Xml Lombiq.Analyzers.nuspec.template -$group = $nuspec.package.metadata.dependencies.group +$dependencies = $nuspec.package.metadata.dependencies $nuspec.package.metadata.GetElementsByTagName('version')[0].InnerXml = $Version @@ -17,7 +17,7 @@ foreach($dependency in (Open-Xml CommonPackages.props).Project.ItemGroup.Analyze $node.SetAttribute('id', $id) $node.SetAttribute('version', $dependency.Version) - $group.AppendChild($node) + $dependencies.AppendChild($node) } $outputPath = Join-Path $projectPath Lombiq.Analyzers.nuspec diff --git a/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template b/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template index b1883391..6981cdd9 100644 --- a/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template +++ b/Lombiq.Analyzers/Lombiq.Analyzers.nuspec.template @@ -14,9 +14,7 @@ OrchardCore Lombiq AspNetCore CodeAnalysis DotNetAnalyzers Analyzer Analyzers Diagnostic Roslyn Refactoring AsyncFixer Meziantou.Analyzer StyleCop - - - + From 9196a1f059921c18100568730c73e3d3cb40e2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 21:48:31 +0200 Subject: [PATCH 030/107] Attempting to prevent NU5100 warning. --- Invoke-BeforePack.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Invoke-BeforePack.ps1 diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 new file mode 100644 index 00000000..b0b01aa9 --- /dev/null +++ b/Invoke-BeforePack.ps1 @@ -0,0 +1,11 @@ +# This script prevents NU5100 warning caused by the presence of these files +# - bin/Release/netstandard2.0/Lombiq.Analyzers.dll +# - obj/Release/netstandard2.0/Lombiq.Analyzers.dll +# The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need +# an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). + +Get-ChildItem Lombiq.Analyzers/obj -Recurse -Include Lombiq.Analyzers.dll | Remove-Item + +$release = Get-ChildItem Lombiq.Analyzers/bin/Release -Recurse -Include Lombiq.Analyzers.dll +New-Item -Type Directory -Force lib +Move-Item $release lib From bab5c129558c3fecc85cd19bc315ddc97f388f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 22:51:59 +0200 Subject: [PATCH 031/107] Add indirect package reference test. --- .gitignore | 1 + TestSolutions/AnalyzerViolations.cs | 4 +++- .../IndirectPackageReference.csproj | 22 +++++++++++++++++++ .../Lombiq.Analyzers.PackageReference.csproj | 13 +++++++---- .../Lombiq.Analyzers.PackageReference.sln | 7 ++++++ 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj diff --git a/.gitignore b/.gitignore index 49020d3c..5a1f5d06 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules/ /TestSolutions/Lombiq.Analyzers.*/.editorconfig /.editorconfig /Lombiq.Analyzers/Lombiq.Analyzers.nuspec +/TestSolutions/*/**/AnalyzerViolations.cs diff --git a/TestSolutions/AnalyzerViolations.cs b/TestSolutions/AnalyzerViolations.cs index d58e74f3..a437da7b 100644 --- a/TestSolutions/AnalyzerViolations.cs +++ b/TestSolutions/AnalyzerViolations.cs @@ -1,6 +1,8 @@ namespace Lombiq.Analyzers.ProjectReference; -// This file has intentional analyzer violations. +// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the +// subdirectories will be copied over during build. Copying is necessary so duplicate warnings from different projects +// can be shown. public class Class1 { private int Number; diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj new file mode 100644 index 00000000..d248049e --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 600aa9e6..02e3b9f2 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -7,11 +7,16 @@ - - AnalyzerViolations.cs - + + - + + + + + + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln index 5b85c186..7a4c2b2b 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.sln @@ -8,8 +8,11 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0533C5D5-F4D0-4231-A810-80E7342F9C33}" ProjectSection(SolutionItems) = preProject ..\Directory.Build.props = ..\Directory.Build.props + ..\AnalyzerViolations.cs = ..\AnalyzerViolations.cs EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IndirectPackageReference", "IndirectPackageReference\IndirectPackageReference.csproj", "{B6108F6C-7B57-4475-932A-1124CD7CBF11}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,5 +26,9 @@ Global {431AE877-59B7-438C-91AE-825AC847B447}.Debug|Any CPU.Build.0 = Debug|Any CPU {431AE877-59B7-438C-91AE-825AC847B447}.Release|Any CPU.ActiveCfg = Release|Any CPU {431AE877-59B7-438C-91AE-825AC847B447}.Release|Any CPU.Build.0 = Release|Any CPU + {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6108F6C-7B57-4475-932A-1124CD7CBF11}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal From a72a47f9125cfb4e98e9cfa2828ea253204ba0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 22:52:12 +0200 Subject: [PATCH 032/107] Refactor unit tests. --- .../AnalyzerViolationTests.cs | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index 9fa0ce6b..1e038f74 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -37,23 +37,29 @@ public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) .ShouldBe(exceptionCodes); } - // Runs dotnet msbuild {solutionPath}.sln -t:Clean,Build -v:quiet -p:RunAnalyzersDuringBuild=true -p:TreatWarningsAsErrors=true -warnAsError - // See https://github.com/Lombiq/.NET-Analyzers/blob/dev/Docs/UsingAnalyzersDuringCommandLineBuilds.md#net-code-style-analysis - private static async Task ExecuteStaticCodeAnalysisAsync(string solutionPath) + // Runs `dotnet build $SolutionFileName$ --no-incremental --nologo --warnaserror --consoleLoggerParameters:NoSummary + // --verbosity:quiet -p:TreatWarningsAsErrors=true -p:RunAnalyzersDuringBuild=true` command. See + // https://github.com/Lombiq/.NET-Analyzers/blob/dev/Docs/UsingAnalyzersDuringCommandLineBuilds.md#net-code-style-analysis + // for more information. + private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath, params string[] additionalArguments) { var relativeSolutionPath = Path.Combine("..", "..", "..", "..", "TestSolutions", solutionPath); - await CliProgram.DotNet.ExecuteAsync(CancellationToken.None, "restore", relativeSolutionPath); - - await CliProgram.DotNet.ExecuteAsync( - CancellationToken.None, - "msbuild", + var arguments = new List + { + "build", relativeSolutionPath, - "-t:Clean,Build", - "-v:quiet", - "-p:RunAnalyzersDuringBuild=true", + "--no-incremental", + "--nologo", + "--warnaserror", + "--consoleLoggerParameters:NoSummary", + "--verbosity:quiet", "-p:TreatWarningsAsErrors=true", - "-warnAsError"); + "-p:RunAnalyzersDuringBuild=true", + }; + arguments.AddRange(additionalArguments); + + return CliProgram.DotNet.ExecuteAsync(CancellationToken.None, arguments.ToArray()); } public static IEnumerable Data() From 626d32a76f7a10e196ecb1cb5f9b49544985261b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 23:03:40 +0200 Subject: [PATCH 033/107] Add new test. --- .../AnalyzerViolationTests.cs | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index 1e038f74..9fd82f59 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -28,13 +28,29 @@ public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) var exceptionCodes = new[] { "IDE0021", "IDE0044", "S2933", "S4487" }; - exception - .Message - .Split(new[] { '\n', '\r' }, StringSplitOptions.None) - .Where(line => line.Contains(" error ")) - .Select(line => line.RegexReplace(@"^.* error ([^:]+):.*$", "$1")) - .OrderBy(line => line) - .ShouldBe(exceptionCodes); + SelectErrorCodes(exception).ShouldBe(exceptionCodes); + } + + [Fact] + public async Task AnalzerShouldNotSpreadToDependentProjects() + { + var solutionRelativePath = "Lombiq.Analyzers.PackageReference"; + var exception = (InvalidOperationException)await Should.ThrowAsync( + () => ExecuteStaticCodeAnalysisAsync(solutionRelativePath), + typeof(InvalidOperationException)); + + var violationCount = SelectErrorCodes(exception).Count(); + violationCount.ShouldBeGreaterThan(0); // Just to be sure. + + exception = (InvalidOperationException)await Should.ThrowAsync( + () => ExecuteStaticCodeAnalysisAsync(solutionRelativePath, "-p:ImportPackageAgain=true"), + typeof(InvalidOperationException)); + + // The solution contains two projects, both copy the same file. One project also has a ProjectReference to the + // other. The first run above will only emit warnings for the main project that references the NuGet package. + // The second run defines a symbol which enables a PackageReference in the other project too, so there will be + // twice as many warnings, one set for each copy of the same source file. + SelectErrorCodes(exception).Count().ShouldBe(2 * violationCount); } // Runs `dotnet build $SolutionFileName$ --no-incremental --nologo --warnaserror --consoleLoggerParameters:NoSummary @@ -62,6 +78,14 @@ private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath, params s return CliProgram.DotNet.ExecuteAsync(CancellationToken.None, arguments.ToArray()); } + private static IEnumerable SelectErrorCodes(Exception exception) => + exception + .Message + .Split(new[] { '\n', '\r' }, StringSplitOptions.None) + .Where(line => line.Contains(" error ")) + .Select(line => line.RegexReplace(@"^.* error ([^:]+):.*$", "$1")) + .OrderBy(line => line); + public static IEnumerable Data() { static object[] FromProjectName(string projectName) => From a30fd1b8b4bd19fa8e8df7125ab82e63a3b742c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sat, 2 Jul 2022 23:17:08 +0200 Subject: [PATCH 034/107] Clean up irrelevant content. --- .../UsingAnalyzersDuringCommandLineBuilds.md | 6 - .../.editorconfig | 310 ------------------ 2 files changed, 316 deletions(-) delete mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig diff --git a/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md b/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md index 48808b48..9d3503ac 100644 --- a/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md +++ b/Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md @@ -41,12 +41,6 @@ Or if you only want to see the errors and not the full build output (including e dotnet build MySolution.sln --no-incremental -warnaserror /p:TreatWarningsAsErrors=true /p:RunAnalyzersDuringBuild=true -nologo -consoleLoggerParameters:NoSummary -verbosity:quiet ``` -If you are using the NuGet package you have to call it with MsBuild instead: - -```ps -dotnet msbuild {solutionPath}.sln -t:Clean,Build -v:quiet -p:RunAnalyzersDuringBuild=true -p:TreatWarningsAsErrors=true -warnAsError -``` - Note that code style analysis is experimental in the .NET 5 SDK and [may change in later versions](https://github.com/dotnet/roslyn/issues/49044). diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig deleted file mode 100644 index 6996c6f3..00000000 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/.editorconfig +++ /dev/null @@ -1,310 +0,0 @@ -# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will -# be overwritten. - -# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference -# If you found some issue then try to fix it, which you can also do from VS Quick Actions: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles -# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. - -# All files -[*] - -# Basics -charset = utf-8 -guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000 - -# Indentation and spacing -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true - - -# New line preferences -end_of_line = crlf -insert_final_newline = true -dotnet_style_operator_placement_when_wrapping = beginning_of_line -tab_width = 4 -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_auto_properties = true:warning - -# C# files -[*.cs] - -#### .NET Coding Conventions #### - -# Organize usings -dotnet_separate_import_directive_groups = false -dotnet_sort_system_directives_first = false - -# this. and Me. preferences -dotnet_style_qualification_for_event = false:warning -dotnet_style_qualification_for_field = false:warning -dotnet_style_qualification_for_method = false:warning -dotnet_style_qualification_for_property = false:warning - -# Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:warning -dotnet_style_predefined_type_for_member_access = true:warning - -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent - -# Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning - -# Expression-level preferences -dotnet_style_coalesce_expression = true:warning -dotnet_style_collection_initializer = true:warning -dotnet_style_explicit_tuple_names = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_object_initializer = true:warning -dotnet_style_prefer_auto_properties = true:warning -dotnet_style_prefer_compound_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_return = false -dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning -dotnet_style_prefer_inferred_tuple_names = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_simplified_interpolation = true:warning - -# Field preferences -dotnet_style_readonly_field = true:warning - -# Parameter preferences -dotnet_code_quality_unused_parameters = non_pubic:suggestion - -#### C# Style Rules #### - -#IDE* rules are managed here. - -# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced -# during build, see: https://github.com/dotnet/roslyn/issues/44201. - -# Default severity for analyzer diagnostics for all categories (escalated to build warnings). See -# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/categories for the list of categories. -dotnet_analyzer_diagnostic.category-Design.severity = warning -dotnet_analyzer_diagnostic.category-Documentation.severity = warning -dotnet_analyzer_diagnostic.category-Globalization.severity = warning -dotnet_analyzer_diagnostic.category-Interoperability.severity = warning -dotnet_analyzer_diagnostic.category-Maintainability.severity = warning -dotnet_analyzer_diagnostic.category-Naming.severity = warning -dotnet_analyzer_diagnostic.category-Performance.severity = warning -dotnet_analyzer_diagnostic.category-SingleFile.severity = warning -dotnet_analyzer_diagnostic.category-Reliability.severity = warning -dotnet_analyzer_diagnostic.category-Security.severity = warning -dotnet_analyzer_diagnostic.category-Style.severity = warning -dotnet_analyzer_diagnostic.category-Usage.severity = warning -dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning - -# IDE0011: Add braces to 'if' statement. -# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn -# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. -dotnet_diagnostic.IDE0011.severity = none -# IDE0050: Convert to tuple -# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and -# those can fail on this silently in runtime while building correctly. -dotnet_diagnostic.IDE0050.severity = none -# IDE0052: Private member can be removed as the value assigned to it is never used. -# We use S4487 for that. -dotnet_diagnostic.IDE0052.severity = none -# IDE0072: Populate switch -# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. -dotnet_diagnostic.IDE0072.severity = none -# "Namespace 'Foo' does not match folder structure, expected 'Foo'" -dotnet_diagnostic.IDE0130.severity = none - -# While these are in the Style category, they need to be explicitly set for some reason. -# IDE0079 Remove unnecessary suppression -dotnet_diagnostic.IDE0079.severity = warning -dotnet_diagnostic.IDE0022.severity = warning - -# 'var' preferences -dotnet_diagnostic.IDE0007.severity = warning -dotnet_diagnostic.IDE0008.severity = none - -# We don't want to decorate every public member with XML comments, only public APIs - so turn CS1591 off. -# CS1591 Missing XML Comment for publicly visible type or member -dotnet_diagnostic.CS1591.severity = none - -#### C# Coding Conventions #### - -# 'var' preferences -# These won't take effect during build due to this bug: -# https://github.com/dotnet/roslyn/issues/44250 -csharp_style_var_elsewhere = true:warning -# If this is not turned off then there will be messages for e.g. integers too, like in for loops. -csharp_style_var_for_built_in_types = false:none -csharp_style_var_when_type_is_apparent = true:warning - -# Expression-bodied members -csharp_style_expression_bodied_accessors = true:warning -csharp_style_expression_bodied_constructors = true:warning -csharp_style_expression_bodied_indexers = true:warning -csharp_style_expression_bodied_lambdas = true:warning -csharp_style_expression_bodied_local_functions = true:warning -csharp_style_expression_bodied_methods = true:warning -csharp_style_expression_bodied_operators = true:warning -csharp_style_expression_bodied_properties = true:warning - -# Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:warning -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_prefer_switch_expression = true:warning - -# Null-checking preferences -csharp_style_conditional_delegate_call = true:warning - -# Modifier preferences -csharp_prefer_static_local_function = true:warning -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent - -# Code-block preferences -csharp_prefer_simple_using_statement = true:warning -# IDE0160: Convert to block-scoped namespace -csharp_style_namespace_declarations = file_scoped:warning - -# Expression-level preferences -csharp_prefer_simple_default_expression = true:warning -csharp_style_deconstructed_variable_declaration = false:silent -csharp_style_inlined_variable_declaration = true:warning -csharp_style_pattern_local_over_anonymous_function = true:warning -csharp_style_prefer_index_operator = true:warning -csharp_style_prefer_range_operator = true:warning -csharp_style_throw_expression = true:warning -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:none - -# 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent - -#### C# Formatting Rules #### - -# New line preferences -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_open_brace = all -csharp_new_line_between_query_expression_clauses = true - -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_case_contents_when_block = true -csharp_indent_labels = no_change -csharp_indent_switch_labels = true - -# Space preferences -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -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 -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -# Wrapping preferences -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true - -#### Naming styles #### - -# 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 = * -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.types.applicable_accessibilities = * -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 = * -dotnet_naming_symbols.non_field_members.required_modifiers = - -# Naming styles - -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.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 - -# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. -dotnet_diagnostic.CA1031.severity = silent -# Disabling "do not nest type" suggestion. -dotnet_diagnostic.CA1034.severity = silent -# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. -dotnet_diagnostic.CA1810.severity = none - -# Don't apply "CA1822: Mark members as static" to the public API -dotnet_code_quality.ca1822.api_surface = private, internal -csharp_prefer_braces = true:silent - -# Various config files -[*.{config,csproj,json,props,targets}] - -indent_size = 2 - -# Markdown files -[*.md] - -trim_trailing_whitespace = false - -# JavaScript files -[*.js] - -# Placeholder, no unique rules for JS files at the moment. - - -# SCSS files -[*.scss] - -# Placeholder, no unique rules for SCSS files at the moment. - -# PowerShell files -[*.ps1] - -# Placeholder, no unique rules for PS files at the moment. From ede24dd7473e6f034eb0028d15fa629742f95e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sun, 3 Jul 2022 05:50:08 +0200 Subject: [PATCH 035/107] Write out exception on test fail. --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index 9fd82f59..c25cd765 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -28,7 +28,7 @@ public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) var exceptionCodes = new[] { "IDE0021", "IDE0044", "S2933", "S4487" }; - SelectErrorCodes(exception).ShouldBe(exceptionCodes); + SelectErrorCodes(exception).ShouldBe(exceptionCodes, $"Exception message: {exception}"); } [Fact] @@ -50,7 +50,7 @@ public async Task AnalzerShouldNotSpreadToDependentProjects() // other. The first run above will only emit warnings for the main project that references the NuGet package. // The second run defines a symbol which enables a PackageReference in the other project too, so there will be // twice as many warnings, one set for each copy of the same source file. - SelectErrorCodes(exception).Count().ShouldBe(2 * violationCount); + SelectErrorCodes(exception).Count().ShouldBe(2 * violationCount, $"Exception message: {exception}"); } // Runs `dotnet build $SolutionFileName$ --no-incremental --nologo --warnaserror --consoleLoggerParameters:NoSummary From 01f30f37f184bf8648eb87b3b6b6236ebb098515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sun, 3 Jul 2022 05:52:55 +0200 Subject: [PATCH 036/107] Fix typo --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index c25cd765..5c077c79 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -32,7 +32,7 @@ public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) } [Fact] - public async Task AnalzerShouldNotSpreadToDependentProjects() + public async Task AnalyzerShouldNotSpreadToDependentProjects() { var solutionRelativePath = "Lombiq.Analyzers.PackageReference"; var exception = (InvalidOperationException)await Should.ThrowAsync( From 159b15cc2f0bfff5fa0e6b524af6f2e52daa1d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 4 Jul 2022 00:49:42 +0200 Subject: [PATCH 037/107] Handle PDB file too. --- Invoke-BeforePack.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index b0b01aa9..0fd7a205 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -7,5 +7,15 @@ Get-ChildItem Lombiq.Analyzers/obj -Recurse -Include Lombiq.Analyzers.dll | Remove-Item $release = Get-ChildItem Lombiq.Analyzers/bin/Release -Recurse -Include Lombiq.Analyzers.dll +$releasePdb = $release.FullName -replace 'dll$','pdb' New-Item -Type Directory -Force lib Move-Item $release lib + +if (Test-Path $releasePdb) +{ + Move-Item $releasePdb lib +} +else +{ + Write-Warning "There is no $releasePdb file!" +} From 0f7e26e4fe65f54aa27641050d89e24ae2d95a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 4 Jul 2022 01:15:25 +0200 Subject: [PATCH 038/107] Copy dlls instead of move. --- Invoke-BeforePack.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 0fd7a205..65bf768e 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -4,16 +4,16 @@ # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). -Get-ChildItem Lombiq.Analyzers/obj -Recurse -Include Lombiq.Analyzers.dll | Remove-Item +Remove-Item Lombiq.Analyzers/obj -Recurse $release = Get-ChildItem Lombiq.Analyzers/bin/Release -Recurse -Include Lombiq.Analyzers.dll $releasePdb = $release.FullName -replace 'dll$','pdb' New-Item -Type Directory -Force lib -Move-Item $release lib +Copy-Item $release lib if (Test-Path $releasePdb) { - Move-Item $releasePdb lib + Copy-Item $releasePdb lib } else { From edfcecb81f2c17759cec4854a1c3c234cab7b77e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 4 Jul 2022 01:29:56 +0200 Subject: [PATCH 039/107] Don't delete obj directory. --- Invoke-BeforePack.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 65bf768e..eed8890e 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -1,11 +1,9 @@ -# This script prevents NU5100 warning caused by the presence of these files +# This script tries to work around NuGet's validation and the NU5100 warning caused by the presence of these files # - bin/Release/netstandard2.0/Lombiq.Analyzers.dll # - obj/Release/netstandard2.0/Lombiq.Analyzers.dll # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). -Remove-Item Lombiq.Analyzers/obj -Recurse - $release = Get-ChildItem Lombiq.Analyzers/bin/Release -Recurse -Include Lombiq.Analyzers.dll $releasePdb = $release.FullName -replace 'dll$','pdb' New-Item -Type Directory -Force lib From 3581a4fde2825ee5d5efcd36b4c518582fc7eecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 4 Jul 2022 01:47:28 +0200 Subject: [PATCH 040/107] Use the latest Lombiq.Analyzers version. --- .../Lombiq.Analyzers.PackageReference.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 02e3b9f2..c0186b59 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -7,7 +7,7 @@ - + From 7244f0bceb072d3b22439bdfa2b5801192eda3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 11 Jul 2022 21:48:41 +0200 Subject: [PATCH 041/107] Restore before build. --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index 5c077c79..b205a237 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -16,6 +16,7 @@ public class AnalyzerViolationTests [MemberData(nameof(Data))] public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) { + await CliProgram.DotNet.ExecuteAsync(CancellationToken.None, "restore", solutionRelativePath); var exception = (InvalidOperationException)await Should.ThrowAsync( () => ExecuteStaticCodeAnalysisAsync(solutionRelativePath), typeof(InvalidOperationException)); @@ -75,7 +76,7 @@ private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath, params s }; arguments.AddRange(additionalArguments); - return CliProgram.DotNet.ExecuteAsync(CancellationToken.None, arguments.ToArray()); + return CliProgram.DotNet.ExecuteAsync(arguments, additionalExceptionText: null, CancellationToken.None); } private static IEnumerable SelectErrorCodes(Exception exception) => From d9f19e78969227f4cd80dae4efb6fb2fd5559eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 11 Jul 2022 22:20:47 +0200 Subject: [PATCH 042/107] Pass the sln files instead of the csproj for static code analysis tests. --- Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index b205a237..1d65d4f7 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -16,7 +16,6 @@ public class AnalyzerViolationTests [MemberData(nameof(Data))] public async Task AnalyzerViolationShouldBeReported(string solutionRelativePath) { - await CliProgram.DotNet.ExecuteAsync(CancellationToken.None, "restore", solutionRelativePath); var exception = (InvalidOperationException)await Should.ThrowAsync( () => ExecuteStaticCodeAnalysisAsync(solutionRelativePath), typeof(InvalidOperationException)); @@ -90,7 +89,7 @@ private static IEnumerable SelectErrorCodes(Exception exception) => public static IEnumerable Data() { static object[] FromProjectName(string projectName) => - new object[] { Path.Combine(projectName, projectName + ".csproj") }; + new object[] { Path.Combine(projectName, projectName + ".sln") }; yield return FromProjectName("Lombiq.Analyzers.PackageReference"); yield return FromProjectName("Lombiq.Analyzers.ProjectReference"); From e77696173b9c5326f75ef337c3865d729744fcdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 12 Jul 2022 00:56:54 +0200 Subject: [PATCH 043/107] Update to use the shared ExecuteStaticCodeAnalysisAsync --- .../AnalyzerViolationTests.cs | 24 ++----------------- .../IndirectPackageReference.csproj | 4 ++-- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs index 1d65d4f7..23b4af32 100644 --- a/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs +++ b/Lombiq.Analyzers.Tests/AnalyzerViolationTests.cs @@ -1,10 +1,9 @@ -using Lombiq.HelpfulLibraries.Cli; +using Lombiq.HelpfulLibraries.Cli.Helpers; using Shouldly; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Xunit; @@ -53,29 +52,10 @@ public async Task AnalyzerShouldNotSpreadToDependentProjects() SelectErrorCodes(exception).Count().ShouldBe(2 * violationCount, $"Exception message: {exception}"); } - // Runs `dotnet build $SolutionFileName$ --no-incremental --nologo --warnaserror --consoleLoggerParameters:NoSummary - // --verbosity:quiet -p:TreatWarningsAsErrors=true -p:RunAnalyzersDuringBuild=true` command. See - // https://github.com/Lombiq/.NET-Analyzers/blob/dev/Docs/UsingAnalyzersDuringCommandLineBuilds.md#net-code-style-analysis - // for more information. private static Task ExecuteStaticCodeAnalysisAsync(string solutionPath, params string[] additionalArguments) { var relativeSolutionPath = Path.Combine("..", "..", "..", "..", "TestSolutions", solutionPath); - - var arguments = new List - { - "build", - relativeSolutionPath, - "--no-incremental", - "--nologo", - "--warnaserror", - "--consoleLoggerParameters:NoSummary", - "--verbosity:quiet", - "-p:TreatWarningsAsErrors=true", - "-p:RunAnalyzersDuringBuild=true", - }; - arguments.AddRange(additionalArguments); - - return CliProgram.DotNet.ExecuteAsync(arguments, additionalExceptionText: null, CancellationToken.None); + return DotnetBuildHelper.ExecuteStaticCodeAnalysisAsync(relativeSolutionPath, additionalArguments); } private static IEnumerable SelectErrorCodes(Exception exception) => diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index d248049e..03082ebd 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -6,7 +6,7 @@ enable - @@ -16,7 +16,7 @@ - + From 1a88ae47518da55a2792acda9ad4979c1667f35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 12 Jul 2022 02:02:56 +0200 Subject: [PATCH 044/107] Fix IndirectPackageReference.csproj --- .../IndirectPackageReference/IndirectPackageReference.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index 03082ebd..20198fce 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -16,7 +16,7 @@ - + From 8caf2786cf78ec0ac490073f6d09b38da006b461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 12 Jul 2022 02:46:19 +0200 Subject: [PATCH 045/107] Clean up packagereference csprojs. --- .../IndirectPackageReference/IndirectPackageReference.csproj | 2 -- .../Lombiq.Analyzers.PackageReference.csproj | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index 20198fce..e19aac12 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -2,8 +2,6 @@ net6.0 - enable - enable true + + + true diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index e19aac12..603c89e6 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -10,10 +10,10 @@ --> - + - + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 4e907e0f..661c3f11 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -2,7 +2,6 @@ net6.0 - true @@ -14,7 +13,7 @@ - + From 41de031a8c8fe7fb5fb7107788996f52ce283056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 21:53:18 +0200 Subject: [PATCH 065/107] We can reference here instead of copy. --- .../Lombiq.Analyzers.PackageReference.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 661c3f11..5b754e76 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,10 +11,10 @@ - - - - + + AnalyzerViolations.cs + + From fca156da8a34e7ea987352deaac577f577b3a818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 22:13:54 +0200 Subject: [PATCH 066/107] Use copy instead of link everywhere in TestSolutions. Explain in comments. --- .gitignore | 1 - TestSolutions/AnalyzerViolations.cs | 7 +++++-- .../AnalyzerViolations.cs | 16 ++++++++++++++++ .../AnalyzerViolations.cs | 16 ++++++++++++++++ .../Lombiq.Analyzers.PackageReference.csproj | 8 ++++---- .../AnalyzerViolations.cs | 16 ++++++++++++++++ .../Lombiq.Analyzers.ProjectReference.csproj | 10 ++++------ 7 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs create mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs diff --git a/.gitignore b/.gitignore index 5a1f5d06..49020d3c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,3 @@ node_modules/ /TestSolutions/Lombiq.Analyzers.*/.editorconfig /.editorconfig /Lombiq.Analyzers/Lombiq.Analyzers.nuspec -/TestSolutions/*/**/AnalyzerViolations.cs diff --git a/TestSolutions/AnalyzerViolations.cs b/TestSolutions/AnalyzerViolations.cs index a437da7b..60bcd7d8 100644 --- a/TestSolutions/AnalyzerViolations.cs +++ b/TestSolutions/AnalyzerViolations.cs @@ -1,8 +1,11 @@ namespace Lombiq.Analyzers.ProjectReference; // This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the -// subdirectories will be copied over during build. Copying is necessary so duplicate warnings from different projects -// can be shown. +// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an +// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of +// effect.) Also please commit the updated version everywhere, because if the file is not present before the build +// starts then MSBuild won't include it despite the task. For this purpose the task is only there to +// ensure that the changes propagate and get committed. public class Class1 { private int Number; diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs new file mode 100644 index 00000000..60bcd7d8 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs @@ -0,0 +1,16 @@ +namespace Lombiq.Analyzers.ProjectReference; + +// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the +// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an +// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of +// effect.) Also please commit the updated version everywhere, because if the file is not present before the build +// starts then MSBuild won't include it despite the task. For this purpose the task is only there to +// ensure that the changes propagate and get committed. +public class Class1 +{ + private int Number; + public Class1(int number) + { + Number = number; + } +} diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs new file mode 100644 index 00000000..60bcd7d8 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs @@ -0,0 +1,16 @@ +namespace Lombiq.Analyzers.ProjectReference; + +// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the +// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an +// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of +// effect.) Also please commit the updated version everywhere, because if the file is not present before the build +// starts then MSBuild won't include it despite the task. For this purpose the task is only there to +// ensure that the changes propagate and get committed. +public class Class1 +{ + private int Number; + public Class1(int number) + { + Number = number; + } +} diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 5b754e76..661c3f11 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -11,10 +11,10 @@ - - - AnalyzerViolations.cs - + + + + diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs new file mode 100644 index 00000000..60bcd7d8 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs @@ -0,0 +1,16 @@ +namespace Lombiq.Analyzers.ProjectReference; + +// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the +// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an +// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of +// effect.) Also please commit the updated version everywhere, because if the file is not present before the build +// starts then MSBuild won't include it despite the task. For this purpose the task is only there to +// ensure that the changes propagate and get committed. +public class Class1 +{ + private int Number; + public Class1(int number) + { + Number = number; + } +} diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj index bbc688bd..61b3c6f3 100644 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj @@ -5,12 +5,10 @@ true - - - AnalyzerViolations.cs - - + + + - + From 1d4231838fb4d97170fc316e59f96a090645653b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 22:18:51 +0200 Subject: [PATCH 067/107] Verify the reason why it doesn't work. --- .../.editorconfig | 310 ++++++++++++++++++ 1 file changed, 310 insertions(+) create mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig new file mode 100644 index 00000000..6996c6f3 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig @@ -0,0 +1,310 @@ +# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will +# be overwritten. + +# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference +# If you found some issue then try to fix it, which you can also do from VS Quick Actions: +# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles +# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. + +# All files +[*] + +# Basics +charset = utf-8 +guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000 + +# Indentation and spacing +indent_size = 4 +indent_style = space +trim_trailing_whitespace = true + + +# New line preferences +end_of_line = crlf +insert_final_newline = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_auto_properties = true:warning + +# C# files +[*.cs] + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:warning +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_property = false:warning + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = always:warning + +# Expression-level preferences +dotnet_style_coalesce_expression = true:warning +dotnet_style_collection_initializer = true:warning +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_object_initializer = true:warning +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_return = false +dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning +dotnet_style_prefer_inferred_tuple_names = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_simplified_interpolation = true:warning + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = non_pubic:suggestion + +#### C# Style Rules #### + +#IDE* rules are managed here. + +# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced +# during build, see: https://github.com/dotnet/roslyn/issues/44201. + +# Default severity for analyzer diagnostics for all categories (escalated to build warnings). See +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/categories for the list of categories. +dotnet_analyzer_diagnostic.category-Design.severity = warning +dotnet_analyzer_diagnostic.category-Documentation.severity = warning +dotnet_analyzer_diagnostic.category-Globalization.severity = warning +dotnet_analyzer_diagnostic.category-Interoperability.severity = warning +dotnet_analyzer_diagnostic.category-Maintainability.severity = warning +dotnet_analyzer_diagnostic.category-Naming.severity = warning +dotnet_analyzer_diagnostic.category-Performance.severity = warning +dotnet_analyzer_diagnostic.category-SingleFile.severity = warning +dotnet_analyzer_diagnostic.category-Reliability.severity = warning +dotnet_analyzer_diagnostic.category-Security.severity = warning +dotnet_analyzer_diagnostic.category-Style.severity = warning +dotnet_analyzer_diagnostic.category-Usage.severity = warning +dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning + +# IDE0011: Add braces to 'if' statement. +# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn +# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. +dotnet_diagnostic.IDE0011.severity = none +# IDE0050: Convert to tuple +# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and +# those can fail on this silently in runtime while building correctly. +dotnet_diagnostic.IDE0050.severity = none +# IDE0052: Private member can be removed as the value assigned to it is never used. +# We use S4487 for that. +dotnet_diagnostic.IDE0052.severity = none +# IDE0072: Populate switch +# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. +dotnet_diagnostic.IDE0072.severity = none +# "Namespace 'Foo' does not match folder structure, expected 'Foo'" +dotnet_diagnostic.IDE0130.severity = none + +# While these are in the Style category, they need to be explicitly set for some reason. +# IDE0079 Remove unnecessary suppression +dotnet_diagnostic.IDE0079.severity = warning +dotnet_diagnostic.IDE0022.severity = warning + +# 'var' preferences +dotnet_diagnostic.IDE0007.severity = warning +dotnet_diagnostic.IDE0008.severity = none + +# We don't want to decorate every public member with XML comments, only public APIs - so turn CS1591 off. +# CS1591 Missing XML Comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = none + +#### C# Coding Conventions #### + +# 'var' preferences +# These won't take effect during build due to this bug: +# https://github.com/dotnet/roslyn/issues/44250 +csharp_style_var_elsewhere = true:warning +# If this is not turned off then there will be messages for e.g. integers too, like in for loops. +csharp_style_var_for_built_in_types = false:none +csharp_style_var_when_type_is_apparent = true:warning + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:warning +csharp_style_expression_bodied_constructors = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_lambdas = true:warning +csharp_style_expression_bodied_local_functions = true:warning +csharp_style_expression_bodied_methods = true:warning +csharp_style_expression_bodied_operators = true:warning +csharp_style_expression_bodied_properties = true:warning + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_prefer_switch_expression = true:warning + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:warning + +# Modifier preferences +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_simple_using_statement = true:warning +# IDE0160: Convert to block-scoped namespace +csharp_style_namespace_declarations = file_scoped:warning + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:warning +csharp_style_deconstructed_variable_declaration = false:silent +csharp_style_inlined_variable_declaration = true:warning +csharp_style_pattern_local_over_anonymous_function = true:warning +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_range_operator = true:warning +csharp_style_throw_expression = true:warning +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:none + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace:silent + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +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 +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# 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 = * +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = * +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 = * +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +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.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 + +# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. +dotnet_diagnostic.CA1031.severity = silent +# Disabling "do not nest type" suggestion. +dotnet_diagnostic.CA1034.severity = silent +# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. +dotnet_diagnostic.CA1810.severity = none + +# Don't apply "CA1822: Mark members as static" to the public API +dotnet_code_quality.ca1822.api_surface = private, internal +csharp_prefer_braces = true:silent + +# Various config files +[*.{config,csproj,json,props,targets}] + +indent_size = 2 + +# Markdown files +[*.md] + +trim_trailing_whitespace = false + +# JavaScript files +[*.js] + +# Placeholder, no unique rules for JS files at the moment. + + +# SCSS files +[*.scss] + +# Placeholder, no unique rules for SCSS files at the moment. + +# PowerShell files +[*.ps1] + +# Placeholder, no unique rules for PS files at the moment. From 73da7eab397f6ce647a50e617db3891679191f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 22:38:08 +0200 Subject: [PATCH 068/107] Try to embed .editorconfig. --- Lombiq.Analyzers/Build.props | 4 + .../.editorconfig | 310 ------------------ 2 files changed, 4 insertions(+), 310 deletions(-) delete mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 33ce6402..0232e9e4 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -76,4 +76,8 @@ + + + + diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig b/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig deleted file mode 100644 index 6996c6f3..00000000 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/.editorconfig +++ /dev/null @@ -1,310 +0,0 @@ -# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will -# be overwritten. - -# Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference -# If you found some issue then try to fix it, which you can also do from VS Quick Actions: -# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#automatically-configure-code-styles -# Add new file types at the bottom. For new rules for C# files follow the structure that VS generates. - -# All files -[*] - -# Basics -charset = utf-8 -guidelines = 120 1px solid a0ffc000, 150 1px solid 80ff0000 - -# Indentation and spacing -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true - - -# New line preferences -end_of_line = crlf -insert_final_newline = true -dotnet_style_operator_placement_when_wrapping = beginning_of_line -tab_width = 4 -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_auto_properties = true:warning - -# C# files -[*.cs] - -#### .NET Coding Conventions #### - -# Organize usings -dotnet_separate_import_directive_groups = false -dotnet_sort_system_directives_first = false - -# this. and Me. preferences -dotnet_style_qualification_for_event = false:warning -dotnet_style_qualification_for_field = false:warning -dotnet_style_qualification_for_method = false:warning -dotnet_style_qualification_for_property = false:warning - -# Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:warning -dotnet_style_predefined_type_for_member_access = true:warning - -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent - -# Modifier preferences -dotnet_style_require_accessibility_modifiers = always:warning - -# Expression-level preferences -dotnet_style_coalesce_expression = true:warning -dotnet_style_collection_initializer = true:warning -dotnet_style_explicit_tuple_names = true:warning -dotnet_style_null_propagation = true:warning -dotnet_style_object_initializer = true:warning -dotnet_style_prefer_auto_properties = true:warning -dotnet_style_prefer_compound_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_assignment = true:warning -dotnet_style_prefer_conditional_expression_over_return = false -dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning -dotnet_style_prefer_inferred_tuple_names = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_simplified_interpolation = true:warning - -# Field preferences -dotnet_style_readonly_field = true:warning - -# Parameter preferences -dotnet_code_quality_unused_parameters = non_pubic:suggestion - -#### C# Style Rules #### - -#IDE* rules are managed here. - -# Note that currently both IDE* rules and csharp_style_* rules are necessary, because only IDE rules will be enforced -# during build, see: https://github.com/dotnet/roslyn/issues/44201. - -# Default severity for analyzer diagnostics for all categories (escalated to build warnings). See -# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/categories for the list of categories. -dotnet_analyzer_diagnostic.category-Design.severity = warning -dotnet_analyzer_diagnostic.category-Documentation.severity = warning -dotnet_analyzer_diagnostic.category-Globalization.severity = warning -dotnet_analyzer_diagnostic.category-Interoperability.severity = warning -dotnet_analyzer_diagnostic.category-Maintainability.severity = warning -dotnet_analyzer_diagnostic.category-Naming.severity = warning -dotnet_analyzer_diagnostic.category-Performance.severity = warning -dotnet_analyzer_diagnostic.category-SingleFile.severity = warning -dotnet_analyzer_diagnostic.category-Reliability.severity = warning -dotnet_analyzer_diagnostic.category-Security.severity = warning -dotnet_analyzer_diagnostic.category-Style.severity = warning -dotnet_analyzer_diagnostic.category-Usage.severity = warning -dotnet_analyzer_diagnostic.category-CodeQuality.severity = warning - -# IDE0011: Add braces to 'if' statement. -# The "when-multiline:warning" config is not actually for cases when the if body is in another line so we have to turn -# this off completely, see: https://github.com/dotnet/roslyn/issues/40912. -dotnet_diagnostic.IDE0011.severity = none -# IDE0050: Convert to tuple -# Quite dangerous as we most frequently use anonymous types to interface with other APIs (like generating routes) and -# those can fail on this silently in runtime while building correctly. -dotnet_diagnostic.IDE0050.severity = none -# IDE0052: Private member can be removed as the value assigned to it is never used. -# We use S4487 for that. -dotnet_diagnostic.IDE0052.severity = none -# IDE0072: Populate switch -# Also signals on switches with discards, by design: https://github.com/dotnet/roslyn/issues/48876. -dotnet_diagnostic.IDE0072.severity = none -# "Namespace 'Foo' does not match folder structure, expected 'Foo'" -dotnet_diagnostic.IDE0130.severity = none - -# While these are in the Style category, they need to be explicitly set for some reason. -# IDE0079 Remove unnecessary suppression -dotnet_diagnostic.IDE0079.severity = warning -dotnet_diagnostic.IDE0022.severity = warning - -# 'var' preferences -dotnet_diagnostic.IDE0007.severity = warning -dotnet_diagnostic.IDE0008.severity = none - -# We don't want to decorate every public member with XML comments, only public APIs - so turn CS1591 off. -# CS1591 Missing XML Comment for publicly visible type or member -dotnet_diagnostic.CS1591.severity = none - -#### C# Coding Conventions #### - -# 'var' preferences -# These won't take effect during build due to this bug: -# https://github.com/dotnet/roslyn/issues/44250 -csharp_style_var_elsewhere = true:warning -# If this is not turned off then there will be messages for e.g. integers too, like in for loops. -csharp_style_var_for_built_in_types = false:none -csharp_style_var_when_type_is_apparent = true:warning - -# Expression-bodied members -csharp_style_expression_bodied_accessors = true:warning -csharp_style_expression_bodied_constructors = true:warning -csharp_style_expression_bodied_indexers = true:warning -csharp_style_expression_bodied_lambdas = true:warning -csharp_style_expression_bodied_local_functions = true:warning -csharp_style_expression_bodied_methods = true:warning -csharp_style_expression_bodied_operators = true:warning -csharp_style_expression_bodied_properties = true:warning - -# Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:warning -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_prefer_switch_expression = true:warning - -# Null-checking preferences -csharp_style_conditional_delegate_call = true:warning - -# Modifier preferences -csharp_prefer_static_local_function = true:warning -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent - -# Code-block preferences -csharp_prefer_simple_using_statement = true:warning -# IDE0160: Convert to block-scoped namespace -csharp_style_namespace_declarations = file_scoped:warning - -# Expression-level preferences -csharp_prefer_simple_default_expression = true:warning -csharp_style_deconstructed_variable_declaration = false:silent -csharp_style_inlined_variable_declaration = true:warning -csharp_style_pattern_local_over_anonymous_function = true:warning -csharp_style_prefer_index_operator = true:warning -csharp_style_prefer_range_operator = true:warning -csharp_style_throw_expression = true:warning -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:none - -# 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent - -#### C# Formatting Rules #### - -# New line preferences -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_open_brace = all -csharp_new_line_between_query_expression_clauses = true - -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_case_contents_when_block = true -csharp_indent_labels = no_change -csharp_indent_switch_labels = true - -# Space preferences -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -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 -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -# Wrapping preferences -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true - -#### Naming styles #### - -# 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 = * -dotnet_naming_symbols.interface.required_modifiers = - -dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum -dotnet_naming_symbols.types.applicable_accessibilities = * -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 = * -dotnet_naming_symbols.non_field_members.required_modifiers = - -# Naming styles - -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.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 - -# Disabling "catch a more specific exception type" suggestion which is overwhelmingly a false positive. -dotnet_diagnostic.CA1031.severity = silent -# Disabling "do not nest type" suggestion. -dotnet_diagnostic.CA1034.severity = silent -# Disabling "CA1810: Initialize reference type static fields inline" as RSPEC-3963 is used instead. -dotnet_diagnostic.CA1810.severity = none - -# Don't apply "CA1822: Mark members as static" to the public API -dotnet_code_quality.ca1822.api_surface = private, internal -csharp_prefer_braces = true:silent - -# Various config files -[*.{config,csproj,json,props,targets}] - -indent_size = 2 - -# Markdown files -[*.md] - -trim_trailing_whitespace = false - -# JavaScript files -[*.js] - -# Placeholder, no unique rules for JS files at the moment. - - -# SCSS files -[*.scss] - -# Placeholder, no unique rules for SCSS files at the moment. - -# PowerShell files -[*.ps1] - -# Placeholder, no unique rules for PS files at the moment. From 0f686c8460048cc9b962978fb4b559509815d1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 22:41:23 +0200 Subject: [PATCH 069/107] Try inside the target --- Lombiq.Analyzers/Build.props | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 0232e9e4..7beb76dd 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -73,11 +73,14 @@ True - + - - - - + + + + From 90d917e15d5bc20855a6d46be0b4be8002aad46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 22:54:09 +0200 Subject: [PATCH 070/107] Try embedding AnalyzerViolations. --- .../AnalyzerViolations.cs | 16 ---------------- .../AnalyzerViolations.cs | 16 ---------------- .../IndirectPackageReference.csproj | 4 ++++ .../Lombiq.Analyzers.PackageReference.csproj | 4 ++++ .../AnalyzerViolations.cs | 16 ---------------- .../Lombiq.Analyzers.ProjectReference.csproj | 4 ++++ 6 files changed, 12 insertions(+), 48 deletions(-) delete mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs delete mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs delete mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs deleted file mode 100644 index 60bcd7d8..00000000 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Lombiq.Analyzers.ProjectReference; - -// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the -// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an -// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of -// effect.) Also please commit the updated version everywhere, because if the file is not present before the build -// starts then MSBuild won't include it despite the task. For this purpose the task is only there to -// ensure that the changes propagate and get committed. -public class Class1 -{ - private int Number; - public Class1(int number) - { - Number = number; - } -} diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs deleted file mode 100644 index 60bcd7d8..00000000 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Lombiq.Analyzers.ProjectReference; - -// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the -// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an -// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of -// effect.) Also please commit the updated version everywhere, because if the file is not present before the build -// starts then MSBuild won't include it despite the task. For this purpose the task is only there to -// ensure that the changes propagate and get committed. -public class Class1 -{ - private int Number; - public Class1(int number) - { - Number = number; - } -} diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index 603c89e6..3eb5ccba 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -17,4 +17,8 @@ + + + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 661c3f11..4cdf06d2 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -17,4 +17,8 @@ + + + + diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs deleted file mode 100644 index 60bcd7d8..00000000 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Lombiq.Analyzers.ProjectReference; - -// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the -// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an -// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of -// effect.) Also please commit the updated version everywhere, because if the file is not present before the build -// starts then MSBuild won't include it despite the task. For this purpose the task is only there to -// ensure that the changes propagate and get committed. -public class Class1 -{ - private int Number; - public Class1(int number) - { - Number = number; - } -} diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj index 61b3c6f3..ceed5021 100644 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj @@ -9,6 +9,10 @@ + + + + From 458755fcc06650a8c91fdfb9ae8f853c497dba3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 22:58:43 +0200 Subject: [PATCH 071/107] Put them back. --- Lombiq.Analyzers/Build.props | 2 +- .../AnalyzerViolations.cs | 16 ++++++++++++++++ .../AnalyzerViolations.cs | 16 ++++++++++++++++ .../AnalyzerViolations.cs | 16 ++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs create mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs create mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 7beb76dd..8c6f1735 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -75,7 +75,7 @@ diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs new file mode 100644 index 00000000..60bcd7d8 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs @@ -0,0 +1,16 @@ +namespace Lombiq.Analyzers.ProjectReference; + +// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the +// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an +// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of +// effect.) Also please commit the updated version everywhere, because if the file is not present before the build +// starts then MSBuild won't include it despite the task. For this purpose the task is only there to +// ensure that the changes propagate and get committed. +public class Class1 +{ + private int Number; + public Class1(int number) + { + Number = number; + } +} diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs new file mode 100644 index 00000000..60bcd7d8 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs @@ -0,0 +1,16 @@ +namespace Lombiq.Analyzers.ProjectReference; + +// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the +// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an +// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of +// effect.) Also please commit the updated version everywhere, because if the file is not present before the build +// starts then MSBuild won't include it despite the task. For this purpose the task is only there to +// ensure that the changes propagate and get committed. +public class Class1 +{ + private int Number; + public Class1(int number) + { + Number = number; + } +} diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs new file mode 100644 index 00000000..60bcd7d8 --- /dev/null +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs @@ -0,0 +1,16 @@ +namespace Lombiq.Analyzers.ProjectReference; + +// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the +// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an +// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of +// effect.) Also please commit the updated version everywhere, because if the file is not present before the build +// starts then MSBuild won't include it despite the task. For this purpose the task is only there to +// ensure that the changes propagate and get committed. +public class Class1 +{ + private int Number; + public Class1(int number) + { + Number = number; + } +} From 18d9bfacc5672d5857aa7392723184e1e36a9174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 23:47:35 +0200 Subject: [PATCH 072/107] Use the LombiqNetAnalyzers target. --- Lombiq.Analyzers/Build.props | 19 +++++++++++-------- .../IndirectPackageReference.csproj | 2 +- .../Lombiq.Analyzers.PackageReference.csproj | 2 +- .../Lombiq.Analyzers.ProjectReference.csproj | 6 +----- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 8c6f1735..c0bc0f86 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -73,14 +73,17 @@ True - - + + - - - + + + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index 3eb5ccba..9ff08a79 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -13,7 +13,7 @@ - + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 4cdf06d2..a5c74444 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -13,7 +13,7 @@ - + diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj index ceed5021..da91f1b9 100644 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj @@ -5,14 +5,10 @@ true - + - - - - From d66434cbc89aaa90b037b71bff97e020cdc2fdb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 28 Jul 2022 23:58:51 +0200 Subject: [PATCH 073/107] Cleanup and fix target name. --- .gitignore | 3 ++- Lombiq.Analyzers/Build.props | 2 +- .../AnalyzerViolations.cs | 16 ---------------- .../AnalyzerViolations.cs | 16 ---------------- 4 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/AnalyzerViolations.cs delete mode 100644 TestSolutions/Lombiq.Analyzers.ProjectReference/AnalyzerViolations.cs diff --git a/.gitignore b/.gitignore index 49020d3c..e66c7e41 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ wwwroot/ node_modules/ *.user .pnpm-debug.log -/TestSolutions/Lombiq.Analyzers.*/.editorconfig /.editorconfig +/TestSolutions/Lombiq.Analyzers.*/.editorconfig +/TestSolutions/Lombiq.Analyzers.*/AnalyzerViolations.cs /Lombiq.Analyzers/Lombiq.Analyzers.nuspec diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index c0bc0f86..7339b359 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -73,7 +73,7 @@ True - + - + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index d956c804..d9f5e894 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -5,7 +5,7 @@ - + From 129397a469c6ccae05a89c1fc4c18101cda9e0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 29 Jul 2022 00:46:57 +0200 Subject: [PATCH 077/107] Retarget. --- .gitignore | 1 + .../AnalyzerViolations.cs | 16 ---------------- .../IndirectPackageReference.csproj | 10 +++++----- .../Lombiq.Analyzers.PackageReference.csproj | 8 ++------ .../Lombiq.Analyzers.ProjectReference.csproj | 2 +- 5 files changed, 9 insertions(+), 28 deletions(-) delete mode 100644 TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs diff --git a/.gitignore b/.gitignore index e66c7e41..97d20264 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ node_modules/ /.editorconfig /TestSolutions/Lombiq.Analyzers.*/.editorconfig /TestSolutions/Lombiq.Analyzers.*/AnalyzerViolations.cs +/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs /Lombiq.Analyzers/Lombiq.Analyzers.nuspec diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs deleted file mode 100644 index 60bcd7d8..00000000 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Lombiq.Analyzers.ProjectReference; - -// This file has intentional analyzer violations. Only edit the one in the TestSolutions directory. Any copy in the -// subdirectories will be copied over during build. Copying is necessary so the source files are in a directory with an -// existing parent .editorconfig file. (Linking will cause them to physically be outside of the .editorconfig's area of -// effect.) Also please commit the updated version everywhere, because if the file is not present before the build -// starts then MSBuild won't include it despite the task. For this purpose the task is only there to -// ensure that the changes propagate and get committed. -public class Class1 -{ - private int Number; - public Class1(int number) - { - Number = number; - } -} diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index 4a21fb09..1026cb7e 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -12,13 +12,13 @@ + + + + - + - - - - diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index d9f5e894..c800e827 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -12,13 +12,9 @@ - - + + - - - - diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj index 03c60b8d..fe2591e8 100644 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj @@ -5,7 +5,7 @@ true - + From 2850386bece49c144b8dd8e9cfdd30984b48dbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 29 Jul 2022 01:03:19 +0200 Subject: [PATCH 078/107] More information. --- Lombiq.Analyzers/Build.props | 3 ++- Lombiq.Analyzers/Docs/UsingAnalyzersDuringCommandLineBuilds.md | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 7339b359..b7e851e6 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -78,7 +78,8 @@ + project has this target, but that's not really relevant. If you are using NuGet, then the argument should be + "-target:Restore;LombiqNetAnalyzers" instead (include the quotes) to load the pacakge first. --> ⚠ If you are using the NuGet package, run `dotnet msbuild "-t:Restore;LombiqNetAnalyzers" MySolution.sln` first to ensure the _.editorconfig_ file is deployed. This is especially important for CI usage. For local development, you can simply rebuild the solution. + Note that code style analysis is experimental in the .NET 5 SDK and [may change in later versions](https://github.com/dotnet/roslyn/issues/49044). ## Non-SDK-style .NET Framework projects From 837a46cf562e32f7de43d9e408673f6ed4c9a973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 2 Aug 2022 01:53:37 +0200 Subject: [PATCH 079/107] Update Invoke-BeforePack.ps1 Co-authored-by: 0liver <0liver@users.noreply.github.com> --- Invoke-BeforePack.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index eed8890e..930b8fec 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -1,4 +1,4 @@ -# This script tries to work around NuGet's validation and the NU5100 warning caused by the presence of these files +# This script tries to work around NuGet's validation and the NU5100 warning caused by the presence of these files: # - bin/Release/netstandard2.0/Lombiq.Analyzers.dll # - obj/Release/netstandard2.0/Lombiq.Analyzers.dll # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need From ca95341a9b7eba647c08fe05bd040c58f6b33d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 2 Aug 2022 01:54:19 +0200 Subject: [PATCH 080/107] Update .gitignore Co-authored-by: 0liver <0liver@users.noreply.github.com> --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 97d20264..7df15708 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ node_modules/ *.user .pnpm-debug.log /.editorconfig -/TestSolutions/Lombiq.Analyzers.*/.editorconfig +/TestSolutions/**/.editorconfig /TestSolutions/Lombiq.Analyzers.*/AnalyzerViolations.cs /TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs /Lombiq.Analyzers/Lombiq.Analyzers.nuspec From a45bed6fb21a27c69a567bc63ad5e778a75402f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 2 Aug 2022 01:54:31 +0200 Subject: [PATCH 081/107] Update .gitignore Co-authored-by: 0liver <0liver@users.noreply.github.com> --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7df15708..b2b691d4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,5 @@ node_modules/ .pnpm-debug.log /.editorconfig /TestSolutions/**/.editorconfig -/TestSolutions/Lombiq.Analyzers.*/AnalyzerViolations.cs -/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/AnalyzerViolations.cs +/TestSolutions/Lombiq.Analyzers.*/**/AnalyzerViolations.cs /Lombiq.Analyzers/Lombiq.Analyzers.nuspec From 336562d2ed7896f7e58e5353621c095b03438127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 2 Aug 2022 01:55:43 +0200 Subject: [PATCH 082/107] Rename Open-Xml to Read-Xml. see https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands?view=powershell-7.2#get-vs-read --- ConvertTo-Nuspec.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ConvertTo-Nuspec.ps1 b/ConvertTo-Nuspec.ps1 index 31b9cc0f..2b61ea57 100644 --- a/ConvertTo-Nuspec.ps1 +++ b/ConvertTo-Nuspec.ps1 @@ -1,14 +1,14 @@ param($Version) $projectPath = Join-Path $PWD Lombiq.Analyzers -function Open-Xml([string]$File) { [xml](Get-Content (Join-Path $projectPath $File)) } +function Read-Xml([string]$File) { [xml](Get-Content (Join-Path $projectPath $File)) } -$nuspec = Open-Xml Lombiq.Analyzers.nuspec.template +$nuspec = Read-Xml Lombiq.Analyzers.nuspec.template $dependencies = $nuspec.package.metadata.dependencies $nuspec.package.metadata.GetElementsByTagName('version')[0].InnerXml = $Version -foreach($dependency in (Open-Xml CommonPackages.props).Project.ItemGroup.AnalyzerPackage) +foreach($dependency in (Read-Xml CommonPackages.props).Project.ItemGroup.AnalyzerPackage) { $id = $dependency.Include if (-not $id) { continue } From 71fca85baee353f1186e2e1ef2264f6cbb1e16aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 2 Aug 2022 16:35:23 +0200 Subject: [PATCH 083/107] Update Lombiq.Analyzers.sln Co-authored-by: 0liver <0liver@users.noreply.github.com> --- Lombiq.Analyzers.sln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers.sln b/Lombiq.Analyzers.sln index d7b048a3..4ea0a908 100644 --- a/Lombiq.Analyzers.sln +++ b/Lombiq.Analyzers.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30114.105 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32112.339 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lombiq.Analyzers", "Lombiq.Analyzers\Lombiq.Analyzers.csproj", "{1435B0AD-AB9A-42BA-B3D9-554FE5274CE8}" EndProject From 9f9a412f3632ff0bdbb0e1e6d83649e116f0df46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 3 Aug 2022 18:42:28 +0200 Subject: [PATCH 084/107] Comment improvements. --- Lombiq.Analyzers/Build.props | 2 +- TestSolutions/Directory.Build.props | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index b7e851e6..a1253028 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -79,7 +79,7 @@ + "-target:Restore;LombiqNetAnalyzers" instead (include the quotes) to restore all package dependencies first. --> - - - - true - - + true From d45806dc23edb9587a422bcb0f0f8c7d96c17004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 3 Aug 2022 18:42:46 +0200 Subject: [PATCH 085/107] Add missing AfterTargets. --- .../IndirectPackageReference/IndirectPackageReference.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index 1026cb7e..bd06e96f 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -14,7 +14,7 @@ - + From 0041dab78dd587f316c0a5bd9378880808828e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 3 Aug 2022 18:43:46 +0200 Subject: [PATCH 086/107] Remove unnecessary stuff? --- Lombiq.Analyzers/build/Lombiq.Analyzers.props | 1 - .../IndirectPackageReference/IndirectPackageReference.csproj | 2 +- .../Lombiq.Analyzers.PackageReference.csproj | 4 ++-- .../Lombiq.Analyzers.ProjectReference.csproj | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Lombiq.Analyzers/build/Lombiq.Analyzers.props b/Lombiq.Analyzers/build/Lombiq.Analyzers.props index a676dc5f..49b5725f 100644 --- a/Lombiq.Analyzers/build/Lombiq.Analyzers.props +++ b/Lombiq.Analyzers/build/Lombiq.Analyzers.props @@ -1,7 +1,6 @@ true - true diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index bd06e96f..f0fad830 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -17,7 +17,7 @@ - + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index c800e827..7200f133 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj index fe2591e8..763500b1 100644 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj @@ -2,10 +2,9 @@ net6.0 - true - + From 51b921c32d0204c8c638aa0b21d319732d1d5d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 3 Aug 2022 19:21:26 +0200 Subject: [PATCH 087/107] Move the Import of .props files to the beginning of the project file in conformance with what happens when you reference the NuGet package. --- .../Lombiq.Analyzers.ProjectReference.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj index 763500b1..19f387d4 100644 --- a/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.ProjectReference/Lombiq.Analyzers.ProjectReference.csproj @@ -1,5 +1,7 @@ + + net6.0 @@ -8,6 +10,4 @@ - - From af635281bfd396b8b837eaaffbfd3e98bc6331e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 3 Aug 2022 19:32:50 +0200 Subject: [PATCH 088/107] Comments. --- Lombiq.Analyzers/Build.props | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index a1253028..cb6184cc 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -23,7 +23,7 @@ + By making this conditional, it won't overwrite the value if you set it in the Directory.Build.props file. --> false @@ -73,6 +73,10 @@ True + From ac86f54b57c6878976b8a03646a90570860cc501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 3 Aug 2022 19:39:06 +0200 Subject: [PATCH 089/107] I don't think we actually need this. --- Lombiq.Analyzers/Build.props | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index cb6184cc..46078a6e 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -66,13 +66,6 @@ - - - True - true - True - - - + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 7200f133..6c6c453c 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -5,7 +5,7 @@ - + From 4a1010b0a8954ce98a1e3c082767797a36d16395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 4 Aug 2022 01:35:00 +0200 Subject: [PATCH 091/107] Add comments. --- Lombiq.Analyzers/Build.props | 1 + TestSolutions/Directory.Build.props | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 46078a6e..4b4cb605 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -66,6 +66,7 @@ + - + + all + + + + + diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index 6c6c453c..f44180c7 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -5,7 +5,9 @@ - + + all + From 226c16643c3865f3401e836dfb022e0244503cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 4 Aug 2022 01:58:54 +0200 Subject: [PATCH 093/107] Remove "and the NU5100 warning". --- Invoke-BeforePack.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 930b8fec..a2fe6b83 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -1,4 +1,4 @@ -# This script tries to work around NuGet's validation and the NU5100 warning caused by the presence of these files: +# This script tries to work around NuGet's validation caused by the presence of these files: # - bin/Release/netstandard2.0/Lombiq.Analyzers.dll # - obj/Release/netstandard2.0/Lombiq.Analyzers.dll # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need From bcf4e61c99777cc9aac3342527fa6a5c6a1c1a5e Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 10:34:07 +0200 Subject: [PATCH 094/107] Update WARNING comment --- Lombiq.Analyzers/.editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.Analyzers/.editorconfig b/Lombiq.Analyzers/.editorconfig index 6996c6f3..1791262b 100644 --- a/Lombiq.Analyzers/.editorconfig +++ b/Lombiq.Analyzers/.editorconfig @@ -1,5 +1,5 @@ -# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's folder. A copy of this file anywhere else will -# be overwritten. +# WARNING: Only edit this file in the Lombiq .NET Analyzers repository's "Lombiq.Analyzers" folder. A copy of this file +# anywhere else will be overwritten. # Common .NET conventions, code formatting and naming convention rules. Check out possible configs here: # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference From 8fd36019aa478b76c54f48dca5cb0084ad56fd13 Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 11:17:57 +0200 Subject: [PATCH 095/107] Trying to fix NU5104 --- Invoke-BeforePack.ps1 | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index a2fe6b83..5e5b209d 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -4,16 +4,6 @@ # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). -$release = Get-ChildItem Lombiq.Analyzers/bin/Release -Recurse -Include Lombiq.Analyzers.dll -$releasePdb = $release.FullName -replace 'dll$','pdb' New-Item -Type Directory -Force lib -Copy-Item $release lib - -if (Test-Path $releasePdb) -{ - Copy-Item $releasePdb lib -} -else -{ - Write-Warning "There is no $releasePdb file!" -} +Get-ChildItem bin\Debug | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll +Get-ChildItem bin\Debug | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb From 32a3f88766905fe7057b58d5da64e5e4da42762e Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 11:29:45 +0200 Subject: [PATCH 096/107] Improve documentation --- .../IndirectPackageReference.csproj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index 47d989e3..d097e309 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -18,8 +18,10 @@ - - + + From 355e38306ec87b13d97a05fe01939a59d505e695 Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 11:35:05 +0200 Subject: [PATCH 097/107] Fix path to Release --- Invoke-BeforePack.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 5e5b209d..39eb47b4 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -5,5 +5,5 @@ # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). New-Item -Type Directory -Force lib -Get-ChildItem bin\Debug | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll -Get-ChildItem bin\Debug | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb +Get-ChildItem bin\Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll +Get-ChildItem bin\Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb From 67d61c1bb49db7177cb53df738bed7e54632737e Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 11:39:49 +0200 Subject: [PATCH 098/107] Fix path to Release again --- Invoke-BeforePack.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 39eb47b4..20e9ca0c 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -5,5 +5,5 @@ # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). New-Item -Type Directory -Force lib -Get-ChildItem bin\Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll -Get-ChildItem bin\Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb +Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll +Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb From 76b8a5f33ca810bd3735af570bfff9b30ef5553b Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 11:46:24 +0200 Subject: [PATCH 099/107] Debugging the lib folder --- Invoke-BeforePack.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 20e9ca0c..08869626 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -4,6 +4,11 @@ # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). -New-Item -Type Directory -Force lib -Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll -Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb + +#New-Item -Type Directory -Force lib +#Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll +#Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb + +Get-ChildItem Lombiq.Analyzers/lib + +Get-ChildItem Lombiq.Analyzers/lib/netstandard2.0 From 33ee340cf63f10835b721b02a07089c468b3c186 Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 12:08:34 +0200 Subject: [PATCH 100/107] Explicit paths as proof-of-concept --- Invoke-BeforePack.ps1 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 08869626..5b01a253 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -4,11 +4,7 @@ # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). - -#New-Item -Type Directory -Force lib -#Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.dll -#Get-ChildItem Lombiq.Analyzers/bin/Release | Copy-Item -Destination lib -Recurse -filter Lombiq.Analyzers.pdb - -Get-ChildItem Lombiq.Analyzers/lib - -Get-ChildItem Lombiq.Analyzers/lib/netstandard2.0 +$framework = "netstandard2.0" +New-Item -Type Directory -Force Lombiq.Analyzers/lib/$framework +Copy-Item Lombiq.Analyzers/bin/Release/$framework/Lombiq.Analyzers.dll -Destination Lombiq.Analyzers/lib/$framework +Copy-Item Lombiq.Analyzers/bin/Release/$framework/Lombiq.Analyzers.dll -Destination Lombiq.Analyzers/lib/$framework \ No newline at end of file From 8f843b38370b3d081b3ea7dc8a2187e5702f9c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 4 Aug 2022 12:12:31 +0200 Subject: [PATCH 101/107] RunAnalyzersDuringBuild condition --- Lombiq.Analyzers/Build.props | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index 4b4cb605..aadb8fd6 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -2,6 +2,10 @@ $(MSBuildThisFileDirectory)orchardcore.ruleset true + + false @@ -22,12 +26,6 @@ <_SkipUpgradeNetAnalyzersNuGetWarning>true - - - false - - From 364bac666c32ce03503819c68e0c7edfad758331 Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 12:33:52 +0200 Subject: [PATCH 102/107] Restore working version --- Invoke-BeforePack.ps1 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 5b01a253..a2fe6b83 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -4,7 +4,16 @@ # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). -$framework = "netstandard2.0" -New-Item -Type Directory -Force Lombiq.Analyzers/lib/$framework -Copy-Item Lombiq.Analyzers/bin/Release/$framework/Lombiq.Analyzers.dll -Destination Lombiq.Analyzers/lib/$framework -Copy-Item Lombiq.Analyzers/bin/Release/$framework/Lombiq.Analyzers.dll -Destination Lombiq.Analyzers/lib/$framework \ No newline at end of file +$release = Get-ChildItem Lombiq.Analyzers/bin/Release -Recurse -Include Lombiq.Analyzers.dll +$releasePdb = $release.FullName -replace 'dll$','pdb' +New-Item -Type Directory -Force lib +Copy-Item $release lib + +if (Test-Path $releasePdb) +{ + Copy-Item $releasePdb lib +} +else +{ + Write-Warning "There is no $releasePdb file!" +} From a040b885c64c09ccfea0f16d59ead77b18a34789 Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 13:32:04 +0200 Subject: [PATCH 103/107] Remove .dll files from build output to prevent NU5100 --- Invoke-BeforePack.ps1 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index a2fe6b83..012704d0 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -4,16 +4,10 @@ # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). -$release = Get-ChildItem Lombiq.Analyzers/bin/Release -Recurse -Include Lombiq.Analyzers.dll -$releasePdb = $release.FullName -replace 'dll$','pdb' -New-Item -Type Directory -Force lib -Copy-Item $release lib +# Remove all .dll files from the directory to be packed. -if (Test-Path $releasePdb) -{ - Copy-Item $releasePdb lib -} -else -{ - Write-Warning "There is no $releasePdb file!" -} +# First, the whole \bin folder. +Remove-Item .\Lombiq.Analyzers\bin -Recurse + +# Then, all .dll files under the \obj folder. +Get-ChildItem Lombiq.Analyzers\obj -Include *.dll -Recurse | Remove-Item From 47ec6a3ea554b5ca91bd5d75dcf5ed0abc8dbbff Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 13:42:41 +0200 Subject: [PATCH 104/107] Update package version to 2.1.1-osoe-110.22 --- .../IndirectPackageReference/IndirectPackageReference.csproj | 2 +- .../Lombiq.Analyzers.PackageReference.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj index d097e309..9d5d6104 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/IndirectPackageReference/IndirectPackageReference.csproj @@ -10,7 +10,7 @@ --> - + all diff --git a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj index f44180c7..726d2a1c 100644 --- a/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj +++ b/TestSolutions/Lombiq.Analyzers.PackageReference/Lombiq.Analyzers.PackageReference.csproj @@ -5,7 +5,7 @@ - + all From e677c714f3baddc5995495c64caf9adb3dccd6ba Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 14:35:16 +0200 Subject: [PATCH 105/107] Don't create a symbol package for Lombiq.Analyzers --- .github/workflows/publish-nuget.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 0bd8ec81..a6bd8bc9 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -8,5 +8,9 @@ on: jobs: call-publish-workflow: uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OSOE-110 + with: + # Don't generate any symbol package because we're not including the Lombiq.Analyzers.dll in the NuGet package + # itself, either. See Invoke-BeforePack.ps1 for details. + dotnet-pack-include-symbols: "false" secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }} From 40b6ff92bf1949c605c2d844e283be01f3801f1e Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 14:37:28 +0200 Subject: [PATCH 106/107] Remove \obj\Release completely before packing --- Invoke-BeforePack.ps1 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Invoke-BeforePack.ps1 b/Invoke-BeforePack.ps1 index 012704d0..cc38cc43 100644 --- a/Invoke-BeforePack.ps1 +++ b/Invoke-BeforePack.ps1 @@ -4,10 +4,6 @@ # The cause is probably that we don't actually do anything in the corresponding csproj, it only exists because we need # an entry point for `dotnet pack` (unlike the older `nuget pack` tooling, which worked with just the .nuspec alone). -# Remove all .dll files from the directory to be packed. - -# First, the whole \bin folder. -Remove-Item .\Lombiq.Analyzers\bin -Recurse - -# Then, all .dll files under the \obj folder. -Get-ChildItem Lombiq.Analyzers\obj -Include *.dll -Recurse | Remove-Item +# Remove all .dll and other build output files from the directory to be packed. +Remove-Item Lombiq.Analyzers/bin -Recurse +Remove-Item Lombiq.Analyzers/obj/Release -Recurse From 4b28262c6cf965dee792d25aeb9ab0abc0b11661 Mon Sep 17 00:00:00 2001 From: Oliver Friedrich Date: Thu, 4 Aug 2022 14:51:35 +0200 Subject: [PATCH 107/107] Minor docs improvements --- Lombiq.Analyzers/Build.props | 4 ++-- TestSolutions/Directory.Build.props | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lombiq.Analyzers/Build.props b/Lombiq.Analyzers/Build.props index aadb8fd6..34021ccb 100644 --- a/Lombiq.Analyzers/Build.props +++ b/Lombiq.Analyzers/Build.props @@ -66,7 +66,7 @@ @@ -75,7 +75,7 @@ + "-target:Restore;LombiqNetAnalyzers" (including the quotes) to restore all package dependencies first. --> + everything is commented out inside, it shouldn't be deleted. -->