Skip to content

Commit

Permalink
Fix release diagnostics warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrstenke committed Jan 4, 2025
1 parent 16f04e2 commit 8c99683
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 262 deletions.
250 changes: 6 additions & 244 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,248 +1,10 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
[*.cs]
root = true
[*.{cs,vb}]

# C# files
[*.cs]

#### Core EditorConfig Options ####

# Indentation and spacing
indent_style = tab

# New line preferences
end_of_line = crlf
insert_final_newline = false

#### .NET Coding Conventions ####

file_header_template = Copyright (c) Piotr Stenke. All rights reserved.\nLicensed under the MIT license.

# Organize usings
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true

# this. and Me. preferences
dotnet_style_qualification_for_event = false : suggestion
dotnet_style_qualification_for_field = false : suggestion
dotnet_style_qualification_for_method = false : suggestion
dotnet_style_qualification_for_property = false : suggestion

# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true : suggestion
dotnet_style_predefined_type_for_member_access = true : suggestion

# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity : suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity : suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary : suggestion
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity : suggestion

# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members : warning

# 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_prefer_auto_properties = true : suggestion
dotnet_style_prefer_compound_assignment = true : suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true : none
dotnet_style_prefer_conditional_expression_over_return = true : none
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 : warning
dotnet_style_prefer_simplified_interpolation = true : suggestion

# Field preferences
dotnet_style_readonly_field = true : warning

# Parameter preferences
dotnet_code_quality_unused_parameters = all : warning

# Suppression preferences
dotnet_remove_unnecessary_suppression_exclusions = none

#### C# Coding Conventions ####

# var preferences
csharp_style_var_elsewhere = false : suggestion
csharp_style_var_for_built_in_types = false : suggestion
csharp_style_var_when_type_is_apparent = false : suggestion

# Expression-bodied members
csharp_style_expression_bodied_accessors = true : none
csharp_style_expression_bodied_constructors = false : none
csharp_style_expression_bodied_indexers = true : none
csharp_style_expression_bodied_lambdas = true : none
csharp_style_expression_bodied_local_functions = false : none
csharp_style_expression_bodied_methods = false : none
csharp_style_expression_bodied_operators = false : none
csharp_style_expression_bodied_properties = true : none

# 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
csharp_style_prefer_switch_expression = true : suggestion

# Null-checking preferences
csharp_style_conditional_delegate_call = true : suggestion

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async : suggestion

# Code-block preferences
csharp_prefer_braces = true : warning
csharp_prefer_simple_using_statement = true : warning

# Expression-level preferences
csharp_prefer_simple_default_expression = true : suggestion
csharp_style_deconstructed_variable_declaration = true : suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true : suggestion
csharp_style_inlined_variable_declaration = true : suggestion
csharp_style_pattern_local_over_anonymous_function = true : warning
csharp_style_prefer_index_operator = false : none
csharp_style_prefer_range_operator = true : suggestion
csharp_style_throw_expression = false : suggestion
csharp_style_unused_value_assignment_preference = discard_variable : warning
csharp_style_unused_value_expression_statement_preference = discard_variable : none

# 'using' directive preferences
csharp_using_directive_placement = outside_namespace : suggestion

#### 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 = false
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 = false

#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_starts_with_i.severity = warning
dotnet_naming_rule.interface_should_be_starts_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_starts_with_i.style = starts_with_i

dotnet_naming_rule.non_private_constant_field_should_be_pascalcase.severity = warning
dotnet_naming_rule.non_private_constant_field_should_be_pascalcase.symbols = non_private_constant_field
dotnet_naming_rule.non_private_constant_field_should_be_pascalcase.style = pascalcase

dotnet_naming_rule.non_public_field_should_be__camelcase.severity = warning
dotnet_naming_rule.non_public_field_should_be__camelcase.symbols = non_public_field
dotnet_naming_rule.non_public_field_should_be__camelcase.style = _camelcase

dotnet_naming_rule.variable_should_be_camelcase.severity = warning
dotnet_naming_rule.variable_should_be_camelcase.symbols = variable
dotnet_naming_rule.variable_should_be_camelcase.style = camelcase

dotnet_naming_rule.member_should_be_pascalcase.severity = warning
dotnet_naming_rule.member_should_be_pascalcase.symbols = member
dotnet_naming_rule.member_should_be_pascalcase.style = pascalcase

# Symbol specifications

dotnet_naming_symbols.member.applicable_kinds = namespace, property, field, event, class, struct, interface, enum, delegate, method, local_function
dotnet_naming_symbols.member.applicable_accessibilities = *

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = *

dotnet_naming_symbols.non_public_field.applicable_kinds = field
dotnet_naming_symbols.non_public_field.applicable_accessibilities = internal, private, private_protected, local

dotnet_naming_symbols.variable.applicable_kinds = field, parameter, local
dotnet_naming_symbols.variable.applicable_accessibilities = *

dotnet_naming_symbols.non_private_constant_field.applicable_kinds = field
dotnet_naming_symbols.non_private_constant_field.applicable_accessibilities = public, internal, protected, protected_internal, private_protected, local
dotnet_naming_symbols.non_private_constant_field.required_modifiers = const

# Naming styles

dotnet_naming_style.pascalcase.capitalization = pascal_case

dotnet_naming_style.starts_with_i.required_prefix = I
dotnet_naming_style.starts_with_i.capitalization = pascal_case

dotnet_naming_style.camelcase.capitalization = camel_case

dotnet_naming_style._camelcase.required_prefix = _
dotnet_naming_style._camelcase.capitalization = camel_case

# RCS1146: Use conditional access.
dotnet_diagnostic.RCS1146.severity = none

# RCS1123: Add parentheses when necessary.
dotnet_diagnostic.RCS1123.severity = none

# IDE0072: Remove unnecessary suppression
dotnet_diagnostic.IDE0079.severity = none


# RCS1096: Convert 'HasFlag' call to bitwise operation (or vice versa).
# RCS1096: Convert 'HasFlag' call to bitwise operation (or vice versa).
dotnet_diagnostic.RCS1096.severity = none
dotnet_diagnostic.RCS1096.severity = none

# RCS1180: Inline lazy initialization.
dotnet_diagnostic.RCS1180.severity = none

# IDE0078: Use pattern matching
dotnet_diagnostic.IDE0078.severity = none

# RCS1124: Inline local variable.
dotnet_diagnostic.RCS1124.severity = none
dotnet_diagnostic.IDE0073.severity=warning
# IDE0270: Use coalesce expression
dotnet_diagnostic.IDE0270.severity = none

# IDE0150: Prefer 'null' check over type check
csharp_style_prefer_null_check_over_type_check = false
dotnet_diagnostic.IDE0150.severity = none

# RS2003: Shipped diagnostic IDs that are no longer reported should have an entry in the 'Removed Rules' table in unshipped file
dotnet_diagnostic.RS2003.severity = none
# IDE0074: Use compound assignment
dotnet_diagnostic.IDE0074.severity = none
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<LangVersion>9</LangVersion>
<PreferredUILang>en-US</PreferredUILang>
<NeutralLanguage>en</NeutralLanguage>
<NoWarn>RS2003</NoWarn>

</PropertyGroup>

Expand Down
11 changes: 0 additions & 11 deletions src/Durian.AnalysisServices/DurianGeneratorBase.diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ public abstract partial class DurianGeneratorBase
{
#region Diagnostics copied from Durian.Core.Analyzer

#pragma warning disable IDE1006 // Naming Styles

private static readonly DiagnosticDescriptor DUR0001_ProjectMustReferenceDurianCore = new(
#pragma warning restore IDE1006 // Naming Styles
#pragma warning disable RS2008 // Enable analyzer release tracking
id: "DUR0001",
#pragma warning restore RS2008 // Enable analyzer release tracking
title: "Projects with any Durian analyzer must reference the Durian.Core package",
messageFormat: "Projects with any Durian analyzer must reference the Durian.Core package",
category: "Durian",
Expand All @@ -25,13 +20,8 @@ public abstract partial class DurianGeneratorBase
isEnabledByDefault: true
);

#pragma warning disable IDE1006 // Naming Styles

private static readonly DiagnosticDescriptor DUR0004_DurianModulesAreValidOnlyInCSharp = new(
#pragma warning restore IDE1006 // Naming Styles
#pragma warning disable RS2008 // Enable analyzer release tracking
id: "DUR0004",
#pragma warning restore RS2008 // Enable analyzer release tracking
title: "Durian modules can be used only in C#",
messageFormat: "Durian modules can be used only in C#",
category: "Durian",
Expand All @@ -41,6 +31,5 @@ public abstract partial class DurianGeneratorBase
);

#endregion Diagnostics copied from Durian.Core.Analyzer

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ ISymbolOrMember root
/// <inheritdoc/>
private protected override bool IsHandledExternally(int level)
{
#pragma warning disable CS0618 // Type or member is obsolete
LeveledSymbolContainer<TParentSymbol, TParentData>.InnerContainer container = (ParentContainer.ResolveLevel(level) as LeveledSymbolContainer<TParentSymbol, TParentData>.InnerContainer)!;
#pragma warning restore CS0618 // Type or member is obsolete

LeveledSymbolContainer<TParentSymbol, TParentData>.LevelEntry levelEntry = ParentContainer._levels[level];
List<ISymbolOrMember<TParentSymbol, TParentData>> baseList = ParentContainer._data;

Expand Down
File renamed without changes.
7 changes: 3 additions & 4 deletions src/Durian.InterfaceTargets/Durian.InterfaceTargets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ Do not reference this package if the main Durian package is already referenced.

</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
</ItemGroup>

<ItemGroup>

<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.1.0" PrivateAssets="all" />

<ProjectReference Include="..\Durian.AnalysisServices\Durian.AnalysisServices.csproj" PrivateAssets="all" />

<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />

<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(OutputPath)\Durian.Core.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(OutputPath)\Durian.AnalysisServices.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
Expand Down

0 comments on commit 8c99683

Please sign in to comment.