From 98a618a77ae701e8e98534f6593770362ff13806 Mon Sep 17 00:00:00 2001 From: Amadeusz Sadowski Date: Wed, 3 Jan 2024 18:41:47 +0100 Subject: [PATCH] feat: refactor Sdk, make compatible with .NET 8 and CPM --- .editorconfig | 392 ++++++++++++++++++ .gitignore | 1 + Directory.Build.props | 51 +-- Directory.Build.targets | 12 +- README.md | 72 ++-- .../Allegro.DotnetSdk.csproj | 20 +- src/Allegro.DotnetSdk/Sdk/Sdk.props | 100 +---- src/Allegro.DotnetSdk/Sdk/Sdk.targets | 22 +- .../Sdk/UseAllegroDotnetSdkDefaults.props | 41 ++ .../Sdk/UseAllegroDotnetSdkDefaults.targets | 45 ++ .../Sdk/UseDefaultAnalyzers.targets | 27 ++ src/Allegro.DotnetSdk/Sdk/editor.globalconfig | 9 - src/package.build.props | 20 - 13 files changed, 600 insertions(+), 212 deletions(-) create mode 100644 .editorconfig create mode 100644 src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.props create mode 100644 src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets create mode 100644 src/Allegro.DotnetSdk/Sdk/UseDefaultAnalyzers.targets delete mode 100644 src/package.build.props diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b3fb98c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,392 @@ +root = true + +# All files +[*] +indent_style = space + +# Xml files +[*.xml] +indent_size = 2 + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### +[*.{cs,vb}] + +# Organize usings +dotnet_separate_import_directive_groups = true +dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent + +# 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 = for_non_interface_members:silent + +# Expression-level preferences +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_object_initializer = true:suggestion +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion + +# Field preferences +dotnet_style_readonly_field = true:warning + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:suggestion + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +#### C# Coding Conventions #### +[*.cs] + +# var preferences +csharp_style_var_elsewhere = false:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_switch_expression = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# 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_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# '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 = one_less_than_current +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 #### +[*.{cs,vb}] + +# Naming rules + +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces +dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion +dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces +dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase + +dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion +dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters +dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase + +dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods +dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties +dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.events_should_be_pascalcase.symbols = events +dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables +dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase + +dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion +dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants +dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase + +dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion +dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters +dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase + +dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields +dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion +dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields +dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase + +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase + +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums +dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions +dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase + +# Symbol specifications + +dotnet_naming_symbols.interfaces.applicable_kinds = interface +dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interfaces.required_modifiers = + +dotnet_naming_symbols.enums.applicable_kinds = enum +dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.enums.required_modifiers = + +dotnet_naming_symbols.events.applicable_kinds = event +dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.events.required_modifiers = + +dotnet_naming_symbols.methods.applicable_kinds = method +dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.methods.required_modifiers = + +dotnet_naming_symbols.properties.applicable_kinds = property +dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.properties.required_modifiers = + +dotnet_naming_symbols.public_fields.applicable_kinds = field +dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_fields.required_modifiers = + +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_fields.required_modifiers = + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_fields.required_modifiers = static + +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types_and_namespaces.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +dotnet_naming_symbols.type_parameters.applicable_kinds = namespace +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters.required_modifiers = + +dotnet_naming_symbols.private_constant_fields.applicable_kinds = field +dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_constant_fields.required_modifiers = const + +dotnet_naming_symbols.local_variables.applicable_kinds = local +dotnet_naming_symbols.local_variables.applicable_accessibilities = local +dotnet_naming_symbols.local_variables.required_modifiers = + +dotnet_naming_symbols.local_constants.applicable_kinds = local +dotnet_naming_symbols.local_constants.applicable_accessibilities = local +dotnet_naming_symbols.local_constants.required_modifiers = const + +dotnet_naming_symbols.parameters.applicable_kinds = parameter +dotnet_naming_symbols.parameters.applicable_accessibilities = * +dotnet_naming_symbols.parameters.required_modifiers = + +dotnet_naming_symbols.public_constant_fields.applicable_kinds = field +dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_constant_fields.required_modifiers = const + +dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal +dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static + +dotnet_naming_symbols.local_functions.applicable_kinds = local_function +dotnet_naming_symbols.local_functions.applicable_accessibilities = * +dotnet_naming_symbols.local_functions.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascalcase.required_prefix = +dotnet_naming_style.pascalcase.required_suffix = +dotnet_naming_style.pascalcase.word_separator = +dotnet_naming_style.pascalcase.capitalization = pascal_case + +dotnet_naming_style.ipascalcase.required_prefix = I +dotnet_naming_style.ipascalcase.required_suffix = +dotnet_naming_style.ipascalcase.word_separator = +dotnet_naming_style.ipascalcase.capitalization = pascal_case + +dotnet_naming_style.tpascalcase.required_prefix = T +dotnet_naming_style.tpascalcase.required_suffix = +dotnet_naming_style.tpascalcase.word_separator = +dotnet_naming_style.tpascalcase.capitalization = pascal_case + +dotnet_naming_style._camelcase.required_prefix = _ +dotnet_naming_style._camelcase.required_suffix = +dotnet_naming_style._camelcase.word_separator = +dotnet_naming_style._camelcase.capitalization = camel_case + +dotnet_naming_style.camelcase.required_prefix = +dotnet_naming_style.camelcase.required_suffix = +dotnet_naming_style.camelcase.word_separator = +dotnet_naming_style.camelcase.capitalization = camel_case + +dotnet_naming_style.s_camelcase.required_prefix = s_ +dotnet_naming_style.s_camelcase.required_suffix = +dotnet_naming_style.s_camelcase.word_separator = +dotnet_naming_style.s_camelcase.capitalization = camel_case + +# Xml project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] +indent_size = 2 + +[*.{csproj,vbproj,proj,nativeproj,locproj}] +charset = utf-8 + +# Xml build files +[*.builds] +indent_size = 2 + +# Xml files +[*.{xml,stylecop,resx,ruleset}] +indent_size = 2 + +# Xml config files +[*.{props,targets,config,nuspec}] +indent_size = 2 + +# YAML config files +[*.{yml,yaml}] +indent_size = 2 + +# Shell scripts +[*.sh] +end_of_line = lf +[*.{cmd,bat}] +end_of_line = crlf diff --git a/.gitignore b/.gitignore index 188918b..05b81fb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .ionide/ App_Data/ packages/ +package/ obj/ bin/ build/ diff --git a/Directory.Build.props b/Directory.Build.props index cfdabf4..f927eb1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,38 +1,25 @@ - - net6.0 - + + Allegro + Allegro + © Allegro. All rights reserved. + $(MSBuildProjectName) + Allegro + LICENSE + README.md + true + - - AnyCPU - AnyCPU - prompt - true - - true - false - latest - enable - disable - false - $(NoWarn);NU5128;SA0001 - true - + + + + + + - - $(MSBuildThisFileDirectory)\bin\$(MSBuildProjectName) - $(MSBuildThisFileDirectory)\obj\$(MSBuildProjectName) - $(MSBuildThisFileDirectory)\nuget - $(MSBuildThisFileDirectory)\bin\$(MSBuildProjectName)\$(Configuration)\$(TargetFramework)\$(MSBuildProjectName).xml - + + + - - Allegro - Allegro - © Allegro. All rights reserved. - $(MSBuildProjectName) - Allegro - - \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets index 16f4b12..68ca924 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,13 +1,3 @@ - - - - - - + \ No newline at end of file diff --git a/README.md b/README.md index 68494b5..059a960 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ The Allegro .NET SDK provides common and importable project settings, such as build properties, coding styles, analyzers configuration etc. -The SDK is versioned and published on nuget It can be imported into dotnet projects. +The SDK is versioned and published on nuget. It can be imported into dotnet projects. ## Using the SDK -The SDK is meant to be easily importable - only a few initial config lines are required to bring its benefits. The SDK also makes it possible to override any of its default settings. +The SDK is meant to be easily importable - only a few initial config lines are required to bring its benefits. The SDK also makes it possible to override any of its default settings. Version 2+ will work only with .NET SDK v8+. ## Importing @@ -27,18 +27,19 @@ It's necessary to include `Allegro.DotnetSdk` with the desired version in `globa "rollForward": "latestFeature" }, "msbuild-sdks": { - "Allegro.DotnetSdk": "1.2.0" + "Allegro.DotnetSdk": "2.0.0" } } ``` + ### Directory.Build.props The `Directory.Build.props` file should be updated in order to actually import the SDK: ```xml - + $(NetCoreVersions) @@ -47,60 +48,48 @@ The `Directory.Build.props` file should be updated in order to actually import t ``` -### Directory.Build.targets - -The `Directory.Build.targets` file should be updated in order to actually import the SDK: - -```xml - - - - - -``` - -### Analyzers - -The SDK imports and configures several external analyzers - StyleCop, AsyncFixer, Meziantou. - -The existing analyzer package reference sections should be removed from `paket.dependencies` and `paket.references`. If they're not removed, the build may fail because of duplicated package references. +## Project settings -## Overriding +Most properties are only set in the SDK if not configured by the project. -The imported properties can be overridden per repo or per project. +To configure the SDK, the following properties can be added into `Directory.Build.props` or `.csproj` files: -## Project settings +- `AllegroDotnetSdkEnableXmlDocAdjustments` (default: true) - enable doc file generation, suppress missing-comments warning (1591) - completely in test projects, as errors otherwise (keep as warning). +- `TreatWarningsAsErrors` (default: true in CI and Rider IDE) +- `UseAllegroDotnetSdkDefaultAnalyzers` (default: true when no CPM) - reference and configure several external analyzers - StyleCop, AsyncFixer, Meziantou. +- `AllegroDotnetSdkEnableGlobalEditorConfig` (default: true) - add `editorconfig.global` analyzer configuration file. +- `AllegroDotnetSdkEnableImplicitUsingsAdjustments` (default: true) - add `System.Collections.Immutable` and remove `Microsoft.Extensions.Logging` and `System.Net.Http` implicit usings. +- `AllegroDotnetSdkEnableAsyncFixer` (default: `UseAllegroDotnetSdkDefaultAnalyzers`) - references AsyncFixer package. +- `AllegroDotnetSdkEnableMeziantou` (default: `UseAllegroDotnetSdkDefaultAnalyzers`) - references Meziantou.Analyzers package. +- `AllegroDotnetSdkEnableStyleCop` (default: `UseAllegroDotnetSdkDefaultAnalyzers`) - references StyleCop.Analyzers package. -In order to override or disable some of the imported components, the behavior changing properties can be added into `Directory.Build.props` or `.csproj` files. +Configure in `Directory.Build.props` - repo wide: -* `Directory.Build.props` - repo wide: ```xml - - - $(NetCoreVersions) - + + - disable - + disable + false - - + ``` -* `.csproj` - project settings: +Configure in `*.csproj` - project settings: + ```xml + - Exe - true + + false - ``` @@ -117,6 +106,7 @@ More about the analyzer and editor config files can be found in [the docs](https ### Rider Make sure you have enabled: + - Preferences -> Editor -> Code Style -> Enable StyleCop support (Ruleset files) - Preferences -> Editor -> Code Style -> Enable EditorConfig support - Preferences -> Editor -> Inspection Settings -> Read settings from editorconfig, project settings and rule sets @@ -125,9 +115,11 @@ Make sure you have enabled: **Be aware!** Only some analyzers's warnings can be addressed by auto-format or code cleanup. Some of the warnings are not covered by Rider, and its settings need to be adjusted. -For that, in editor.globalconfig is `# ReSharper properties` section with some already defined settings which align with analyzers. If you find some inconsistency and you find appropriate settings in Rider, which will fix it - please, contribute! :) +For that, in editor.globalconfig is `# ReSharper properties` section with some already defined settings which align with analyzers. If you find some inconsistency and you find appropriate settings in Rider, which will fix it - please, contribute! :) + ## License -Copyright 2022 Allegro Group + +Copyright Allegro Group Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/src/Allegro.DotnetSdk/Allegro.DotnetSdk.csproj b/src/Allegro.DotnetSdk/Allegro.DotnetSdk.csproj index 1bcceba..626b1b0 100644 --- a/src/Allegro.DotnetSdk/Allegro.DotnetSdk.csproj +++ b/src/Allegro.DotnetSdk/Allegro.DotnetSdk.csproj @@ -1,13 +1,21 @@ - + net6.0 - build\ + 2.0.0 + true + true true MSBuildSdk - Allegro Dotnet SDK - MSBuild MSBuildSdk - true - 1.2.2 + Allegro Dotnet SDK + $(Tags) MSBuild MSBuildSdk + false + + $(NoWarn);NU5128 + + + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Sdk.props b/src/Allegro.DotnetSdk/Sdk/Sdk.props index b254d9e..73d08d2 100644 --- a/src/Allegro.DotnetSdk/Sdk/Sdk.props +++ b/src/Allegro.DotnetSdk/Sdk/Sdk.props @@ -1,85 +1,27 @@ - - net6.0 - netstandard2.0;netstandard2.1 - $(NetCoreVersions);$(NetStandardVersions) - $(NetCoreVersions) - - - - latest - Recommended - latest - true - enable - enable - - false - - true - - - - + + + true - - $([MSBuild]::GetDirectoryNameOfFileAbove('$(MSBuildProjectDirectory)', 'global.json')) - $(RepoRoot)\bin\$(MSBuildProjectName) - $(RepoRoot)\obj\$(MSBuildProjectName) - $(RepoRoot)\nuget - - - - - - all - runtime; build; native; contentfiles; analyzers - - + + $(CustomAfterDirectoryBuildProps);$(MSBuildThisFileDirectory)UseAllegroDotnetSdkDefaults.props + + $(CustomBeforeDirectoryBuildTargets);$(MSBuildThisFileDirectory)UseAllegroDotnetSdkDefaults.targets + - - - all - runtime; build; native; contentfiles; analyzers - - - - - - all - runtime; build; native; contentfiles; analyzers - - + + + net6.0 + - - - all - runtime; compile; build; native; contentfiles; analyzers - - - - - - - - - - - - $(NoWarn);CA1707 - - - - true - - true - - - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - true - snupkg - - \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Sdk.targets b/src/Allegro.DotnetSdk/Sdk/Sdk.targets index af0bd8d..3249eaa 100644 --- a/src/Allegro.DotnetSdk/Sdk/Sdk.targets +++ b/src/Allegro.DotnetSdk/Sdk/Sdk.targets @@ -1,17 +1,9 @@ - - + + + + + - - - - - \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.props b/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.props new file mode 100644 index 0000000..a5a56c7 --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.props @@ -0,0 +1,41 @@ + + + + + true + + + + latest + enable + enable + + + + latest-Recommended + true + + true + + true + + true + + + + + true + + + $(WarningsNotAsErrors);CS1591 + + + + + + $(NoWarn);CA1707 + + $(NoWarn);CS1591 + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets b/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets new file mode 100644 index 0000000..9a763f6 --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets @@ -0,0 +1,45 @@ + + + + + + true + true + true + + + + true + true + true + + + + true + + true + + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + true + snupkg + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/UseDefaultAnalyzers.targets b/src/Allegro.DotnetSdk/Sdk/UseDefaultAnalyzers.targets new file mode 100644 index 0000000..00a29a2 --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/UseDefaultAnalyzers.targets @@ -0,0 +1,27 @@ + + + + + + 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/src/Allegro.DotnetSdk/Sdk/editor.globalconfig b/src/Allegro.DotnetSdk/Sdk/editor.globalconfig index af03faf..4d986ad 100644 --- a/src/Allegro.DotnetSdk/Sdk/editor.globalconfig +++ b/src/Allegro.DotnetSdk/Sdk/editor.globalconfig @@ -436,12 +436,3 @@ dotnet_diagnostic.MA0056.severity = suggestion # MA0074: Avoid implicit culture-sensitive methods dotnet_diagnostic.MA0074.severity = suggestion - -# Use the return value or discard -dotnet_diagnostic.CSE005.severity = none - -# Untangle complex expressions -dotnet_diagnostic.CSE006.severity = none - -# Handle disposal properly -dotnet_diagnostic.CSE007.severity = none diff --git a/src/package.build.props b/src/package.build.props deleted file mode 100644 index ac86205..0000000 --- a/src/package.build.props +++ /dev/null @@ -1,20 +0,0 @@ - - - - net6.0 - Allegro - Allegro - Copyright 2022 Allegro Group - Apache-2.0 - https://github.com/allegro/dotnet-sdk - README.md - true - snupkg - - - - - - - - \ No newline at end of file