diff --git a/.editorconfig b/.editorconfig index 9896049..19e562e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,64 +1,59 @@ root = true -# All files +# ============================================================ +# ALL FILES +# ============================================================ [*] indent_style = space -# Xml files +# ============================================================ +# XML FILES +# ============================================================ [*.xml] indent_size = 2 -# Xml project files [*.{csproj,fsproj,vbproj,proj,slnx}] indent_size = 2 -# Xml config files [*.{props,targets,config,nuspec}] indent_size = 2 +# ============================================================ +# JSON FILES +# ============================================================ [*.json] indent_size = 2 -# C# files -[*.cs] - -#### Core EditorConfig Options #### - -# Indentation and spacing -indent_size = 4 -tab_width = 4 - -# New line preferences -insert_final_newline = false - -#### .NET Coding Conventions #### +# ============================================================ +# C# AND VB FILES — SHARED .NET CONVENTIONS +# ============================================================ [*.{cs,vb}] -# Organize usings +#### Organize Usings #### dotnet_separate_import_directive_groups = true dotnet_sort_system_directives_first = true file_header_template = unset -# this. and Me. preferences +#### 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 +#### Language Keywords vs BCL Types #### dotnet_style_predefined_type_for_locals_parameters_members = true:silent dotnet_style_predefined_type_for_member_access = true:silent -# Parentheses preferences +#### 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 +#### Modifier Preferences #### dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent -# Expression-level preferences +#### Expression-Level Preferences #### dotnet_style_coalesce_expression = true:suggestion dotnet_style_collection_initializer = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion @@ -78,129 +73,30 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggesti dotnet_style_prefer_simplified_boolean_expressions = true:suggestion dotnet_style_prefer_simplified_interpolation = true:suggestion -# Field preferences +#### Field Preferences #### dotnet_style_readonly_field = true:warning -# Parameter preferences +#### Parameter Preferences #### dotnet_code_quality_unused_parameters = all:suggestion -# Suppression preferences +#### Suppression Preferences #### dotnet_remove_unnecessary_suppression_exclusions = none -#### C# Coding Conventions #### -[*.cs] +#### Diagnostics #### +dotnet_diagnostic.IDE0005.severity = warning # Remove unused usings +dotnet_diagnostic.IDE0073.severity = none # File header not required +dotnet_diagnostic.SA1600.severity = warning # Elements should be documented +dotnet_diagnostic.SA1623.severity = none # Property summary text +dotnet_diagnostic.SA1624.severity = none # Property summary text +dotnet_diagnostic.SA1633.severity = none # File header not required +dotnet_diagnostic.SA1642.severity = suggestion # Constructor summary text -# 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_extended_property_pattern = 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_anonymous_function = true:suggestion -csharp_prefer_static_local_function = true:warning -csharp_preferred_modifier_order = public,private,protected,internal,file,const,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion -csharp_style_prefer_readonly_struct = true:suggestion -csharp_style_prefer_readonly_struct_member = true:suggestion - -# Code-block preferences -csharp_prefer_braces = true:silent -csharp_prefer_simple_using_statement = true:suggestion -csharp_style_namespace_declarations = file_scoped:suggestion -csharp_style_prefer_method_group_conversion = true:silent -csharp_style_prefer_primary_constructors = true:suggestion -csharp_style_prefer_top_level_statements = true:silent - -# 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_prefer_index_operator = true:suggestion -csharp_style_prefer_local_over_anonymous_function = true:suggestion -csharp_style_prefer_null_check_over_type_check = true:suggestion -csharp_style_prefer_range_operator = true:suggestion -csharp_style_prefer_tuple_swap = true:suggestion -csharp_style_prefer_utf8_string_literals = 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 #### +# ============================================================ +# NAMING RULES +# ============================================================ [*.{cs,vb}] -# Naming rules - +## 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 @@ -225,6 +121,38 @@ 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.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.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.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_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.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.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_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 @@ -237,38 +165,6 @@ 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 @@ -277,67 +173,35 @@ 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 +## Symbol Specifications ## +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.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.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 = +# NOTE: was previously misconfigured as 'namespace' kind — corrected to 'type_parameter' +dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters.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.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.properties.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.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_fields.required_modifiers = dotnet_naming_symbols.public_constant_fields.applicable_kinds = field dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal @@ -347,57 +211,193 @@ 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_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.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.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.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.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.local_functions.applicable_kinds = local_function dotnet_naming_symbols.local_functions.applicable_accessibilities = * -dotnet_naming_symbols.local_functions.required_modifiers = +dotnet_naming_symbols.local_functions.required_modifiers = -# Naming styles +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_style.pascalcase.required_prefix = -dotnet_naming_style.pascalcase.required_suffix = -dotnet_naming_style.pascalcase.word_separator = +## Naming Styles ## dotnet_naming_style.pascalcase.capitalization = pascal_case +dotnet_naming_style.pascalcase.required_prefix = +dotnet_naming_style.pascalcase.required_suffix = +dotnet_naming_style.pascalcase.word_separator = -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.ipascalcase.required_prefix = I +dotnet_naming_style.ipascalcase.required_suffix = +dotnet_naming_style.ipascalcase.word_separator = -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.tpascalcase.required_prefix = T +dotnet_naming_style.tpascalcase.required_suffix = +dotnet_naming_style.tpascalcase.word_separator = -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.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.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 +dotnet_naming_style.s_camelcase.required_prefix = s_ +dotnet_naming_style.s_camelcase.required_suffix = +dotnet_naming_style.s_camelcase.word_separator = -dotnet_diagnostic.SA1623.severity = none -dotnet_diagnostic.SA1624.severity = none - -dotnet_diagnostic.SA1600.severity = suggestion - +# ============================================================ +# C# FILES ONLY +# ============================================================ [*.cs] -# 1. Tell the .NET Formatter to stop injecting a header -file_header_template = unset -# 2. Tell StyleCop to stop requiring a file header (SA1633) -dotnet_diagnostic.SA1633.severity = none +#### Core EditorConfig Options #### +indent_size = 4 +tab_width = 4 +insert_final_newline = false -# 3. Tell the IDE to stop requiring a file header (IDE0073) -dotnet_diagnostic.IDE0073.severity = none \ No newline at end of file +#### 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_extended_property_pattern = 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_anonymous_function = true:suggestion +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,file,const,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion + +#### Code-Block Preferences #### +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = file_scoped:suggestion +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_top_level_statements = true:silent + +#### 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_prefer_index_operator = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = 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 = inside_namespace:warning + +#### Formatting — 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 + +#### Formatting — 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 + +#### Formatting — 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 + +#### Formatting — Wrapping Preferences #### +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +# ============================================================ +# TEST PROJECTS — RELAXED RULES +# ============================================================ +[*.Tests/**/*.cs] +dotnet_diagnostic.SA1600.severity = none \ No newline at end of file diff --git a/.gitea/workflows/pr-endpoint-check.yml b/.gitea/workflows/pr-endpoint-check.yml index 427f687..1aba34b 100644 --- a/.gitea/workflows/pr-endpoint-check.yml +++ b/.gitea/workflows/pr-endpoint-check.yml @@ -13,19 +13,29 @@ jobs: - name: Configure appsettings for CI run: | - # Find the appsettings.json file APPSETTINGS_PATH="Webzine.WebApplication/appsettings.json" - - # Backup original file cp $APPSETTINGS_PATH $APPSETTINGS_PATH.bak - - # Use jq to modify the JSON jq '.UseDatabase = true | .IsSQLite = true' $APPSETTINGS_PATH > $APPSETTINGS_PATH.tmp mv $APPSETTINGS_PATH.tmp $APPSETTINGS_PATH - echo "Updated appsettings.json:" cat $APPSETTINGS_PATH + - name: Cache .NET SDK + uses: actions/cache@v3 + with: + path: | + ~/.dotnet + /usr/share/dotnet + key: ${{ runner.os }}-dotnet-10.0.x + + - name: Cache NuGet packages + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: Setup .NET 10 uses: actions/setup-dotnet@v4 with: @@ -65,24 +75,22 @@ jobs: chmod +x scripts/test-endpoints.sh bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 | tee /tmp/webzine_endpoint_output.txt EXIT_CODE=${PIPESTATUS[0]} - - # Count failures + FAIL_COUNT=$(grep -cE "^\[ÉCHEC\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0) SLOW_COUNT=$(grep -cE "^\[LENT\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0) - + echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT" echo "slow=$SLOW_COUNT" >> "$GITHUB_OUTPUT" - - # Échoue s’il y a DES problèmes (échecs OU lents) + if [ $FAIL_COUNT -gt 0 ] || [ $SLOW_COUNT -gt 0 ]; then echo "❌ Performance check failed: $FAIL_COUNT endpoint(s) failed, $SLOW_COUNT endpoint(s) exceeded threshold (1000ms)" exit 1 fi - + echo "✅ All endpoints passed performance check (< 1000ms)" - name: Post performance report as PR comment - if: always() # Always post comment, even on failure + if: always() env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_SERVER_URL: ${{ gitea.server_url }} @@ -92,20 +100,15 @@ jobs: RAW_REPORT=$(cat /tmp/webzine_endpoint_output.txt 2>/dev/null || echo "Aucune sortie capturée.") FAILED_COUNT="${{ steps.perf_test.outputs.failed }}" SLOW_COUNT="${{ steps.perf_test.outputs.slow }}" - - # Determine if the check passed or failed + if [ "$FAILED_COUNT" -gt 0 ] || [ "$SLOW_COUNT" -gt 0 ]; then STATUS_HEADER="❌ **PERFORMANCE CHECK FAILED**" - STATUS_ICON="❌" else STATUS_HEADER="✅ **PERFORMANCE CHECK PASSED**" - STATUS_ICON="✅" fi - - # Convert report to Markdown with colors + CLEAN_REPORT=$(echo "$RAW_REPORT" | sed 's/\x1b\[[0-9;]*m//g') - - # Generate formatted report + FORMATTED_REPORT=$(echo "$CLEAN_REPORT" | sed \ -e 's/^\[OK\] /✅ /' \ -e 's/^\[LENT\] /⚠️ /' \ @@ -120,23 +123,16 @@ jobs: -e 's/^\(⚠️ ENDPOINTS LENTS.*\)$/\n### \1/' \ -e 's/^\(❌ ENDPOINTS EN ÉCHEC.*\)$/\n### \1/' \ -e 's/^\(La PR doit.*\)$/\n**❌ \1**/') - + BODY=$(cat </dev/null || echo 0) - - ⚠️ Endpoints lents (>1000ms): $SLOW_COUNT - - ❌ Endpoints en échec: $FAILED_COUNT - + **Vérifié par**: Workflow PR Endpoint Performance EOF ) - + curl -s -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ diff --git a/Webzine.WebApplication/Dockerfile b/Dockerfile similarity index 88% rename from Webzine.WebApplication/Dockerfile rename to Dockerfile index 3211249..bd375cc 100644 --- a/Webzine.WebApplication/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ EXPOSE 8081 FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src -COPY ["Webzine.WebApplication/Webzine.WebApplication.csproj", "Webzine.WebApplication/"] +COPY ["./Webzine.WebApplication/Webzine.WebApplication.csproj", "Webzine.WebApplication/"] RUN dotnet restore "Webzine.WebApplication/Webzine.WebApplication.csproj" COPY . . WORKDIR "/src/Webzine.WebApplication" diff --git a/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md b/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md index 9d202cb..ee3333a 100644 --- a/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md +++ b/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md @@ -8,9 +8,10 @@ ## Table des modifications -| Date | Auteur | -|------|--------| +| Date | Auteur | +| ----- | ------------- | | 25/03 | Clément Bobin | +| 31/03 | Joséphine Vetu | --- @@ -18,12 +19,12 @@ Avant de lancer l'application, assurez-vous d'avoir installé les outils suivants : -| Outil | Version minimale | Lien | -|-------|-----------------|------| -| .NET SDK | 10.0 | https://dotnet.microsoft.com/download | -| Node.js (optionnel, pour outils front) | 18+ | https://nodejs.org | -| Git | 2.x | https://git-scm.com | -| Un IDE | Visual Studio 2022+ ou Rider | — | +| Outil | Version minimale | Lien | +| -------------------------------------- | ---------------------------- | ------------------------------------- | +| .NET SDK | 10.0 | https://dotnet.microsoft.com/download | +| Node.js (optionnel, pour outils front) | 18+ | https://nodejs.org | +| Git | 2.x | https://git-scm.com | +| Un IDE | Visual Studio 2022+ ou Rider | — | --- @@ -65,6 +66,7 @@ dotnet run ``` L'application est accessible par défaut à : + - **HTTP :** http://localhost:5038 - **HTTPS :** https://localhost:7095 @@ -89,10 +91,10 @@ Le fichier principal de configuration est `Webzine.WebApplication/appsettings.js } ``` -| Propriété | Type | Description | Valeur par défaut | -|-----------|------|-------------|-------------------| -| `NombreDerniereChronique` | int | Nombre de chroniques affichées sur la page d'accueil (section "Derniers titres") | 3 | -| `NombreDeTopTitres` | int | Nombre de titres affichés dans le bloc "Titres les plus populaires" | 3 | +| Propriété | Type | Description | Valeur par défaut | +| ------------------------- | ---- | -------------------------------------------------------------------------------- | ----------------- | +| `NombreDerniereChronique` | int | Nombre de chroniques affichées sur la page d'accueil (section "Derniers titres") | 3 | +| `NombreDeTopTitres` | int | Nombre de titres affichés dans le bloc "Titres les plus populaires" | 3 | Ces valeurs sont injectées dans `AccueilController` via `IConfiguration` et peuvent être modifiées sans recompilation. @@ -106,14 +108,15 @@ La configuration du logging se trouve dans `Webzine.WebApplication/nlog.config`. Les logs sont écrits dans le dossier `/Logs/` avec deux fichiers : -| Fichier | Contenu | -|---------|---------| +| Fichier | Contenu | +| --------------------- | ----------------------------------------------------- | | `nlog-all-{date}.log` | Tous les logs (Debug et supérieur pour l'application) | -| `nlog-own-{date}.log` | Logs applicatifs avec URL de la requête | +| `nlog-own-{date}.log` | Logs applicatifs avec URL de la requête | Les logs de la console sont également activés, utiles lors du développement. **Niveaux configurés :** + - `Webzine.WebApplication.*` → Debug et supérieur - `Microsoft.*` → Warning et supérieur (pour réduire le bruit) - `Microsoft.Hosting.Lifetime*` → Info (pour voir le démarrage de l'appli) @@ -143,18 +146,18 @@ Les tests vérifient les contraintes de validation (annotations DataAnnotations) ## 8. Routes principales -| URL | Contrôleur | Description | -|-----|-----------|-------------| -| `/` | `AccueilController.Index` | Page d'accueil | -| `/artiste/{nom}` | `ArtisteController.Index` | Page d'un artiste | -| `/titre/{id}` | `TitreController.Details` | Détail d'un titre | -| `/titre/style/{style}` | `TitreController.Style` | Titres par style | -| `/recherche` (POST) | `RechercheController.Index` | Résultats de recherche | -| `/Administration/Dashboard` | `DashboardController.Index` | Tableau de bord admin | -| `/Administration/Artiste` | `ArtisteController` (admin) | Gestion des artistes | -| `/Administration/Titre` | `TitreController` (admin) | Gestion des titres | -| `/Administration/Style` | `StyleController` | Gestion des styles | -| `/Administration/Commentaire` | `CommentaireController` | Gestion des commentaires | +| URL | Contrôleur | Description | +| ----------------------------- | --------------------------- | ------------------------ | +| `/` | `AccueilController.Index` | Page d'accueil | +| `/artiste/{nom}` | `ArtisteController.Index` | Page d'un artiste | +| `/titre/{id}` | `TitreController.Details` | Détail d'un titre | +| `/titre/style/{style}` | `TitreController.Style` | Titres par style | +| `/recherche` (POST) | `RechercheController.Index` | Résultats de recherche | +| `/Administration/Dashboard` | `DashboardController.Index` | Tableau de bord admin | +| `/Administration/Artiste` | `ArtisteController` (admin) | Gestion des artistes | +| `/Administration/Titre` | `TitreController` (admin) | Gestion des titres | +| `/Administration/Style` | `StyleController` | Gestion des styles | +| `/Administration/Commentaire` | `CommentaireController` | Gestion des commentaires | --- @@ -168,4 +171,14 @@ En production, positionner : export ASPNETCORE_ENVIRONMENT=Production ``` -Cela désactive les pages d'erreur détaillées et active les optimisations de performance ASP.NET Core. \ No newline at end of file +Cela désactive les pages d'erreur détaillées et active les optimisations de performance ASP.NET Core. + +## Ajout du pre-commit + +Les fichiers présents dans le dossier git_hooks sont à copier dans le dossier caché .git. +Le pre-commit reformatte le code à chaque commit. +Le commit-msg vérifie si le message du commit respecte bien les conventions du cahier des charges: + +- le message référence un ticket +- le message termine par un point +- le message doit faire au moins 10 caractères diff --git a/Webzine.Documentation/StyleCop/stylecop.json b/Webzine.Documentation/StyleCop/stylecop.json index b387567..52ce63b 100644 --- a/Webzine.Documentation/StyleCop/stylecop.json +++ b/Webzine.Documentation/StyleCop/stylecop.json @@ -2,14 +2,8 @@ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "settings": { "documentationRules": { - "documentInterfaces": false, - "documentInternalElements": false, - "documentExposedElements": false - }, - "maintainabilityRules": { - "settings": { - "commonWords": [ "Obtient", "définit" ] - } + "companyName": "Equipe 1 - BOBIN, MASI, NODON, VETU", + "documentationCulture": "fr-FR" + } } } -} diff --git a/Webzine.Documentation/git_hooks/commit-msg b/Webzine.Documentation/git_hooks/commit-msg new file mode 100644 index 0000000..eb15525 --- /dev/null +++ b/Webzine.Documentation/git_hooks/commit-msg @@ -0,0 +1,24 @@ +#!/bin/sh + +# Hook: commit-msg +# Validates the commit message format. +# Git passes the path to the temp message file as $1. + +COMMIT_MSG=$(cat "$1") + +if [ ${#COMMIT_MSG} -le 10 ]; then + echo "❌ Erreur : Le message doit faire plus de 10 caractères." + exit 1 +fi + +if ! echo "$COMMIT_MSG" | grep -q "\.$"; then + echo "❌ Erreur : Le commit doit se terminer par un point." + exit 1 +fi + +if ! echo "$COMMIT_MSG" | grep -q "#[0-9]\+"; then + echo "❌ Erreur : Vous devez faire référence à un ticket (ex: #123)." + exit 1 +fi + +exit 0 diff --git a/Webzine.Documentation/git_hooks/pre-commit b/Webzine.Documentation/git_hooks/pre-commit new file mode 100644 index 0000000..5473d88 --- /dev/null +++ b/Webzine.Documentation/git_hooks/pre-commit @@ -0,0 +1,21 @@ +#!/bin/sh + +# Hook: pre-commit +# Runs dotnet format on staged files, then verifies documentation warnings. + +echo "🔧 Running dotnet format..." +dotnet format --severity warn +if [ $? -ne 0 ]; then + echo "❌ Erreur : dotnet format a échoué." + exit 1 +fi +git add -u + +echo "📄 Vérification de la documentation..." +dotnet format style --severity warn --verify-no-changes +if [ $? -ne 0 ]; then + echo "❌ Erreur : Documentation manquante (classes/méthodes non commentées)." + exit 1 +fi + +exit 0 diff --git a/Webzine.Entity.Tests/.editorconfig b/Webzine.Entity.Tests/.editorconfig new file mode 100644 index 0000000..c148d4b --- /dev/null +++ b/Webzine.Entity.Tests/.editorconfig @@ -0,0 +1,2 @@ +[*.cs] +dotnet_diagnostic.SA1600.severity = none \ No newline at end of file diff --git a/Webzine.Repository.Contracts/IArtisteRepository.cs b/Webzine.Repository.Contracts/IArtisteRepository.cs index 1ab6e83..bc13f76 100644 --- a/Webzine.Repository.Contracts/IArtisteRepository.cs +++ b/Webzine.Repository.Contracts/IArtisteRepository.cs @@ -44,5 +44,12 @@ namespace Webzine.Repository.Contracts /// /// L'artiste à mettre à jour. void Update(Artiste artiste); + + /// + /// Récupérer une liste d'artiste à partir d'une recherche. + /// + /// Nom de l'artiste. + /// IEnumarble. qui contient la chaine de caractere. + IEnumerable Search(string nom); } } \ No newline at end of file diff --git a/Webzine.Repository/DbArtisteRepository.cs b/Webzine.Repository/DbArtisteRepository.cs index 404f7bf..c27c1d7 100644 --- a/Webzine.Repository/DbArtisteRepository.cs +++ b/Webzine.Repository/DbArtisteRepository.cs @@ -4,8 +4,6 @@ namespace Webzine.Repository { - using System.Data.Common; - using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -85,8 +83,8 @@ namespace Webzine.Repository try { Artiste artiste = this.context.Artistes - .Include(a => a.Titres) - .First(a => a.IdArtiste == id); + .Include(a => a.Titres) + .FirstOrDefault(a => a.IdArtiste == id); return artiste; } catch (Exception ex) @@ -120,7 +118,7 @@ namespace Webzine.Repository try { // .AsNoTracking() rend la requête beaucoup plus rapide pour de la lecture - var artistes = this.context.Artistes.AsNoTracking().ToList(); + var artistes = this.context.Artistes.AsNoTracking().Include(t => t.Titres).ToList(); this.logger.LogDebug("{Count} artistes récupérés de la base.", artistes.Count); return artistes; } @@ -156,5 +154,27 @@ namespace Webzine.Repository throw; } } + + /// + public IEnumerable Search(string mot) + { + try + { + // Récupération des artistes et des titres + // qui leurs sont associés. + // ajout de 'ToLower' pour ne pas être sensible à la casse. + // NoTracking car action de lecture seulement. + var artiste = this.context.Artistes + .Where(a => a.Nom.ToLower().Contains(mot.ToLower())) + .Include(t => t.Titres) + .AsNoTracking() + .ToList(); + return artiste; + } + catch (Exception ex) + { + throw new Exception("Erreur lors de la recherche d'artiste {error}", ex); + } + } } } \ No newline at end of file diff --git a/Webzine.Repository/DbStyleRepository.cs b/Webzine.Repository/DbStyleRepository.cs index 6d8350b..c350a4f 100644 --- a/Webzine.Repository/DbStyleRepository.cs +++ b/Webzine.Repository/DbStyleRepository.cs @@ -1,11 +1,12 @@ +namespace Webzine.Repository; + using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; + using Webzine.EntitiesContext; using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les styles en utilisant une base de données. /// diff --git a/Webzine.Repository/DbTitreRepository.cs b/Webzine.Repository/DbTitreRepository.cs index 20b90fd..ab362b9 100644 --- a/Webzine.Repository/DbTitreRepository.cs +++ b/Webzine.Repository/DbTitreRepository.cs @@ -1,11 +1,12 @@ +namespace Webzine.Repository; + using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; + using Webzine.EntitiesContext; using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les titres en utilisant une base de données. /// @@ -242,6 +243,7 @@ public class DbTitreRepository : ITitreRepository .Include(t => t.Styles) .Where(t => t.Libelle.ToLower().Contains(mot.ToLower())) .OrderBy(t => t.Libelle) + .AsNoTracking() .ToList(); this.logger.LogDebug("{Count} titres trouvés correspondant à '{Mot}'", titres.Count, mot); @@ -260,15 +262,13 @@ public class DbTitreRepository : ITitreRepository try { this.logger.LogDebug("Recherche du titre avec l'ID: {IdTitre}", idTitre); - this.logger.LogDebug("Préparation de la requête avec les inclusions Artiste, Styles et Commentaires"); var titre = this.context.Titres .Include(t => t.Artiste) .Include(t => t.Styles) .Include(t => t.Commentaires) - .First(t => t.IdTitre == idTitre); + .FirstOrDefault(t => t.IdTitre == idTitre); - this.logger.LogDebug("Titre trouvé: {Libelle}", titre.Libelle); return titre; } catch (InvalidOperationException ex) diff --git a/Webzine.Repository/LocalArtisteRepository.cs b/Webzine.Repository/LocalArtisteRepository.cs index 67ebabf..69021c5 100644 --- a/Webzine.Repository/LocalArtisteRepository.cs +++ b/Webzine.Repository/LocalArtisteRepository.cs @@ -85,5 +85,13 @@ namespace Webzine.Repository { throw new NotSupportedException("Mode Local"); } + + /// + public IEnumerable Search(string mot) + { + return this.dataStore.Artistes + .Where(a => a.Nom.ToLower().Contains(mot.ToLower())) + .ToList(); + } } } \ No newline at end of file diff --git a/Webzine.Repository/LocalStyleRepository.cs b/Webzine.Repository/LocalStyleRepository.cs index 02a033d..0b4d16c 100644 --- a/Webzine.Repository/LocalStyleRepository.cs +++ b/Webzine.Repository/LocalStyleRepository.cs @@ -1,9 +1,10 @@ +namespace Webzine.Repository; + using Microsoft.Extensions.Logging; + using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les styles en utilisant une liste locale comme source de données. /// diff --git a/Webzine.Repository/LocalTitreRepository.cs b/Webzine.Repository/LocalTitreRepository.cs index 741bbc8..ff8832c 100644 --- a/Webzine.Repository/LocalTitreRepository.cs +++ b/Webzine.Repository/LocalTitreRepository.cs @@ -1,9 +1,10 @@ +namespace Webzine.Repository; + using Microsoft.Extensions.Logging; + using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les titres en utilisant une liste locale comme source de données. /// diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs index d9e2436..e6ad7e5 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs @@ -1,10 +1,11 @@ -using Microsoft.AspNetCore.Mvc; +namespace Webzine.WebApplication.Areas.Administration.Controllers; + +using Microsoft.AspNetCore.Mvc; + using Webzine.Entity; using Webzine.Repository.Contracts; using Webzine.WebApplication.Areas.Administration.ViewModels.Artiste; -namespace Webzine.WebApplication.Areas.Administration.Controllers; - /// /// Contrôleur pour la gestion des artistes dans l'administration du webzine. /// @@ -49,14 +50,37 @@ public class ArtisteController : Controller /// Redirection. public IActionResult Create() { - var model = new AdminArtisteForm + return this.View(); + } + + /// + /// Formulaire de création d'un artiste. + /// + /// Paramètre nécessaire pour la création d'un artiste. + /// Redirection sur la page Index. + [HttpPost] + public IActionResult Create(ArtisteCreateViewModel model) + { + // vérifier si les données sont corrects. + if (!this.ModelState.IsValid) { - Id = 0, - Nom = string.Empty, - Biographie = string.Empty, + // Passer model en paramètre afin que + // l'utilisateur conserve sa saissie. + return this.View(model); + } + + // Créer un objet Artiste avecc les paramètres. + var artiste = new Artiste + { + Nom = model.Nom, + Biographie = model.Biographie, }; - return this.View(model); + // Persister les données. + this.artisteRepository.Add(artiste); + + // Renvoyer sur la page Index. + return this.RedirectToAction("Index"); } /// @@ -68,14 +92,37 @@ public class ArtisteController : Controller { var artiste = this.artisteRepository.Find(id); - var model = new AdminArtisteForm + if (artiste == null) { - Id = artiste.IdArtiste, - Nom = artiste.Nom, - Biographie = artiste.Biographie, + return this.RedirectToAction("Index"); + } + + return this.View(artiste); + } + + /// + /// Traitement du formulaire de modification d'un artiste. + /// + /// Paramètre d'un artiste. + /// Redirection sur Index. + [HttpPost] + public IActionResult Edit(ArtisteEditViewModel model) + { + var artiste = new Artiste + { + IdArtiste = model.Id, + Nom = model.Nom, + Biographie = model.Biographie, }; - return this.View(model); + if (!this.ModelState.IsValid) + { + return this.View(artiste); + } + + this.artisteRepository.Update(artiste); + + return this.RedirectToAction("Index"); } /// @@ -86,6 +133,12 @@ public class ArtisteController : Controller public IActionResult Delete(int id) { var artiste = this.artisteRepository.Find(id); + + if (artiste == null) + { + return this.RedirectToAction("Index"); + } + var model = new AdminArtisteForm { Id = id, diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs index c60e9bd..b954e14 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs @@ -53,6 +53,11 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers { var commentaire = this.commentaireRepository.Find(id); + if (commentaire == null) + { + return this.RedirectToAction("Index"); + } + var model = new CommentaireDeleteViewModel { IdCommentaire = commentaire.IdCommentaire, diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs index e8e3d89..2f314ad 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs @@ -1,10 +1,10 @@ -using System.Diagnostics; +namespace Webzine.WebApplication.Areas.Administration.Controllers; + using Microsoft.AspNetCore.Mvc; + using Webzine.Repository.Contracts; using Webzine.WebApplication.Areas.Administration.ViewModels; -namespace Webzine.WebApplication.Areas.Administration.Controllers; - [Area("Administration")] public class DashboardController : Controller { diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs index e6741f9..1283fd0 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs @@ -1,109 +1,170 @@ -namespace Webzine.WebApplication.Areas.Administration.Controllers -{ - using Microsoft.AspNetCore.Mvc; +namespace Webzine.WebApplication.Areas.Administration.Controllers; - using Webzine.Repository.Contracts; - using Webzine.WebApplication.Areas.Administration.ViewModels.Style; +using Microsoft.AspNetCore.Mvc; + +using Webzine.Entity; +using Webzine.Repository.Contracts; +using Webzine.WebApplication.Areas.Administration.ViewModels.Style; + +/// +/// Controleur pour la gestion des styles dans l'administration du webzine. +/// +[Area("Administration")] +public class StyleController : Controller +{ + private readonly ILogger logger; + private readonly IStyleRepository styleRepository; /// - /// Contrôleur pour la gestion des styles dans l'administration du webzine. + /// Initializes a new instance of the class. /// - [Area("Administration")] - public class StyleController : Controller + /// Service de journalisation injecte. + /// Repository des styles injecte. + public StyleController( + ILogger logger, + IStyleRepository styleRepository) { - private readonly ILogger logger; - private readonly IStyleRepository styleRepository; + this.logger = logger; + this.styleRepository = styleRepository; - /// - /// Initializes a new instance of the class. - /// Initialise une nouvelle instance de la classe . - /// - /// Service de journalisation injecté. - /// Repository des styles injecté. - public StyleController( - ILogger logger, - IStyleRepository styleRepository) + this.logger.LogInformation("Initialisation du controleur StyleController."); + } + + /// + /// Affiche la liste des styles dans la vue Index. + /// + /// La vue Index avec la liste des styles. + public IActionResult Index() + { + IEnumerable