diff --git a/.editorconfig b/.editorconfig index 8acafa7..62bbf18 100644 --- a/.editorconfig +++ b/.editorconfig @@ -30,108 +30,232 @@ indent_size = 2 [*.{cs,csx,vb,vbx}] indent_size = 4 insert_final_newline = false -############################### -# .NET Coding Conventions # -############################### -[*.{cs,vb}] + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +# end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + # Organize usings -dotnet_sort_system_directives_first = true -# this. preferences -dotnet_style_qualification_for_field = false:silent -dotnet_style_qualification_for_property = false:silent -dotnet_style_qualification_for_method = false:silent -dotnet_style_qualification_for_event = false:silent +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + # 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 +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + # Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_relational_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_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + # Modifier preferences -dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent -dotnet_style_readonly_field = true:suggestion +dotnet_style_require_accessibility_modifiers = for_non_interface_members + # Expression-level preferences -dotnet_style_object_initializer = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_null_propagation = true:suggestion -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent -dotnet_style_prefer_inferred_tuple_names = true:suggestion -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_auto_properties = true:silent -dotnet_style_prefer_conditional_expression_over_assignment = true:silent -dotnet_style_prefer_conditional_expression_over_return = true:silent -############################### -# Naming Conventions # -############################### -# Style Definitions -dotnet_naming_style.pascal_case_style.capitalization = pascal_case -# Use PascalCase for constant fields -dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields -dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style -dotnet_naming_symbols.constant_fields.applicable_kinds = field -dotnet_naming_symbols.constant_fields.applicable_accessibilities = * -dotnet_naming_symbols.constant_fields.required_modifiers = const -############################### -# C# Coding Conventions # -############################### -[*.cs] +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_collection_expression = when_types_loosely_match +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:silent + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C# Coding Conventions #### + # var preferences -csharp_style_var_for_built_in_types = true:silent -csharp_style_var_when_type_is_apparent = true:silent -csharp_style_var_elsewhere = true:silent +csharp_style_var_elsewhere = true +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true + # Expression-bodied members -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + # Pattern matching preferences -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + # Null-checking preferences -csharp_style_throw_expression = true:suggestion -csharp_style_conditional_delegate_call = true:suggestion +csharp_style_conditional_delegate_call = true + # Modifier preferences -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true +csharp_style_prefer_readonly_struct_member = true + +# Code-block preferences +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_style_namespace_declarations = file_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_primary_constructors = true +csharp_style_prefer_top_level_statements = true + # Expression-level preferences -csharp_prefer_braces = true:silent -csharp_style_deconstructed_variable_declaration = true:suggestion -csharp_prefer_simple_default_expression = true:suggestion -csharp_style_prefer_local_over_anonymous_function = true:suggestion -csharp_style_inlined_variable_declaration = true:suggestion -############################### -# C# Formatting Rules # -############################### +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + # New line preferences -csharp_new_line_before_open_brace = all -csharp_new_line_before_else = true csharp_new_line_before_catch = true +csharp_new_line_before_else = true csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = 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 -csharp_indent_labels = flush_left + # 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_before_colon_in_inheritance_clause = true -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_around_binary_operators = before_and_after -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_square_brackets = false + # Wrapping preferences -csharp_preserve_single_line_statements = true csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..e5ff3f8 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,48 @@ + + + true + false + $(NoWarn);NU1507 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Readme.md b/Readme.md index b12a549..0b04aa5 100644 --- a/Readme.md +++ b/Readme.md @@ -72,4 +72,3 @@ TDB * You have Docker installed - ideally latest version of the tool. * You have .NET 8 installed (SDK and runtime). * Visual Studio or JetBrains Rider or Visual Studio Code as IDE - one of them, better for you, all them is appropriate. -* \ No newline at end of file diff --git a/SimpleServicesDashboard.sln b/SimpleServicesDashboard.sln index 52b8de1..8ef9993 100644 --- a/SimpleServicesDashboard.sln +++ b/SimpleServicesDashboard.sln @@ -1,20 +1,29 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleServicesDashboard.Api", "src\SimpleServicesDashboard.Api\SimpleServicesDashboard.Api.csproj", "{F98ED69A-9575-4A09-B057-B4777D1CEA2B}" +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35208.52 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleServicesDashboard.Api", "src\SimpleServicesDashboard.Api\SimpleServicesDashboard.Api.csproj", "{F98ED69A-9575-4A09-B057-B4777D1CEA2B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{71B651C8-3952-45CE-88EE-FA92ACC91260}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{266B464D-79A9-442F-A321-844DA6BDB1F0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleServicesDashboard.Common", "src\SimpleServicesDashboard.Common\SimpleServicesDashboard.Common.csproj", "{5BBBDDAE-7A70-47DB-A8F6-2C0D4F9B719A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleServicesDashboard.Common", "src\SimpleServicesDashboard.Common\SimpleServicesDashboard.Common.csproj", "{5BBBDDAE-7A70-47DB-A8F6-2C0D4F9B719A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleServicesDashboard.Application", "src\SimpleServicesDashboard.Application\SimpleServicesDashboard.Application.csproj", "{42D8E9FB-7EDF-448E-A798-E9C474C47A73}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleServicesDashboard.Application", "src\SimpleServicesDashboard.Application\SimpleServicesDashboard.Application.csproj", "{42D8E9FB-7EDF-448E-A798-E9C474C47A73}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleServicesDashboard.Infrastructure", "src\SimpleServicesDashboard.Infrastructure\SimpleServicesDashboard.Infrastructure.csproj", "{8A38D3A0-38FF-4B61-A9CC-3B97182C18A3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleServicesDashboard.Infrastructure", "src\SimpleServicesDashboard.Infrastructure\SimpleServicesDashboard.Infrastructure.csproj", "{8A38D3A0-38FF-4B61-A9CC-3B97182C18A3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleServicesDashboard.Infrastructure.Models", "src\SimpleServicesDashboard.Infrastructure.Models\SimpleServicesDashboard.Infrastructure.Models.csproj", "{F5DEFFA1-774F-44F0-9FC8-9190D2F5AFC9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleServicesDashboard.Infrastructure.Models", "src\SimpleServicesDashboard.Infrastructure.Models\SimpleServicesDashboard.Infrastructure.Models.csproj", "{F5DEFFA1-774F-44F0-9FC8-9190D2F5AFC9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleServicesDashboard.Application.Tests", "tests\SimpleServicesDashboard.Application.Tests\SimpleServicesDashboard.Application.Tests.csproj", "{B0440C2C-55C4-4276-BA6A-F09CF89E9B28}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleServicesDashboard.Application.Tests", "tests\SimpleServicesDashboard.Application.Tests\SimpleServicesDashboard.Application.Tests.csproj", "{B0440C2C-55C4-4276-BA6A-F09CF89E9B28}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2F89E0BD-D325-4A27-8966-3280F860FB7C}" + ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + Directory.Packages.props = Directory.Packages.props + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,6 +56,9 @@ Global {B0440C2C-55C4-4276-BA6A-F09CF89E9B28}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0440C2C-55C4-4276-BA6A-F09CF89E9B28}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection GlobalSection(NestedProjects) = preSolution {F98ED69A-9575-4A09-B057-B4777D1CEA2B} = {71B651C8-3952-45CE-88EE-FA92ACC91260} {5BBBDDAE-7A70-47DB-A8F6-2C0D4F9B719A} = {71B651C8-3952-45CE-88EE-FA92ACC91260} @@ -55,4 +67,7 @@ Global {F5DEFFA1-774F-44F0-9FC8-9190D2F5AFC9} = {71B651C8-3952-45CE-88EE-FA92ACC91260} {B0440C2C-55C4-4276-BA6A-F09CF89E9B28} = {266B464D-79A9-442F-A321-844DA6BDB1F0} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5402085B-5010-4627-8D80-C9D87F9F9162} + EndGlobalSection EndGlobal diff --git a/src/SimpleServicesDashboard.Api/Controllers/BaseApiController.cs b/src/SimpleServicesDashboard.Api/Controllers/BaseApiController.cs index 29ad4e6..1d3efc8 100644 --- a/src/SimpleServicesDashboard.Api/Controllers/BaseApiController.cs +++ b/src/SimpleServicesDashboard.Api/Controllers/BaseApiController.cs @@ -1,7 +1,7 @@ -using System.Threading.Tasks; using AutoMapper; using MediatR; using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Api.Controllers; diff --git a/src/SimpleServicesDashboard.Api/Controllers/ServiceStatusController.cs b/src/SimpleServicesDashboard.Api/Controllers/ServiceStatusController.cs index cf5cfcc..0bc16f1 100644 --- a/src/SimpleServicesDashboard.Api/Controllers/ServiceStatusController.cs +++ b/src/SimpleServicesDashboard.Api/Controllers/ServiceStatusController.cs @@ -1,4 +1,3 @@ -using System.Threading.Tasks; using Asp.Versioning; using AutoMapper; using MediatR; @@ -7,6 +6,7 @@ using SimpleServicesDashboard.Application.DTOs; using SimpleServicesDashboard.Application.Modules.ServiceStatus.Queries; using Swashbuckle.AspNetCore.Annotations; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Api.Controllers; diff --git a/src/SimpleServicesDashboard.Api/Controllers/StatusController.cs b/src/SimpleServicesDashboard.Api/Controllers/StatusController.cs index b721511..b734c92 100644 --- a/src/SimpleServicesDashboard.Api/Controllers/StatusController.cs +++ b/src/SimpleServicesDashboard.Api/Controllers/StatusController.cs @@ -1,4 +1,3 @@ -using System.Threading.Tasks; using Asp.Versioning; using AutoMapper; using MediatR; @@ -7,6 +6,7 @@ using SimpleServicesDashboard.Application.DTOs; using SimpleServicesDashboard.Application.Modules.Status.Queries; using Swashbuckle.AspNetCore.Annotations; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Api.Controllers; diff --git a/src/SimpleServicesDashboard.Api/Infrastructure/Configuration/ConfigureSwaggerOptions.cs b/src/SimpleServicesDashboard.Api/Infrastructure/Configuration/ConfigureSwaggerOptions.cs index d7c1b96..0c0a620 100644 --- a/src/SimpleServicesDashboard.Api/Infrastructure/Configuration/ConfigureSwaggerOptions.cs +++ b/src/SimpleServicesDashboard.Api/Infrastructure/Configuration/ConfigureSwaggerOptions.cs @@ -1,9 +1,9 @@ -using System; using Asp.Versioning.ApiExplorer; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; +using System; namespace SimpleServicesDashboard.Api.Infrastructure.Configuration; diff --git a/src/SimpleServicesDashboard.Api/Infrastructure/Extensions/ServiceCollectionExtensions.cs b/src/SimpleServicesDashboard.Api/Infrastructure/Extensions/ServiceCollectionExtensions.cs index 5266357..1d18b10 100644 --- a/src/SimpleServicesDashboard.Api/Infrastructure/Extensions/ServiceCollectionExtensions.cs +++ b/src/SimpleServicesDashboard.Api/Infrastructure/Extensions/ServiceCollectionExtensions.cs @@ -1,9 +1,3 @@ -using System; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Text.Json.Serialization; -using System.Text.RegularExpressions; using Asp.Versioning; using Hellang.Middleware.ProblemDetails; using Microsoft.AspNetCore.Hosting; @@ -22,6 +16,12 @@ using SimpleServicesDashboard.Common.Extensions; using SimpleServicesDashboard.Infrastructure; using Swashbuckle.AspNetCore.SwaggerGen; +using System; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; using ProblemDetailsOptions = Hellang.Middleware.ProblemDetails.ProblemDetailsOptions; namespace SimpleServicesDashboard.Api.Infrastructure.Extensions; diff --git a/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/HealthCheckExtensions.cs b/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/HealthCheckExtensions.cs index fe7d741..1b44ce4 100644 --- a/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/HealthCheckExtensions.cs +++ b/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/HealthCheckExtensions.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using SimpleServicesDashboard.Common.Configuration; +using System.Collections.Generic; namespace SimpleServicesDashboard.Api.Infrastructure.HealthCheck; @@ -11,10 +11,10 @@ namespace SimpleServicesDashboard.Api.Infrastructure.HealthCheck; public static class HealthCheckExtensions { public static IHealthChecksBuilder AddMemoryHealthCheck(this IHealthChecksBuilder builder, HealthStatus? failureStatus = null, - IEnumerable tags = default, long? thresholdInBytes = null) + IEnumerable? tags = default, long? thresholdInBytes = null) { // Register a check of type GCInfo. - builder.AddCheck(MemoryHealthCheck.Name, failureStatus ?? HealthStatus.Degraded, tags); + builder.AddCheck(MemoryHealthCheck.Name, failureStatus ?? HealthStatus.Degraded, tags, timeout: null); // Configure named options to pass the threshold into the check. if (thresholdInBytes.HasValue) diff --git a/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/MemoryHealthCheck.cs b/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/MemoryHealthCheck.cs index 6cb9ad0..c0e41f6 100644 --- a/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/MemoryHealthCheck.cs +++ b/src/SimpleServicesDashboard.Api/Infrastructure/HealthCheck/MemoryHealthCheck.cs @@ -1,10 +1,10 @@ +using Microsoft.Extensions.Diagnostics.HealthChecks; +using Microsoft.Extensions.Options; +using SimpleServicesDashboard.Common.Configuration; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.Extensions.Options; -using SimpleServicesDashboard.Common.Configuration; namespace SimpleServicesDashboard.Api.Infrastructure.HealthCheck; diff --git a/src/SimpleServicesDashboard.Api/Infrastructure/Swagger/SwaggerDefaultValues.cs b/src/SimpleServicesDashboard.Api/Infrastructure/Swagger/SwaggerDefaultValues.cs index 233de2c..eef38d0 100644 --- a/src/SimpleServicesDashboard.Api/Infrastructure/Swagger/SwaggerDefaultValues.cs +++ b/src/SimpleServicesDashboard.Api/Infrastructure/Swagger/SwaggerDefaultValues.cs @@ -1,8 +1,8 @@ -using System.Linq; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; +using System.Linq; namespace SimpleServicesDashboard.Api.Infrastructure.Swagger; diff --git a/src/SimpleServicesDashboard.Api/Models/DashboardViewModel.cs b/src/SimpleServicesDashboard.Api/Models/DashboardViewModel.cs index 76a1b34..0ec32b7 100644 --- a/src/SimpleServicesDashboard.Api/Models/DashboardViewModel.cs +++ b/src/SimpleServicesDashboard.Api/Models/DashboardViewModel.cs @@ -5,35 +5,35 @@ namespace SimpleServicesDashboard.Api.Models; public sealed class DashboardViewModel { - public List Services { get; set; } + public required List Services { get; set; } - public Dictionary Environments { get; set; } + public required Dictionary Environments { get; set; } } public sealed class ServiceViewModel { - public string Code { get; set; } - public string Name { get; set; } + public required string Code { get; set; } + public required string Name { get; set; } - public Dictionary Environments { get; set; } + public required Dictionary Environments { get; set; } } public sealed class ServiceEnvironmentViewModel { - public string Name { get; set; } + public required string Name { get; set; } public DateTime Created { get; set; } - public string MachineName { get; set; } - public string EnvironmentName { get; set; } + public string? MachineName { get; set; } + public string? EnvironmentName { get; set; } public DateTime ReleaseDate { get; set; } public DateTime AppStartTime { get; set; } - public string Version { get; set; } - public string BaseUrl { get; set; } + public string? Version { get; set; } + public string? BaseUrl { get; set; } } public sealed class ServiceDetailsViewModel { - public string Code { get; set; } - public string Name { get; set; } - public string EnvironmentCode { get; set; } - public ServiceEnvironmentViewModel ServiceDetailsModel { get; set; } + public required string Code { get; set; } + public required string Name { get; set; } + public required string EnvironmentCode { get; set; } + public required ServiceEnvironmentViewModel ServiceDetailsModel { get; set; } } \ No newline at end of file diff --git a/src/SimpleServicesDashboard.Api/Models/ServiceStatusViewModel.cs b/src/SimpleServicesDashboard.Api/Models/ServiceStatusViewModel.cs index e8f78ab..f2a08e3 100644 --- a/src/SimpleServicesDashboard.Api/Models/ServiceStatusViewModel.cs +++ b/src/SimpleServicesDashboard.Api/Models/ServiceStatusViewModel.cs @@ -5,7 +5,10 @@ namespace SimpleServicesDashboard.Api.Models; /// public sealed class ServiceStatusViewModel { - public string? Url { get; set; } + public required string? AboutUrl { get; set; } + public required string? HealthUrl { get; set; } + public required string? HealthcheckDashboardUrl { get; set; } + public required string? SwaggerdUrl { get; set; } public string? ServiceName { get; set; } public string? Environment { get; set; } diff --git a/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml b/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml index 04d2372..3479fd9 100644 --- a/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml +++ b/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml @@ -14,7 +14,8 @@ - + +
diff --git a/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml.cs b/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml.cs index 9ab65f3..fe5e9ed 100644 --- a/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml.cs +++ b/src/SimpleServicesDashboard.Api/Pages/Dashboard.cshtml.cs @@ -1,10 +1,10 @@ -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Options; using SimpleServicesDashboard.Api.Models; using SimpleServicesDashboard.Application.Services.Interfaces; using SimpleServicesDashboard.Common.Configuration; +using System.Linq; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Api.Pages; @@ -37,12 +37,10 @@ private async Task CollectServicesDetails() { var details = await _servicesStatusService.GetServicesStatusAsync(); - var model = new DashboardViewModel(); - // build the model to prepare the data in the block on the page var servicesGroup = details.Statuses.GroupBy(x => x.Code); - model.Services = servicesGroup.Select(x => + var services = servicesGroup.Select(x => new ServiceViewModel { Code = x.Key, @@ -61,8 +59,12 @@ private async Task CollectServicesDetails() }).ToList(); // get environments configuration - model.Environments = _servicesConfiguration.Environments.ToDictionary(x => x.Code, x => x.Name); + var environments = _servicesConfiguration.Environments.ToDictionary(x => x.Code, x => x.Name); - return model; + return new DashboardViewModel + { + Services = services, + Environments = environments + }; } } \ No newline at end of file diff --git a/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml b/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml index 91d47d3..5f53201 100644 --- a/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml +++ b/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml @@ -15,7 +15,8 @@ - + +
@@ -25,24 +26,65 @@

Details about specific service. This details comes from the Status endpoint on the service and can be fetched for the each service. Here just to check if the service is working.

-
-
- - -
The URL to call the service to get the status (used here to fetch the data from the service).
+
+ +
+ +
The URL to call the service to get the status (used here to fetch the data from the service).
-
- +
+ Open +
+
+
+ +
+ +
The URL to get health of the service in general.
+
+
+ Open +
+
+
+ +
+ +
The URL to see healthcheck dashboard of the actual service.
+
+
+ Open +
+
+
+ +
+ +
The URL to see the Swagger UI with API documentation.
+
+
+ Open +
+
+
+ +
Environment name for the service details.
-
+
+
+
Details from the service in JSON (status endpoint result).
- Go back to the dashboard - +
+
diff --git a/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml.cs b/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml.cs index 13fceac..c404fda 100644 --- a/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml.cs +++ b/src/SimpleServicesDashboard.Api/Pages/ServiceStatus.cshtml.cs @@ -1,7 +1,7 @@ -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.RazorPages; using SimpleServicesDashboard.Api.Models; using SimpleServicesDashboard.Application.Services.Interfaces; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Api.Pages; @@ -30,7 +30,10 @@ private async Task CollectServiceStatus(string serviceCo var result = new ServiceStatusViewModel { - Url = serviceStatus.Url, + AboutUrl = serviceStatus.AboutUrl, + HealthUrl = serviceStatus.HealthUrl, + HealthcheckDashboardUrl = serviceStatus.HealthcheckDashboardUrl, + SwaggerdUrl = serviceStatus.SwaggerdUrl, ServiceName = serviceStatus.ServiceName, Environment = serviceStatus.Environment, StatusData = serviceStatus.JsonData diff --git a/src/SimpleServicesDashboard.Api/Pages/_ServiceDetails.cshtml b/src/SimpleServicesDashboard.Api/Pages/_ServiceDetails.cshtml index 073ffa6..7ab535c 100644 --- a/src/SimpleServicesDashboard.Api/Pages/_ServiceDetails.cshtml +++ b/src/SimpleServicesDashboard.Api/Pages/_ServiceDetails.cshtml @@ -11,7 +11,11 @@ else
Version: @Model.ServiceDetailsModel.Version
- BaseUrl: @Model.ServiceDetailsModel.BaseUrl + BaseUrl: + + @Model.ServiceDetailsModel.BaseUrl + +
Environment Config Name: @Model.ServiceDetailsModel.EnvironmentName
@@ -24,6 +28,8 @@ else App Start Time: @Model.ServiceDetailsModel.AppStartTime
} diff --git a/src/SimpleServicesDashboard.Api/Program.cs b/src/SimpleServicesDashboard.Api/Program.cs index 2762300..51e0f15 100644 --- a/src/SimpleServicesDashboard.Api/Program.cs +++ b/src/SimpleServicesDashboard.Api/Program.cs @@ -1,32 +1,86 @@ -using System.Threading.Tasks; +using Asp.Versioning.ApiExplorer; +using Hellang.Middleware.ProblemDetails; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; +using SimpleServicesDashboard.Api.Infrastructure.Extensions; +using SimpleServicesDashboard.Common.Extensions; -namespace SimpleServicesDashboard.Api; +var builder = WebApplication.CreateBuilder(); -public static class Program +// configure Serilog for logging +builder.Host.UseSerilog((context, loggerConfiguration) => { - public static async Task Main(string[] args) + loggerConfiguration.ReadFrom.Configuration(context.Configuration); +}); + +// configure application services +ConfigureServices(builder); + +// create the app to configure the middleware +var app = builder.Build(); + +// configure the web app middleware components +var apiVersionDescriptionProvider = app.Services.GetRequiredService(); +ConfigureApplication(app, builder.Environment, apiVersionDescriptionProvider); + +// run the application +await app.RunAsync(); +return; + +// Configure the DI and all services on the web application + +void ConfigureServices(WebApplicationBuilder builder) +{ + builder.Services.ConfigureApiService(builder.Configuration, builder.Environment, true); +} + +// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. +void ConfigureApplication(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider apiProvider) +{ + var healthCheckConfig = builder.Configuration.GetHealthCheckConfiguration(); + + // configure Forwarder headers for proxies and Load Balancers + app.ConfigureForwarderOptions(); + + if (!env.IsEnvironment("Local")) { - var host = CreateHostBuilder(args).Build(); - await host.RunAsync(); + // custom configuration for security headers (HSTS for 60 days) + app.ConfigureSecurityHeaders(); } - private static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .UseSerilog((context, loggerConfiguration) => - { - loggerConfiguration.ReadFrom.Configuration(context.Configuration); - }) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder - .ConfigureKestrel(options => - { - options.AddServerHeader = false; - }) - .UseIISIntegration() - .UseStartup(); - }); + // redirect to the HTTPS connection + app.UseHttpsRedirection(); + + // Add using ProblemDetail middleware to handle errors and use RFC7807 standard + app.UseProblemDetails(); + + // configure Swagger UI + app.ConfigureSwagger(apiProvider); + + // add logger for all requests in the web server + app.ConfigureSerilog(); + + // use default files + app.UseDefaultFiles(); + + // allow to use static files + app.UseStaticFiles(); + + // Use routing middleware to handle requests to the controllers + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + // add controllers endpoints + endpoints.MapControllers(); + + // add routing for the Razor pages + endpoints.MapRazorPages(); + + // add health checks endpoints and configurations + endpoints.AddHealthCheckEndpoints(healthCheckConfig); + }); } \ No newline at end of file diff --git a/src/SimpleServicesDashboard.Api/Properties/launchSettings.json b/src/SimpleServicesDashboard.Api/Properties/launchSettings.json index 894afc0..48b5d68 100644 --- a/src/SimpleServicesDashboard.Api/Properties/launchSettings.json +++ b/src/SimpleServicesDashboard.Api/Properties/launchSettings.json @@ -1,20 +1,6 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:40615", - "sslPort": 44360 - } - }, + "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Local" - } - }, "SimpleServicesDashboard.Api": { "commandName": "Project", "launchBrowser": true, @@ -22,7 +8,7 @@ "ASPNETCORE_ENVIRONMENT": "Local" }, "dotnetRunMessages": "true", - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "applicationUrl": "https://localhost:5601;http://localhost:5600" }, "Docker": { "commandName": "Docker", diff --git a/src/SimpleServicesDashboard.Api/SimpleServicesDashboard.Api.csproj b/src/SimpleServicesDashboard.Api/SimpleServicesDashboard.Api.csproj index ff6870a..02dfb8b 100644 --- a/src/SimpleServicesDashboard.Api/SimpleServicesDashboard.Api.csproj +++ b/src/SimpleServicesDashboard.Api/SimpleServicesDashboard.Api.csproj @@ -12,29 +12,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -58,8 +58,4 @@ - - - - diff --git a/src/SimpleServicesDashboard.Api/Startup.cs b/src/SimpleServicesDashboard.Api/Startup.cs deleted file mode 100644 index 4c1591b..0000000 --- a/src/SimpleServicesDashboard.Api/Startup.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Asp.Versioning.ApiExplorer; -using Hellang.Middleware.ProblemDetails; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using SimpleServicesDashboard.Api.Infrastructure.Extensions; -using SimpleServicesDashboard.Common.Extensions; - -namespace SimpleServicesDashboard.Api; - -/// -/// Startup class to configure the services and api middleware. -/// -public sealed class Startup -{ - /// - /// Configuration for application loaded from the files. - /// - private IConfiguration Configuration { get; } - - /// - /// Environment settings and configuration. - /// - private IWebHostEnvironment Environment { get; } - - public Startup(IConfiguration configuration, IWebHostEnvironment environment) - { - Configuration = configuration; - Environment = environment; - } - - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - services.ConfigureApiService(Configuration, Environment, true); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider apiProvider) - { - var healthCheckConfig = Configuration.GetHealthCheckConfiguration(); - - // configure Forwarder headers for proxies and Load Balancers - app.ConfigureForwarderOptions(); - - if (!env.IsEnvironment("Local")) - { - // custom configuration for security headers (HSTS for 60 days) - app.ConfigureSecurityHeaders(); - } - - // redirect to the HTTPS connection - app.UseHttpsRedirection(); - - // Add using ProblemDetail middleware to handle errors and use RFC7807 standard - app.UseProblemDetails(); - - // configure Swagger UI - app.ConfigureSwagger(apiProvider); - - // add logger for all requests in the web server - app.ConfigureSerilog(); - - // use default files - app.UseDefaultFiles(); - - // allow to use static files - app.UseStaticFiles(); - - // Use routing middleware to handle requests to the controllers - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - // add controllers endpoints - endpoints.MapControllers(); - - // add routing for the Razor pages - endpoints.MapRazorPages(); - - // add health checks endpoints and configurations - endpoints.AddHealthCheckEndpoints(healthCheckConfig); - }); - } -} \ No newline at end of file diff --git a/src/SimpleServicesDashboard.Api/appsettings.Development.json b/src/SimpleServicesDashboard.Api/appsettings.Development.json index 9e86d70..c313362 100644 --- a/src/SimpleServicesDashboard.Api/appsettings.Development.json +++ b/src/SimpleServicesDashboard.Api/appsettings.Development.json @@ -5,44 +5,6 @@ "EvaluationTimeInSeconds": 60, "MaximumHistoryEntriesPerEndpoint": 240 }, - "ServicesConfigurationOptions": { - "Environments" : [ - { - "Code": "dev", - "Name": "Development" - }, - { - "Code": "qa", - "Name": "QA" - }, - { - "Code": "prod", - "Name": "Production" - } - ], - "Services": [ - { - "Code": "email", - "Name": "Email Service", - "HealthEndpoint": "/health", - "AboutEndpoint": "/api/v1/status", - "Environments": [ - { - "Environment": "dev", - "BaseUrl": "https://emailservice-dev.azurewebsites.net" - }, - { - "Environment": "qa", - "BaseUrl": "https://emailservice-qa.azurewebsites.net" - }, - { - "Environment": "prod", - "BaseUrl": "https://emailservice.azurewebsites.net" - } - ] - } - ] - }, "Serilog": { "Using": ["Serilog.Sinks.Console"], "MinimumLevel": { diff --git a/src/SimpleServicesDashboard.Api/appsettings.Docker.json b/src/SimpleServicesDashboard.Api/appsettings.Docker.json index 5e6511e..68d64f6 100644 --- a/src/SimpleServicesDashboard.Api/appsettings.Docker.json +++ b/src/SimpleServicesDashboard.Api/appsettings.Docker.json @@ -5,44 +5,6 @@ "EvaluationTimeInSeconds": 60, "MaximumHistoryEntriesPerEndpoint": 240 }, - "ServicesConfigurationOptions": { - "Environments" : [ - { - "Code": "dev", - "Name": "Development" - }, - { - "Code": "qa", - "Name": "QA" - }, - { - "Code": "prod", - "Name": "Production" - } - ], - "Services": [ - { - "Code": "email", - "Name": "Email Service", - "HealthEndpoint": "/health", - "AboutEndpoint": "/api/v1/status", - "Environments": [ - { - "Environment": "dev", - "BaseUrl": "https://emailservice-dev.azurewebsites.net" - }, - { - "Environment": "qa", - "BaseUrl": "https://emailservice-qa.azurewebsites.net" - }, - { - "Environment": "prod", - "BaseUrl": "https://emailservice.azurewebsites.net" - } - ] - } - ] - }, "Serilog": { "Using": ["Serilog.Sinks.Console", "Serilog.Sinks.File"], "MinimumLevel": { diff --git a/src/SimpleServicesDashboard.Api/appsettings.Local.json b/src/SimpleServicesDashboard.Api/appsettings.Local.json index 1388096..38ee6ea 100644 --- a/src/SimpleServicesDashboard.Api/appsettings.Local.json +++ b/src/SimpleServicesDashboard.Api/appsettings.Local.json @@ -5,44 +5,6 @@ "EvaluationTimeInSeconds": 60, "MaximumHistoryEntriesPerEndpoint": 240 }, - "ServicesConfigurationOptions": { - "Environments" : [ - { - "Code": "dev", - "Name": "Development" - }, - { - "Code": "qa", - "Name": "QA" - }, - { - "Code": "prod", - "Name": "Production" - } - ], - "Services": [ - { - "Code": "email", - "Name": "Email Service", - "HealthEndpoint": "/health", - "AboutEndpoint": "/api/v1/status", - "Environments": [ - { - "Environment": "dev", - "BaseUrl": "https://emailservice-dev.azurewebsites.net" - }, - { - "Environment": "qa", - "BaseUrl": "https://emailservice-qa.azurewebsites.net" - }, - { - "Environment": "prod", - "BaseUrl": "https://emailservice.azurewebsites.net" - } - ] - } - ] - }, "Serilog": { "Using": ["Serilog.Sinks.Console", "Serilog.Sinks.File"], "MinimumLevel": { diff --git a/src/SimpleServicesDashboard.Api/appsettings.json b/src/SimpleServicesDashboard.Api/appsettings.json index 6b85907..f14c8d6 100644 --- a/src/SimpleServicesDashboard.Api/appsettings.json +++ b/src/SimpleServicesDashboard.Api/appsettings.json @@ -1,3 +1,43 @@ { - "AllowedHosts": "*" + "AllowedHosts": "*", + "ServicesConfigurationOptions": { + "Environments" : [ + { + "Code": "dev", + "Name": "Development" + }, + { + "Code": "qa", + "Name": "QA" + }, + { + "Code": "prod", + "Name": "Production" + } + ], + "Services": [ + { + "Code": "email", + "Name": "Email Service", + "HealthEndpoint": "/health", + "AboutEndpoint": "/api/v1/status", + "HealthcheckDashboardEndpoint": "/healthcheck-dashboard", + "SwaggerEndpoint": "/swagger", + "Environments": [ + { + "Environment": "dev", + "BaseUrl": "https://emailservice-dev.azurewebsites.net" + }, + { + "Environment": "qa", + "BaseUrl": "https://emailservice-qa.azurewebsites.net" + }, + { + "Environment": "prod", + "BaseUrl": "https://emailservice.azurewebsites.net" + } + ] + } + ] + } } \ No newline at end of file diff --git a/src/SimpleServicesDashboard.Api/wwwroot/ui/resources/1ae4e3706fe3f478fcc1.woff2 b/src/SimpleServicesDashboard.Api/wwwroot/ui/resources/1ae4e3706fe3f478fcc1.woff2 deleted file mode 100644 index 2b86ebf..0000000 Binary files a/src/SimpleServicesDashboard.Api/wwwroot/ui/resources/1ae4e3706fe3f478fcc1.woff2 and /dev/null differ diff --git a/src/SimpleServicesDashboard.Application/Common/Behaviours/LoggingBehaviour.cs b/src/SimpleServicesDashboard.Application/Common/Behaviours/LoggingBehaviour.cs index b0662dc..ed112dd 100644 --- a/src/SimpleServicesDashboard.Application/Common/Behaviours/LoggingBehaviour.cs +++ b/src/SimpleServicesDashboard.Application/Common/Behaviours/LoggingBehaviour.cs @@ -1,8 +1,8 @@ +using MediatR; +using Microsoft.Extensions.Logging; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using MediatR; -using Microsoft.Extensions.Logging; namespace SimpleServicesDashboard.Application.Common.Behaviours; diff --git a/src/SimpleServicesDashboard.Application/Common/Behaviours/UnhandledExceptionBehaviour.cs b/src/SimpleServicesDashboard.Application/Common/Behaviours/UnhandledExceptionBehaviour.cs index 47b4a95..c8625ca 100644 --- a/src/SimpleServicesDashboard.Application/Common/Behaviours/UnhandledExceptionBehaviour.cs +++ b/src/SimpleServicesDashboard.Application/Common/Behaviours/UnhandledExceptionBehaviour.cs @@ -1,8 +1,8 @@ +using MediatR; +using Microsoft.Extensions.Logging; using System; using System.Threading; using System.Threading.Tasks; -using MediatR; -using Microsoft.Extensions.Logging; namespace SimpleServicesDashboard.Application.Common.Behaviours; diff --git a/src/SimpleServicesDashboard.Application/Common/Behaviours/ValidationBehaviour.cs b/src/SimpleServicesDashboard.Application/Common/Behaviours/ValidationBehaviour.cs index f932b9d..c0d18f0 100644 --- a/src/SimpleServicesDashboard.Application/Common/Behaviours/ValidationBehaviour.cs +++ b/src/SimpleServicesDashboard.Application/Common/Behaviours/ValidationBehaviour.cs @@ -1,9 +1,9 @@ +using FluentValidation; +using MediatR; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using FluentValidation; -using MediatR; using ValidationException = SimpleServicesDashboard.Application.Common.Exceptions.ValidationException; namespace SimpleServicesDashboard.Application.Common.Behaviours; diff --git a/src/SimpleServicesDashboard.Application/Common/Exceptions/ValidationException.cs b/src/SimpleServicesDashboard.Application/Common/Exceptions/ValidationException.cs index 8455246..21e3b81 100644 --- a/src/SimpleServicesDashboard.Application/Common/Exceptions/ValidationException.cs +++ b/src/SimpleServicesDashboard.Application/Common/Exceptions/ValidationException.cs @@ -1,7 +1,7 @@ +using FluentValidation.Results; using System; using System.Collections.Generic; using System.Linq; -using FluentValidation.Results; namespace SimpleServicesDashboard.Application.Common.Exceptions; diff --git a/src/SimpleServicesDashboard.Application/Common/Processors/RequestLogger.cs b/src/SimpleServicesDashboard.Application/Common/Processors/RequestLogger.cs index 6a68878..c0d5ab1 100644 --- a/src/SimpleServicesDashboard.Application/Common/Processors/RequestLogger.cs +++ b/src/SimpleServicesDashboard.Application/Common/Processors/RequestLogger.cs @@ -1,8 +1,8 @@ +using MediatR.Pipeline; +using Microsoft.Extensions.Logging; using System; using System.Threading; using System.Threading.Tasks; -using MediatR.Pipeline; -using Microsoft.Extensions.Logging; namespace SimpleServicesDashboard.Application.Common.Processors; diff --git a/src/SimpleServicesDashboard.Application/Common/Processors/ResponseLogger.cs b/src/SimpleServicesDashboard.Application/Common/Processors/ResponseLogger.cs index 856a9dd..1c21e72 100644 --- a/src/SimpleServicesDashboard.Application/Common/Processors/ResponseLogger.cs +++ b/src/SimpleServicesDashboard.Application/Common/Processors/ResponseLogger.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading; -using System.Threading.Tasks; using MediatR; using MediatR.Pipeline; using Microsoft.Extensions.Logging; +using System; +using System.Threading; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Common.Processors; diff --git a/src/SimpleServicesDashboard.Application/Models/ServiceDescriptionResponse.cs b/src/SimpleServicesDashboard.Application/Models/ServiceDescriptionResponse.cs index a079761..5565de5 100644 --- a/src/SimpleServicesDashboard.Application/Models/ServiceDescriptionResponse.cs +++ b/src/SimpleServicesDashboard.Application/Models/ServiceDescriptionResponse.cs @@ -4,12 +4,12 @@ namespace SimpleServicesDashboard.Application.Models; public sealed class ServicesDescriptionResponse { - public List? ServicesInfo { get; set; } + public required List? ServicesInfo { get; set; } } public sealed class ServiceDescription { - public string? Name { get; set; } - public string? Code { get; set; } - public string? Environments { get; set; } + public required string Name { get; set; } + public required string Code { get; set; } + public required string Environments { get; set; } } \ No newline at end of file diff --git a/src/SimpleServicesDashboard.Application/Models/ServiceStatusResponse.cs b/src/SimpleServicesDashboard.Application/Models/ServiceStatusResponse.cs index e094d62..3a3d0bf 100644 --- a/src/SimpleServicesDashboard.Application/Models/ServiceStatusResponse.cs +++ b/src/SimpleServicesDashboard.Application/Models/ServiceStatusResponse.cs @@ -15,9 +15,9 @@ public ServicesStatusResponse() public sealed class ServiceStatusResponse { - public string? Name { get; set; } - public string? Code { get; set; } - public string? Environment { get; set; } + public required string Name { get; set; } + public required string Code { get; set; } + public required string Environment { get; set; } public DateTime Created { get; set; } @@ -32,7 +32,10 @@ public sealed class ServiceStatusResponse public sealed class ServiceDetailsResponse { - public string? Url { get; set; } + public string? AboutUrl { get; set; } + public string? HealthUrl { get; set; } + public string? HealthcheckDashboardUrl { get; set; } + public string? SwaggerdUrl { get; set; } public string? ServiceName { get; set; } public string? Environment { get; set; } public string? JsonData { get; set; } diff --git a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusByCodeQuery.cs b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusByCodeQuery.cs index 45ca0a4..2ea9d88 100644 --- a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusByCodeQuery.cs +++ b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusByCodeQuery.cs @@ -1,10 +1,10 @@ -using System.Threading; -using System.Threading.Tasks; using MediatR; using Microsoft.Extensions.Logging; using SimpleServicesDashboard.Application.Models; using SimpleServicesDashboard.Application.Services.Interfaces; using SimpleServicesDashboard.Common.Extensions; +using System.Threading; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Modules.ServiceStatus.Queries; diff --git a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusQuery.cs b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusQuery.cs index 601a842..a829ba2 100644 --- a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusQuery.cs +++ b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServiceStatusQuery.cs @@ -1,10 +1,10 @@ -using System.Threading; -using System.Threading.Tasks; using MediatR; using Microsoft.Extensions.Logging; using SimpleServicesDashboard.Application.Models; using SimpleServicesDashboard.Application.Services.Interfaces; using SimpleServicesDashboard.Common.Extensions; +using System.Threading; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Modules.ServiceStatus.Queries; diff --git a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesCodeEnvInfoQuery.cs b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesCodeEnvInfoQuery.cs index 1bb0f33..921e1b5 100644 --- a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesCodeEnvInfoQuery.cs +++ b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesCodeEnvInfoQuery.cs @@ -1,10 +1,10 @@ -using System.Threading; -using System.Threading.Tasks; using MediatR; using Microsoft.Extensions.Logging; using SimpleServicesDashboard.Application.Models; using SimpleServicesDashboard.Application.Services.Interfaces; using SimpleServicesDashboard.Common.Extensions; +using System.Threading; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Modules.ServiceStatus.Queries; diff --git a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesStatusQuery.cs b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesStatusQuery.cs index 796ff4b..3bba46f 100644 --- a/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesStatusQuery.cs +++ b/src/SimpleServicesDashboard.Application/Modules/ServiceStatus/Queries/GetServicesStatusQuery.cs @@ -1,10 +1,10 @@ -using System.Threading; -using System.Threading.Tasks; using MediatR; using Microsoft.Extensions.Logging; using SimpleServicesDashboard.Application.Models; using SimpleServicesDashboard.Application.Services.Interfaces; using SimpleServicesDashboard.Common.Extensions; +using System.Threading; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Modules.ServiceStatus.Queries; diff --git a/src/SimpleServicesDashboard.Application/Modules/Status/Queries/GetStatusQuery.cs b/src/SimpleServicesDashboard.Application/Modules/Status/Queries/GetStatusQuery.cs index cb3c698..15565a8 100644 --- a/src/SimpleServicesDashboard.Application/Modules/Status/Queries/GetStatusQuery.cs +++ b/src/SimpleServicesDashboard.Application/Modules/Status/Queries/GetStatusQuery.cs @@ -1,10 +1,10 @@ -using System.Threading; -using System.Threading.Tasks; using MediatR; using Microsoft.Extensions.Logging; using SimpleServicesDashboard.Application.Models; using SimpleServicesDashboard.Application.Services.Interfaces; using SimpleServicesDashboard.Common.Extensions; +using System.Threading; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Modules.Status.Queries; diff --git a/src/SimpleServicesDashboard.Application/ServiceCollectionExtensions.cs b/src/SimpleServicesDashboard.Application/ServiceCollectionExtensions.cs index c9a617f..1fdfaaa 100644 --- a/src/SimpleServicesDashboard.Application/ServiceCollectionExtensions.cs +++ b/src/SimpleServicesDashboard.Application/ServiceCollectionExtensions.cs @@ -1,10 +1,10 @@ -using System.Reflection; using FluentValidation; using MediatR; using Microsoft.Extensions.DependencyInjection; using SimpleServicesDashboard.Application.Common.Behaviours; using SimpleServicesDashboard.Application.Services; using SimpleServicesDashboard.Application.Services.Interfaces; +using System.Reflection; namespace SimpleServicesDashboard.Application; diff --git a/src/SimpleServicesDashboard.Application/Services/ApplicationStatusService.cs b/src/SimpleServicesDashboard.Application/Services/ApplicationStatusService.cs index 7174c08..e850bf2 100644 --- a/src/SimpleServicesDashboard.Application/Services/ApplicationStatusService.cs +++ b/src/SimpleServicesDashboard.Application/Services/ApplicationStatusService.cs @@ -1,9 +1,9 @@ -using System; -using System.Reflection; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using SimpleServicesDashboard.Application.Models; using SimpleServicesDashboard.Application.Services.Interfaces; +using System; +using System.Reflection; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Services; diff --git a/src/SimpleServicesDashboard.Application/Services/Interfaces/IApplicationStatusService.cs b/src/SimpleServicesDashboard.Application/Services/Interfaces/IApplicationStatusService.cs index 848651d..1e0b676 100644 --- a/src/SimpleServicesDashboard.Application/Services/Interfaces/IApplicationStatusService.cs +++ b/src/SimpleServicesDashboard.Application/Services/Interfaces/IApplicationStatusService.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using SimpleServicesDashboard.Application.Models; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Services.Interfaces; diff --git a/src/SimpleServicesDashboard.Application/Services/Interfaces/IServicesStatusService.cs b/src/SimpleServicesDashboard.Application/Services/Interfaces/IServicesStatusService.cs index 44795d1..8ce4e3f 100644 --- a/src/SimpleServicesDashboard.Application/Services/Interfaces/IServicesStatusService.cs +++ b/src/SimpleServicesDashboard.Application/Services/Interfaces/IServicesStatusService.cs @@ -1,5 +1,5 @@ -using System.Threading.Tasks; using SimpleServicesDashboard.Application.Models; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Services.Interfaces; diff --git a/src/SimpleServicesDashboard.Application/Services/ServicesStatusService.cs b/src/SimpleServicesDashboard.Application/Services/ServicesStatusService.cs index cf9e3e1..2449e8d 100644 --- a/src/SimpleServicesDashboard.Application/Services/ServicesStatusService.cs +++ b/src/SimpleServicesDashboard.Application/Services/ServicesStatusService.cs @@ -1,14 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using SimpleServicesDashboard.Application.Common.Interfaces; using SimpleServicesDashboard.Application.Models; using SimpleServicesDashboard.Application.Services.Interfaces; using SimpleServicesDashboard.Common.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Application.Services; @@ -102,10 +102,10 @@ public async Task GetServiceStatusAsync(string code, stri if (serviceEnvironment != null) { - var url = serviceEnvironment.BaseUrl + serviceConfiguration.AboutEndpoint; + var aboutUrl = serviceEnvironment.BaseUrl + serviceConfiguration.AboutEndpoint; return CheckServiceCode(serviceConfiguration.Code) - ? await BuildServiceResponseAsync(url, environment, serviceConfiguration.Name, serviceConfiguration.Code, serviceEnvironment.BaseUrl) + ? await BuildServiceResponseAsync(aboutUrl, environment, serviceConfiguration.Name, serviceConfiguration.Code, serviceEnvironment.BaseUrl) : BuildEmptyResult(serviceConfiguration, serviceEnvironment); } } @@ -124,10 +124,13 @@ public async Task GetServiceDetailsAsync(string code, st if (serviceEnvironment != null) { - var url = serviceEnvironment.BaseUrl + serviceConfiguration.AboutEndpoint; + var aboutUrl = serviceEnvironment.BaseUrl + serviceConfiguration.AboutEndpoint; + var healthUrl = serviceEnvironment.BaseUrl + serviceConfiguration.HealthEndpoint; + var healthcheckDashboardUrl = serviceEnvironment.BaseUrl + serviceConfiguration.HealthcheckDashboardEndpoint; + var swaggerUrl = serviceEnvironment.BaseUrl + serviceConfiguration.SwaggerEndpoint; return CheckServiceCode(serviceConfiguration.Code) - ? await BuildServiceDetailsResponseAsync(url, environmentName, serviceConfiguration.Name, serviceConfiguration.Code) + ? await BuildServiceDetailsResponseAsync(aboutUrl, healthUrl, healthcheckDashboardUrl, swaggerUrl, environmentName, serviceConfiguration.Name, serviceConfiguration.Code) : BuildEmptyServiceDetailsResult(serviceConfiguration, environmentName); } } @@ -161,8 +164,9 @@ private async Task> BuildServiceResponsesAsync(Servi foreach (var servicesConfigurationEnvironment in servicesConfiguration.Environments) { - var url = servicesConfigurationEnvironment.BaseUrl + servicesConfiguration.AboutEndpoint; - tasks.Add(BuildServiceResponseAsync(url, servicesConfigurationEnvironment.Environment, + var aboutUrl = servicesConfigurationEnvironment.BaseUrl + servicesConfiguration.AboutEndpoint; + + tasks.Add(BuildServiceResponseAsync(aboutUrl, servicesConfigurationEnvironment.Environment, servicesConfiguration.Name, servicesConfiguration.Code, servicesConfigurationEnvironment.BaseUrl)); } @@ -171,10 +175,10 @@ private async Task> BuildServiceResponsesAsync(Servi return taskResults.ToList(); } - private async Task BuildServiceResponseAsync(string url, string environment, string name, string code, string baseUrl) + private async Task BuildServiceResponseAsync(string aboutUrl, string environment, string name, string code, string baseUrl) { var serviceAccess = _serviceAccessFactory.GetServiceAccess(code); - var response = await serviceAccess.GetServiceStatus(url); + var response = await serviceAccess.GetServiceStatus(aboutUrl); if (response is not null) { @@ -196,14 +200,17 @@ private async Task BuildServiceResponseAsync(string url, return CreateDefaultResponse(code, name, environment); } - private async Task BuildServiceDetailsResponseAsync(string url, string environment, string name, string code) + private async Task BuildServiceDetailsResponseAsync(string aboutUrl, string healthUrl, string healthcheckDashboardUrl, string swaggerUrl, string environment, string name, string code) { var serviceAccess = _serviceAccessFactory.GetServiceAccess(code); - var result = await serviceAccess.GetServiceStatus(url); + var result = await serviceAccess.GetServiceStatus(aboutUrl); return new ServiceDetailsResponse { - Url = url, + AboutUrl = aboutUrl, + HealthUrl = healthUrl, + HealthcheckDashboardUrl = healthcheckDashboardUrl, + SwaggerdUrl = swaggerUrl, ServiceName = name, Environment = environment, JsonData = SerializeResultToJson(result) @@ -285,10 +292,13 @@ private static ServiceDetailsResponse BuildEmptyServiceDetailsResult(ServiceConf { return new ServiceDetailsResponse { - Url = "", + AboutUrl = string.Empty, + HealthUrl = string.Empty, + HealthcheckDashboardUrl = string.Empty, + SwaggerdUrl = string.Empty, ServiceName = serviceConfiguration.Name, Environment = environment, - JsonData = "" + JsonData = string.Empty }; } diff --git a/src/SimpleServicesDashboard.Application/SimpleServicesDashboard.Application.csproj b/src/SimpleServicesDashboard.Application/SimpleServicesDashboard.Application.csproj index ac811a8..7e97c73 100644 --- a/src/SimpleServicesDashboard.Application/SimpleServicesDashboard.Application.csproj +++ b/src/SimpleServicesDashboard.Application/SimpleServicesDashboard.Application.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/src/SimpleServicesDashboard.Common/Configuration/HealthCheckOptions.cs b/src/SimpleServicesDashboard.Common/Configuration/HealthCheckOptions.cs index 1717ca2..77d7e77 100644 --- a/src/SimpleServicesDashboard.Common/Configuration/HealthCheckOptions.cs +++ b/src/SimpleServicesDashboard.Common/Configuration/HealthCheckOptions.cs @@ -1,5 +1,5 @@ -using System.ComponentModel.DataAnnotations; using FluentValidation; +using System.ComponentModel.DataAnnotations; namespace SimpleServicesDashboard.Common.Configuration; @@ -11,7 +11,7 @@ public sealed class HealthCheckOptions [Required] public bool HealthCheckUiEnabled { get; set; } [Required] - public string HeaderText { get; set; } + public required string HeaderText { get; set; } public int EvaluationTimeInSeconds { get; set; } public int MaximumHistoryEntriesPerEndpoint { get; set; } } diff --git a/src/SimpleServicesDashboard.Common/Configuration/ServicesConfigurationOptions.cs b/src/SimpleServicesDashboard.Common/Configuration/ServicesConfigurationOptions.cs index 618999f..1315966 100644 --- a/src/SimpleServicesDashboard.Common/Configuration/ServicesConfigurationOptions.cs +++ b/src/SimpleServicesDashboard.Common/Configuration/ServicesConfigurationOptions.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using FluentValidation; +using System.Collections.Generic; namespace SimpleServicesDashboard.Common.Configuration; @@ -11,12 +11,12 @@ public sealed class ServicesConfigurationOptions /// /// Environment configurations. /// - public List Environments { get; set; } + public required List Environments { get; set; } = []; /// /// List of the services to monitor with configuration. /// - public List Services { get; set; } + public required List Services { get; set; } = []; } /// @@ -27,12 +27,12 @@ public sealed class EnvironmentConfiguration /// /// Short environment code. /// - public string Code { get; set; } + public required string Code { get; set; } /// /// Full environment name. /// - public string Name { get; set; } + public required string Name { get; set; } } /// @@ -40,15 +40,17 @@ public sealed class EnvironmentConfiguration /// public sealed class ServiceConfiguration { - public string Code { get; set; } - public string Name { get; set; } - public string HealthEndpoint { get; set; } - public string AboutEndpoint { get; set; } + public required string Code { get; set; } + public required string Name { get; set; } + public required string HealthEndpoint { get; set; } = "/health"; + public required string AboutEndpoint { get; set; } = "/api/v1/status"; + public required string HealthcheckDashboardEndpoint { get; set; } = "/healthcheck-dashboard"; + public required string SwaggerEndpoint { get; set; } = "/swagger"; /// /// Specific configuration for each available and monitored environment. /// - public List Environments { get; set; } + public required List Environments { get; set; } } /// @@ -59,12 +61,12 @@ public sealed class ServiceEnvironment /// /// Environment short code (dev, qa, uat, prod). /// - public string Environment { get; set; } + public required string Environment { get; set; } /// /// Base URL to the service. /// - public string BaseUrl { get; set; } + public required string BaseUrl { get; set; } } public sealed class ServicesConfigurationOptionsValidator : AbstractValidator diff --git a/src/SimpleServicesDashboard.Common/Extensions/LoggerExtensions.cs b/src/SimpleServicesDashboard.Common/Extensions/LoggerExtensions.cs index 65daf00..0542d00 100644 --- a/src/SimpleServicesDashboard.Common/Extensions/LoggerExtensions.cs +++ b/src/SimpleServicesDashboard.Common/Extensions/LoggerExtensions.cs @@ -1,6 +1,6 @@ +using Microsoft.Extensions.Logging; using System; using System.Linq; -using Microsoft.Extensions.Logging; namespace SimpleServicesDashboard.Common.Extensions; @@ -9,7 +9,7 @@ namespace SimpleServicesDashboard.Common.Extensions; /// public static class LoggerExtensions { - public static IDisposable BeginNamedScope(this ILogger logger, + public static IDisposable? BeginNamedScope(this ILogger logger, string name, params ValueTuple[] properties) { var dictionary = properties.ToDictionary(p => p.Item1, p => p.Item2); @@ -17,7 +17,7 @@ public static IDisposable BeginNamedScope(this ILogger logger, return logger.BeginScope(dictionary); } - public static IDisposable BeginPropertyScope(this ILogger logger, + public static IDisposable? BeginPropertyScope(this ILogger logger, params ValueTuple[] properties) { var dictionary = properties.ToDictionary(p => p.Item1, p => p.Item2); diff --git a/src/SimpleServicesDashboard.Common/Extensions/ValidationOptionsExtensions.cs b/src/SimpleServicesDashboard.Common/Extensions/ValidationOptionsExtensions.cs index 9e5142e..8fafa88 100644 --- a/src/SimpleServicesDashboard.Common/Extensions/ValidationOptionsExtensions.cs +++ b/src/SimpleServicesDashboard.Common/Extensions/ValidationOptionsExtensions.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; -using FluentValidation; +using FluentValidation; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; namespace SimpleServicesDashboard.Common.Extensions; diff --git a/src/SimpleServicesDashboard.Common/SimpleServicesDashboard.Common.csproj b/src/SimpleServicesDashboard.Common/SimpleServicesDashboard.Common.csproj index 3061a03..cd436c3 100644 --- a/src/SimpleServicesDashboard.Common/SimpleServicesDashboard.Common.csproj +++ b/src/SimpleServicesDashboard.Common/SimpleServicesDashboard.Common.csproj @@ -8,11 +8,11 @@ - - - - - + + + + + diff --git a/src/SimpleServicesDashboard.Infrastructure/Clients/BaseHttpClient.cs b/src/SimpleServicesDashboard.Infrastructure/Clients/BaseHttpClient.cs index 40d4d9c..d652dcb 100644 --- a/src/SimpleServicesDashboard.Infrastructure/Clients/BaseHttpClient.cs +++ b/src/SimpleServicesDashboard.Infrastructure/Clients/BaseHttpClient.cs @@ -1,3 +1,6 @@ +using Microsoft.AspNetCore.WebUtilities; +using SimpleServicesDashboard.Application.Common.Interfaces; +using SimpleServicesDashboard.Infrastructure.Helpers; using System; using System.Collections.Generic; using System.IO; @@ -8,9 +11,6 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; -using Microsoft.AspNetCore.WebUtilities; -using SimpleServicesDashboard.Application.Common.Interfaces; -using SimpleServicesDashboard.Infrastructure.Helpers; namespace SimpleServicesDashboard.Infrastructure.Clients; @@ -185,7 +185,7 @@ private static void SetHeaders(HttpRequestMessage requestMessage, IDictionary /// The parameter (header, path, query, form). /// Formatted string. - private static string ParameterToString(object obj) + private static string? ParameterToString(object obj) { switch (obj) { diff --git a/src/SimpleServicesDashboard.Infrastructure/Clients/EmailServiceClient.cs b/src/SimpleServicesDashboard.Infrastructure/Clients/EmailServiceClient.cs index 28b1e51..5c863ed 100644 --- a/src/SimpleServicesDashboard.Infrastructure/Clients/EmailServiceClient.cs +++ b/src/SimpleServicesDashboard.Infrastructure/Clients/EmailServiceClient.cs @@ -1,5 +1,5 @@ -using System.Net.Http; using SimpleServicesDashboard.Application.Common.Interfaces; +using System.Net.Http; namespace SimpleServicesDashboard.Infrastructure.Clients; diff --git a/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/EmailServiceAccess.cs b/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/EmailServiceAccess.cs index b316e54..f12d957 100644 --- a/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/EmailServiceAccess.cs +++ b/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/EmailServiceAccess.cs @@ -1,8 +1,8 @@ -using System; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using SimpleServicesDashboard.Application.Common.Interfaces; using SimpleServicesDashboard.Infrastructure.Models; +using System; +using System.Threading.Tasks; namespace SimpleServicesDashboard.Infrastructure.ServiceAccess; diff --git a/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/ServiceAccessFactory.cs b/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/ServiceAccessFactory.cs index 1f8c511..32c509b 100644 --- a/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/ServiceAccessFactory.cs +++ b/src/SimpleServicesDashboard.Infrastructure/ServiceAccess/ServiceAccessFactory.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using SimpleServicesDashboard.Application.Common.Interfaces; +using System; +using System.Collections.Generic; namespace SimpleServicesDashboard.Infrastructure.ServiceAccess; diff --git a/src/SimpleServicesDashboard.Infrastructure/SimpleServicesDashboard.Infrastructure.csproj b/src/SimpleServicesDashboard.Infrastructure/SimpleServicesDashboard.Infrastructure.csproj index 23eebf7..dedcd5a 100644 --- a/src/SimpleServicesDashboard.Infrastructure/SimpleServicesDashboard.Infrastructure.csproj +++ b/src/SimpleServicesDashboard.Infrastructure/SimpleServicesDashboard.Infrastructure.csproj @@ -6,11 +6,11 @@ - - - - - + + + + + diff --git a/tests/SimpleServicesDashboard.Application.Tests/SimpleServicesDashboard.Application.Tests.csproj b/tests/SimpleServicesDashboard.Application.Tests/SimpleServicesDashboard.Application.Tests.csproj index d7a1ef0..5eebcef 100644 --- a/tests/SimpleServicesDashboard.Application.Tests/SimpleServicesDashboard.Application.Tests.csproj +++ b/tests/SimpleServicesDashboard.Application.Tests/SimpleServicesDashboard.Application.Tests.csproj @@ -11,10 +11,10 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all