diff --git a/.editorconfig b/.editorconfig index 9636fb7..c22c07c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,25 +1,28 @@ +# EditorConfig is awesome:http://EditorConfig.org +# From https://raw.githubusercontent.com/dotnet/roslyn/master/.editorconfig +# https://github.com/BenjaminAbt/templates/blob/main/editorconfig/.editorconfig + ############################### # Core EditorConfig Options # ############################### +# top-most EditorConfig file root = true # stop .editorconfig files search on current file. # All files +# Don't use tabs for indentation. [*] -charset = utf-8 indent_style = space -indent_size = 4 trim_trailing_whitespace = true # Remove trailing whitespace insert_final_newline = true # Ensure file ends with a newline max_line_length = 120 # Maximum line length for readability -end_of_line = lf -tab_width = 4 ############################### # Markdown # ############################### [*.md] +indent_size = 4 trim_trailing_whitespace = false max_line_length = off @@ -83,11 +86,43 @@ max_line_length = off indent_size = 2 max_line_length = off +############################### +# PowerShell # +############################### + +[*.ps1] +indent_size = 2 + +############################### +# Shell # +############################### + +[*.sh] +end_of_line = lf + +[*.{cmd,bat}] +end_of_line = crlf + +############################### +# .NET project files # +############################### + +# Xml project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +indent_size = 2 + +# Xml config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 + ############################### # C# / VB # ############################### -[*.{cs,vb}] +# Code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 + # Organize usings dotnet_sort_system_directives_first = true @@ -98,8 +133,8 @@ dotnet_style_qualification_for_method = false:silent dotnet_style_qualification_for_event = false:silent # Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:silent -dotnet_style_predefined_type_for_member_access = true:silent +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion # Parentheses preferences dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent @@ -124,11 +159,7 @@ dotnet_style_prefer_auto_properties = true:suggestion dotnet_style_prefer_conditional_expression_over_assignment = true:silent dotnet_style_prefer_conditional_expression_over_return = true:silent -############################### -# Naming Conventions # -############################### # Style Definitions - dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i @@ -230,10 +261,8 @@ csharp_preferred_modifier_order = public,private,protected,internal,static,exter csharp_prefer_braces = true:suggestion 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 -# ------------------------------------------------------ # New line preferences csharp_new_line_before_open_brace = all csharp_new_line_before_else = true @@ -243,13 +272,11 @@ csharp_new_line_before_members_in_object_initializers = true csharp_new_line_before_members_in_anonymous_types = true csharp_new_line_between_query_expression_clauses = true -# ------------------------------------------------------ # Indentation preferences csharp_indent_case_contents = true csharp_indent_switch_labels = true csharp_indent_labels = one_less_than_current -# ------------------------------------------------------ # Space preferences csharp_space_after_cast = false csharp_space_after_keywords_in_control_flow_statements = true @@ -263,7 +290,6 @@ 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 -# ------------------------------------------------------ # Wrapping preferences csharp_preserve_single_line_statements = true csharp_preserve_single_line_blocks = true @@ -294,54 +320,6 @@ csharp_style_prefer_pattern_matching = true:silent csharp_style_prefer_not_pattern = true:suggestion csharp_style_prefer_extended_property_pattern = true:suggestion -# ------------------------------------------------------ -# 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.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 - -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.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 - # ------------------------------------------------------ # CA Style @@ -349,108 +327,129 @@ dotnet_naming_style.pascal_case.capitalization = pascal_case dotnet_diagnostic.CA1050.severity = warning # CA1507: Use nameof in place of string +# Avoiding hard-coded strings in code improves maintainability and reduces the risk of errors during refactoring. dotnet_diagnostic.CA1507.severity = warning -# CA1825: Avoid unnecessary zero-length array allocations. Use Array.Empty() instead. +# CA1825: Avoid unnecessary zero-length array allocations. Use Array.Empty() instead. +# Array.Empty() is more memory-efficient as it reuses a single cached empty array instance rather than creating new ones. dotnet_diagnostic.CA1825.severity = warning # CA1850: It is more efficient to use the static 'HashData' method over creating and managing a HashAlgorithm instance to call 'ComputeHash'. +# This improves performance by avoiding unnecessary instance creation and lifecycle management of HashAlgorithm objects. dotnet_diagnostic.CA1850.severity = warning # CA1860: Prefer using 'IsEmpty', 'Count' or 'Length' properties whichever available, rather than calling 'Enumerable.Any()'. -# The intent is clearer and it is more performant than using 'Enumerable.Any()' extension method. -dotnet_diagnostic.CA1860.severity = warning - -# CA1860: Prefer using 'IsEmpty', 'Count' or 'Length' properties whichever available, rather than calling 'Enumerable.Any()'. -# The intent is clearer and it is more performant than using 'Enumerable.Any()' extension method. +# These direct property accesses are more performant and communicate intent more clearly than using LINQ extension methods. dotnet_diagnostic.CA1860.severity = warning # CS1998: This async method lacks 'await' operators and will run synchronously. -# Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. +# Setting this to error prevents misleading code that suggests asynchronous behavior but actually runs synchronously. dotnet_diagnostic.CS1998.severity = error # CA2016: Forward the CancellationToken parameter to methods that take one +# Ensuring proper propagation of cancellation tokens throughout the call chain is critical for responsive and cancellable operations. dotnet_diagnostic.CA2016.severity = error - -# CA2211: Static fields that are neither constants nor read-only are not thread-safe. -# Access to such a field must be carefully controlled and requires advanced programming techniques to synchronize access to the class object. -dotnet_diagnostic.CA2211.severity = silent - # ------------------------------------------------------ # IDE # IDE0060: Avoid unused parameters in your code. -# If the parameter cannot be removed, then change its name so it starts with an underscore and is optionally followed by an -# integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names. +# Silenced to allow for interface implementations where not all parameters may be needed in every implementation or like URL design in ASP.NET Core. dotnet_diagnostic.IDE0060.severity = silent # IDE0130: Namespace does not match folder structure +# Enforces consistent organization where namespaces reflect folder structure, improving code discoverability. dotnet_diagnostic.IDE0130.severity = warning -# IDE0290: Use primary constructor -dotnet_diagnostic.IDE0290.severity = none -csharp_style_prefer_primary_constructors = false:suggestion +# IDE0039: Use local function instead of lambda +# Local functions improve readability and performance over lambdas for method-local callable code. +dotnet_diagnostic.IDE0039.severity = warning -# IDE1006: Naming rule violation: These words must begin with upper case characters: accessToken +# IDE0270: Null check can be simplified +# Disabled to allow developers to choose their preferred null-checking style based on context and readability. +dotnet_diagnostic.IDE0270.severity = none + +# IDE0305: Use collection expression for fluent +# Silenced because collection expression style is often a matter of preference and readability context. +dotnet_diagnostic.IDE0305.severity = silent + +# IDE1006: Naming rule violation: These words must begin with upper case characters +# Enforces consistent naming conventions across the codebase for better readability and maintainability. dotnet_diagnostic.IDE1006.severity = warning # ------------------------------------------------------ # Roslyn +# RCS0063: Remove unnecessary blank line +# Promotes cleaner, more consistent code formatting by eliminating superfluous whitespace. +dotnet_diagnostic.RCS0063.severity = warning + # RCS1021: Use expression-bodied lambda. +# Silenced to allow both statement and expression-bodied lambda syntax based on complexity and readability. dotnet_diagnostic.RCS1021.severity = silent -# RCS1036: Remove unnecessary blank line -dotnet_diagnostic.RCS1036.severity = warning - # RCS1049: Simplify boolean comparison -# we usually prefer is vs ! +# Silenced to allow explicit boolean comparisons (e.g., x == true) when they improve readability. dotnet_diagnostic.RCS1049.severity = silent # RCS1123: Add parentheses when necessary +# Enforces explicit operator precedence through parentheses, preventing subtle bugs and improving readability. dotnet_diagnostic.RCS1123.severity = warning # RCS1163: Unused parameter -# Often this warning comes also from parameters we want to have for readability +# Silenced because parameters may be kept for API consistency or documentation purposes even when unused or URL design in ASP.NET Core. dotnet_diagnostic.RCS1163.severity = silent # RCS1194: Implement exception constructors +# Silenced to allow custom exception classes with only the constructors needed for the specific use case. dotnet_diagnostic.RCS1194.severity = silent # ------------------------------------------------------ # Meziantou.Analyzer +# MA0007: Add a comma after the last value +# Disabled as trailing commas in C# are not conventional and would make the code less familiar to most developers. +dotnet_diagnostic.MA0007.severity = none + # MA0016: Prefer using collection abstraction instead of implementation +# Disabled to allow direct use of concrete collection types when their specific capabilities are needed. dotnet_diagnostic.MA0016.severity = none # MA0017: Abstract types should not have public or internal constructors +# Disabled to permit protected constructors in abstract classes which are valid for inheritance scenarios. dotnet_diagnostic.MA0017.severity = none -# MA0018: Do not declare static members on generic types (deprecated; use CA1000 instead) +# MA0018: Do not declare static members on generic types +# Disabled in favor of using the standard CA1000 (Do not declare static members on generic types) rule to handle this case. dotnet_diagnostic.MA0018.severity = none # MA0029: Combine LINQ methods -# Often these recommendations have a performance impact, so it is recommended to review them before applying them. +# Disabled because LINQ method chaining can be more readable and potential performance impacts need case-by-case review. dotnet_diagnostic.MA0029.severity = none # MA0040: Forward the CancellationToken parameter to methods that take one +# Enforces proper cancellation token propagation for responsive applications and services. dotnet_diagnostic.MA0040.severity = warning # MA0048: File name must match type name +# Silenced to allow flexibility in file naming, particularly for partial classes or multiple types in one file. dotnet_diagnostic.MA0048.severity = silent -# MA0051: Method is too long (80 lines; maximum allowed: 60) +# MA0051: Method is too long +# Set as suggestion to encourage smaller, more focused methods while allowing flexibility for complex logic. dotnet_diagnostic.MA0051.severity = suggestion # MA0154: Use langword in XML comment +# Disabled to allow flexibility in documentation style and format. dotnet_diagnostic.MA0154.severity = none # ------------------------------------------------------ # Xunit # xUnit1006: Theory methods should have parameters +# Silenced to allow theories that might dynamically generate test cases without explicit parameters. dotnet_diagnostic.xUnit1006.severity = silent -# xUnit1048: Support for 'async void' unit tests is being removed from xUnit.net v3. To simplify upgrading, convert the test to 'async Task' instead. +# xUnit1048: Support for 'async void' unit tests is being removed +# Set as error to ensure future compatibility with xUnit v3 by requiring proper async Task signatures. dotnet_diagnostic.xUnit1048.severity = error diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..17c77c3 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1 @@ +- @azure Rule - Use Azure Best Practices: When generating code for Azure, running terminal commands for Azure, or performing operations related to Azure, invoke your `get_azure_best_practices` tool if available. \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15b9090..60732e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,13 @@ on: jobs: build: - uses: mycsharp/github-actions/.github/workflows/dotnet-nuget-build.yml@main + uses: mycsharp/github-actions/.github/workflows/dotnet-nuget-build-multi-sdk.yml@main with: configuration: Release + dotnet-sdks: | + 8.x + 9.x + 10.x + secrets: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} diff --git a/Directory.Build.props b/Directory.Build.props index b5d555f..5e3c143 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,42 +1,25 @@ - - - MyCSharp.de, Benjamin Abt, Günther Foidl and Contributors + MyCSharp.HttpClientHints - en-US - true - embedded - - - - - $(MSBuildProjectName.Contains('Test')) - $(MsBuildProjectName.Contains('Benchmark')) - - - - https://github.com/mycsharp/HttpClientHints - true - HTTP Client Hints for .NET - 2.12 - false - UserAgent, User Agent, Client Hints, Browser, Client, Detector, Detection, Console, ASP, Desktop, Mobile - true + MyCSharp.de, Benjamin Abt, Günther Foidl and Contributors + MyCSharp.de - - net8.0;net9.0 - + + true + true + true - - 12.0 - enable - enable - true + $(MSBuildProjectName.EndsWith('Tests')) + $(MSBuildProjectName.EndsWith('UnitTests')) + $(MSBuildProjectName.EndsWith('IntegrationTests')) + $(MsBuildProjectName.EndsWith('Benchmarks')) - - true + + net8.0;net9.0;net10.0 + MyCSharp.$(MSBuildProjectName) + MyCSharp.$(MSBuildProjectName) @@ -52,10 +35,91 @@ - + + preview + embedded + enable + en-US + enable + true + + + + false + true + 2.12 + true + + HTTP Client Hints for .NET + https://github.com/mycsharp/HttpClientHints + https://github.com/mycsharp/HttpClientHints + UserAgent, User Agent, Client Hints, Browser, Client, Detector, Detection, Console, ASP, Desktop, Mobile + + + + true + + + + + true + + + + true + all + low + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props index 5e97cf2..9553c73 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -2,40 +2,54 @@ true - - + + - - + + + + + + + - - - + + all + runtime; build; native; contentfiles; analyzers + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + all runtime; build; native; contentfiles; analyzers - - - + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers - + + + + all runtime; build; native; contentfiles; analyzers diff --git a/MyCSharp.HttpClientHints.sln b/MyCSharp.HttpClientHints.sln index 1e8a9a9..c25274a 100644 --- a/MyCSharp.HttpClientHints.sln +++ b/MyCSharp.HttpClientHints.sln @@ -22,17 +22,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{E23F6AE5-FF68-4E version.json = version.json EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCSharp.HttpClientHints", "src\MyCSharp.HttpClientHints\MyCSharp.HttpClientHints.csproj", "{3FC14B16-D6F7-4A28-8562-0BD7EDD6A3DC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientHints", "src\HttpClientHints\HttpClientHints.csproj", "{3FC14B16-D6F7-4A28-8562-0BD7EDD6A3DC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCSharp.HttpClientHints.AspNetCore", "src\MyCSharp.HttpClientHints.AspNetCore\MyCSharp.HttpClientHints.AspNetCore.csproj", "{8A434079-78A3-41C5-8319-3165B0D10E51}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientHints.AspNetCore", "src\HttpClientHints.AspNetCore\HttpClientHints.AspNetCore.csproj", "{8A434079-78A3-41C5-8319-3165B0D10E51}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCSharp.HttpClientHints.AspNetCore.UnitTests", "tests\MyCSharp.HttpClientHints.AspNetCore.UnitTests\MyCSharp.HttpClientHints.AspNetCore.UnitTests.csproj", "{2BDA44E4-1E40-4B97-8903-B8C36C35B8C4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientHints.AspNetCore.UnitTests", "tests\HttpClientHints.AspNetCore.UnitTests\HttpClientHints.AspNetCore.UnitTests.csproj", "{2BDA44E4-1E40-4B97-8903-B8C36C35B8C4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCSharp.HttpClientHints.UnitTests", "tests\MyCSharp.HttpClientHints.UnitTests\MyCSharp.HttpClientHints.UnitTests.csproj", "{E60AE9AF-09E5-4FE0-A005-5F697599E508}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientHints.UnitTests", "tests\HttpClientHints.UnitTests\HttpClientHints.UnitTests.csproj", "{E60AE9AF-09E5-4FE0-A005-5F697599E508}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DD28B2F1-1CF8-4070-A997-83DE356EA88C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCSharp.HttpClientHints.Samples.AspNetCoreMvc", "samples\MyCSharp.HttpClientHints.Samples.AspNetCoreMvc\MyCSharp.HttpClientHints.Samples.AspNetCoreMvc.csproj", "{2F2815DE-1730-4645-B6CF-13599BBA3B2C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClientHints.Samples.AspNetCoreMvc", "samples\HttpClientHints.Samples.AspNetCoreMvc\HttpClientHints.Samples.AspNetCoreMvc.csproj", "{2F2815DE-1730-4645-B6CF-13599BBA3B2C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/global.json b/global.json index 76474f0..c30f249 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { - "sdk": { - "version": "9.0.100" - } + "sdk": { + "version": "10.0.100-preview.2.25164.34" + } } diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Controllers/HomeController.cs b/samples/HttpClientHints.Samples.AspNetCoreMvc/Controllers/HomeController.cs similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Controllers/HomeController.cs rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Controllers/HomeController.cs diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc.csproj b/samples/HttpClientHints.Samples.AspNetCoreMvc/HttpClientHints.Samples.AspNetCoreMvc.csproj similarity index 56% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc.csproj rename to samples/HttpClientHints.Samples.AspNetCoreMvc/HttpClientHints.Samples.AspNetCoreMvc.csproj index 5ec1be5..75901c6 100644 --- a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc.csproj +++ b/samples/HttpClientHints.Samples.AspNetCoreMvc/HttpClientHints.Samples.AspNetCoreMvc.csproj @@ -5,7 +5,7 @@ - + diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Program.cs b/samples/HttpClientHints.Samples.AspNetCoreMvc/Program.cs similarity index 91% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Program.cs rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Program.cs index 01eba86..a19f47e 100644 --- a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Program.cs +++ b/samples/HttpClientHints.Samples.AspNetCoreMvc/Program.cs @@ -2,7 +2,7 @@ using MyCSharp.HttpClientHints.AspNetCore; -var builder = WebApplication.CreateBuilder(args); +WebApplicationBuilder builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); @@ -19,7 +19,7 @@ options.Lifetime = TimeSpan.FromDays(31); }); -var app = builder.Build(); +WebApplication app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) @@ -44,5 +44,4 @@ name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); - app.Run(); diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Properties/launchSettings.json b/samples/HttpClientHints.Samples.AspNetCoreMvc/Properties/launchSettings.json similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Properties/launchSettings.json rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Properties/launchSettings.json diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/Home/Index.cshtml b/samples/HttpClientHints.Samples.AspNetCoreMvc/Views/Home/Index.cshtml similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/Home/Index.cshtml rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Views/Home/Index.cshtml diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml b/samples/HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Views/Shared/_Layout.cshtml.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewImports.cshtml b/samples/HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewImports.cshtml similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewImports.cshtml rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewImports.cshtml diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewStart.cshtml b/samples/HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewStart.cshtml similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewStart.cshtml rename to samples/HttpClientHints.Samples.AspNetCoreMvc/Views/_ViewStart.cshtml diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/appsettings.Development.json b/samples/HttpClientHints.Samples.AspNetCoreMvc/appsettings.Development.json similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/appsettings.Development.json rename to samples/HttpClientHints.Samples.AspNetCoreMvc/appsettings.Development.json diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/appsettings.json b/samples/HttpClientHints.Samples.AspNetCoreMvc/appsettings.json similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/appsettings.json rename to samples/HttpClientHints.Samples.AspNetCoreMvc/appsettings.json diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/css/site.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/css/site.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/css/site.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/css/site.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/favicon.ico b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/favicon.ico similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/favicon.ico rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/favicon.ico diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/js/site.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/js/site.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/js/site.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/js/site.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/LICENSE b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/LICENSE similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/LICENSE rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/LICENSE diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.js.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/LICENSE.md b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/LICENSE.md similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/LICENSE.md rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/LICENSE.md diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/additional-methods.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/LICENSE.txt b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/LICENSE.txt similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/LICENSE.txt rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/LICENSE.txt diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.min.map diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.js b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.js similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.js rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.js diff --git a/samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.map b/samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.map similarity index 100% rename from samples/MyCSharp.HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.map rename to samples/HttpClientHints.Samples.AspNetCoreMvc/wwwroot/lib/jquery/dist/jquery.slim.min.map diff --git a/src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj b/src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj new file mode 100644 index 0000000..13dedd2 --- /dev/null +++ b/src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj @@ -0,0 +1,27 @@ + + + + HTTP Client Hints Extensions for ASP.NET Core + HTTP Client Hints Extensions for ASP.NET Core + + + + true + readme.md + LICENSE.txt + + + + + + + + + + + + + + + + diff --git a/src/HttpClientHints.AspNetCore/HttpClientHintsHttpContextExtensions.cs b/src/HttpClientHints.AspNetCore/HttpClientHintsHttpContextExtensions.cs new file mode 100644 index 0000000..b6f3ebe --- /dev/null +++ b/src/HttpClientHints.AspNetCore/HttpClientHintsHttpContextExtensions.cs @@ -0,0 +1,76 @@ +// Copyright © myCSharp.de - all rights reserved + +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Primitives; + +namespace MyCSharp.HttpClientHints.AspNetCore; + +/// +/// Extension methods for accessing HTTP Client Hints from the and its headers. +/// +public static class HttpClientHintsHttpContextExtensions +{ + /// + /// The cache key used to store the client hints in the HttpContext.Items dictionary. + /// + private const string ClientHintsCacheKey = "__HttpClientHints"; + + /// + /// Retrieves the from the current HTTP context. + /// + /// The HTTP context containing the request headers. + /// An instance of populated with the relevant header values. + public static HttpClientHints GetClientHints(this HttpContext context) + { + // Check if client hints are already cached for this request + if (context.Items.TryGetValue(ClientHintsCacheKey, out var cached) && cached is HttpClientHints hints) + { + return hints; + } + + // Create and cache new client hints + var newHints = context.Request.Headers.GetClientHints(); + context.Items[ClientHintsCacheKey] = newHints; + return newHints; + } + + /// + /// Retrieves the from the specified header dictionary. + /// + /// The header dictionary containing the Client Hints headers. + /// An instance of populated with the relevant header values. + public static HttpClientHints GetClientHints(this IHeaderDictionary headers) + { + // User Agent + headers.TryGetValue("User-Agent", out StringValues userAgentValues); + string? userAgent = userAgentValues.Count > 0 ? userAgentValues[0] : null; + + headers.TryGetValue("Sec-CH-UA", out StringValues uaValues); + string? ua = uaValues.Count > 0 ? uaValues[0] : null; + + // Platform + headers.TryGetValue("Sec-CH-UA-Platform", out StringValues platformValues); + string? platform = platformValues.Count > 0 ? platformValues[0] : null; + + headers.TryGetValue("Sec-CH-UA-Platform-Version", out StringValues platformVersionValues); + string? platformVersion = platformVersionValues.Count > 0 ? platformVersionValues[0] : null; + + // Architecture + headers.TryGetValue("Sec-CH-UA-Arch", out StringValues architectureValues); + string? architecture = architectureValues.Count > 0 ? architectureValues[0] : null; + + // Other + headers.TryGetValue("Sec-CH-UA-Full-Version-List", out StringValues fullVersionListValues); + string? fullVersionList = fullVersionListValues.Count > 0 ? fullVersionListValues[0] : null; + + // Device + headers.TryGetValue("Sec-CH-UA-Model", out StringValues modelValues); + string? model = modelValues.Count > 0 ? modelValues[0] : null; + + headers.TryGetValue("Sec-CH-UA-Mobile", out StringValues mobileValues); + bool? mobile = HttpClientHintsInterpreter.IsMobile(mobileValues.Count > 0 ? mobileValues[0] : null); + + // Return the HttpClientHints record + return new(userAgent, platform, platformVersion, architecture, model, fullVersionList, ua, mobile, headers); + } +} diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsMiddlewareConfig.cs b/src/HttpClientHints.AspNetCore/HttpClientHintsMiddlewareConfig.cs similarity index 50% rename from src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsMiddlewareConfig.cs rename to src/HttpClientHints.AspNetCore/HttpClientHintsMiddlewareConfig.cs index 0dc0a46..6a97604 100644 --- a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsMiddlewareConfig.cs +++ b/src/HttpClientHints.AspNetCore/HttpClientHintsMiddlewareConfig.cs @@ -12,12 +12,40 @@ public class HttpClientHintsMiddlewareConfig /// /// The name of the response header as a . /// These settings are set by . Do not set these values manually. - public required string ResponseHeader { get; set; } + public required string ResponseHeader + { + get; + set + { + field = value; + HasResponseHeaders = string.IsNullOrEmpty(value) is false; + } + } + + /// + /// Gets a value indicating whether the response headers have been configured. + /// + /// true if response headers are configured; otherwise, false. + public bool HasResponseHeaders { get; internal set; } /// /// Gets or sets the lifetime of the client hints in seconds. /// /// A containing an representing the lifetime in seconds, or null if unspecified. /// These settings are set by . Do not set these values manually. - public string? LifeTime { get; set; } + public string? LifeTime + { + get; + set + { + field = value; + HasLifetime = string.IsNullOrEmpty(value) is false; + } + } + + /// + /// Gets a value indicating whether the lifetime for client hints has been configured. + /// + /// true if lifetime is configured; otherwise, false. + public bool HasLifetime { get; internal set; } } diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsOptions.cs b/src/HttpClientHints.AspNetCore/HttpClientHintsOptions.cs similarity index 100% rename from src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsOptions.cs rename to src/HttpClientHints.AspNetCore/HttpClientHintsOptions.cs diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsRegistration.cs b/src/HttpClientHints.AspNetCore/HttpClientHintsRegistration.cs similarity index 96% rename from src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsRegistration.cs rename to src/HttpClientHints.AspNetCore/HttpClientHintsRegistration.cs index 7f30739..6536127 100644 --- a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsRegistration.cs +++ b/src/HttpClientHints.AspNetCore/HttpClientHintsRegistration.cs @@ -24,7 +24,7 @@ public static IServiceCollection AddHttpClientHints(this IServiceCollection serv string? lifeTime; if (httpClientHintsConfig.Lifetime is TimeSpan lifetime) { - lifeTime = lifetime.TotalSeconds.ToString("0.##"); // ignore decimals + lifeTime = lifetime.TotalSeconds.ToString("0.##", provider: null); // ignore decimals } else { diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsRequestMiddleware.cs b/src/HttpClientHints.AspNetCore/HttpClientHintsRequestMiddleware.cs similarity index 61% rename from src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsRequestMiddleware.cs rename to src/HttpClientHints.AspNetCore/HttpClientHintsRequestMiddleware.cs index b3c60d8..90b1f8a 100644 --- a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsRequestMiddleware.cs +++ b/src/HttpClientHints.AspNetCore/HttpClientHintsRequestMiddleware.cs @@ -1,18 +1,19 @@ -// Copyright © myCSharp.de - all rights reserved - using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; namespace MyCSharp.HttpClientHints.AspNetCore; /// -/// Middleware for adding HTTP Client Hints headers to the response. -/// Initializes a new instance of the class. +/// Middleware for processing HTTP Client Hints in ASP.NET Core requests. +/// This middleware adds Client Hints headers to HTTP responses based on configuration. /// -/// The next middleware in the request pipeline. -/// The options for configuring the middleware. +/// +/// This middleware adds the 'Accept-CH' header and optionally the 'Accept-CH-Lifetime' header +/// to responses when configured appropriately. +/// public class HttpClientHintsRequestMiddleware(RequestDelegate next, IOptions options) { + // Cache the options value and pre-compute conditions to avoid repeated checks private readonly HttpClientHintsMiddlewareConfig _options = options.Value; /// @@ -22,18 +23,18 @@ public class HttpClientHintsRequestMiddleware(RequestDelegate next, IOptionsA that represents the asynchronous operation. public async Task InvokeAsync(HttpContext context) { - // Add Client Hints headers to the response - if (string.IsNullOrEmpty(_options.ResponseHeader) is false) + if (_options.HasResponseHeaders) { + // Set headers directly without additional checks context.Response.Headers["Accept-CH"] = _options.ResponseHeader; - if (_options.LifeTime is not null) + if (_options.HasLifetime) { context.Response.Headers["Accept-CH-Lifetime"] = _options.LifeTime; } } // Call the next middleware in the pipeline - await next(context); + await next(context).ConfigureAwait(false); } } diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/LICENSE.txt b/src/HttpClientHints.AspNetCore/LICENSE.txt similarity index 100% rename from src/MyCSharp.HttpClientHints.AspNetCore/LICENSE.txt rename to src/HttpClientHints.AspNetCore/LICENSE.txt diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/readme.md b/src/HttpClientHints.AspNetCore/readme.md similarity index 100% rename from src/MyCSharp.HttpClientHints.AspNetCore/readme.md rename to src/HttpClientHints.AspNetCore/readme.md diff --git a/src/MyCSharp.HttpClientHints/HttpClientHints.cs b/src/HttpClientHints/HttpClientHints.cs similarity index 94% rename from src/MyCSharp.HttpClientHints/HttpClientHints.cs rename to src/HttpClientHints/HttpClientHints.cs index 6c84c3e..4bffbab 100644 --- a/src/MyCSharp.HttpClientHints/HttpClientHints.cs +++ b/src/HttpClientHints/HttpClientHints.cs @@ -4,6 +4,8 @@ namespace MyCSharp.HttpClientHints; +#pragma warning disable MA0049 // Type name should not match containing namespace + /// /// Represents HTTP Client Hints retrieved from the request headers. /// diff --git a/src/HttpClientHints/HttpClientHints.csproj b/src/HttpClientHints/HttpClientHints.csproj new file mode 100644 index 0000000..9ed2777 --- /dev/null +++ b/src/HttpClientHints/HttpClientHints.csproj @@ -0,0 +1,22 @@ + + + + HTTP Client Agents + Reads HTTP Client Hints to identify Browsers, Platforms and Bots. + + + + true + readme.md + LICENSE.txt + + + + + + + + + + + diff --git a/src/MyCSharp.HttpClientHints/HttpClientHintsInterpreter.cs b/src/HttpClientHints/HttpClientHintsInterpreter.cs similarity index 87% rename from src/MyCSharp.HttpClientHints/HttpClientHintsInterpreter.cs rename to src/HttpClientHints/HttpClientHintsInterpreter.cs index f7e7c26..a37c862 100644 --- a/src/MyCSharp.HttpClientHints/HttpClientHintsInterpreter.cs +++ b/src/HttpClientHints/HttpClientHintsInterpreter.cs @@ -21,12 +21,12 @@ public static class HttpClientHintsInterpreter /// public static bool? IsMobile(string? mobileHeaderValue) { - if (mobileHeaderValue is "?1") + if (string.Equals(mobileHeaderValue, "?1", StringComparison.Ordinal)) { return true; } - if (mobileHeaderValue is "?0") + if (string.Equals(mobileHeaderValue, "?0", StringComparison.Ordinal)) { return false; } diff --git a/src/MyCSharp.HttpClientHints/LICENSE.txt b/src/HttpClientHints/LICENSE.txt similarity index 100% rename from src/MyCSharp.HttpClientHints/LICENSE.txt rename to src/HttpClientHints/LICENSE.txt diff --git a/src/MyCSharp.HttpClientHints/readme.md b/src/HttpClientHints/readme.md similarity index 100% rename from src/MyCSharp.HttpClientHints/readme.md rename to src/HttpClientHints/readme.md diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsHttpContextExtensions.cs b/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsHttpContextExtensions.cs deleted file mode 100644 index d141120..0000000 --- a/src/MyCSharp.HttpClientHints.AspNetCore/HttpClientHintsHttpContextExtensions.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright © myCSharp.de - all rights reserved - -using Microsoft.AspNetCore.Http; - -namespace MyCSharp.HttpClientHints.AspNetCore; - -/// -/// Extension methods for accessing HTTP Client Hints from the and its headers. -/// -public static class HttpClientHintsHttpContextExtensions -{ - /// - /// Retrieves the from the current HTTP context. - /// - /// The HTTP context containing the request headers. - /// An instance of populated with the relevant header values. - public static HttpClientHints GetClientHints(this HttpContext context) - { - IHeaderDictionary headers = context.Request.Headers; - return headers.GetClientHints(); - } - - /// - /// Retrieves the from the specified header dictionary. - /// - /// The header dictionary containing the Client Hints headers. - /// An instance of populated with the relevant header values. - public static HttpClientHints GetClientHints(this IHeaderDictionary headers) - { - // user agent - string? userAgent = headers["User-Agent"].FirstOrDefault(); - string? ua = headers["Sec-CH-UA"].FirstOrDefault(); - - // platform - string? platform = headers["Sec-CH-UA-Platform"].FirstOrDefault(); - string? platformVersion = headers["Sec-CH-UA-Platform-Version"].FirstOrDefault(); - - // architecture - string? architecture = headers["Sec-CH-UA-Arch"].FirstOrDefault(); - - // other - string? fullVersionList = headers["Sec-CH-UA-Full-Version-List"].FirstOrDefault(); - - // device - string? model = headers["Sec-CH-UA-Model"].FirstOrDefault(); - bool? mobile = HttpClientHintsInterpreter.IsMobile(headers["Sec-CH-UA-Mobile"].FirstOrDefault()); - - // return the HttpClientHints record - return new(userAgent, platform, platformVersion, architecture, model, fullVersionList, ua, mobile, headers); - } -} diff --git a/src/MyCSharp.HttpClientHints.AspNetCore/MyCSharp.HttpClientHints.AspNetCore.csproj b/src/MyCSharp.HttpClientHints.AspNetCore/MyCSharp.HttpClientHints.AspNetCore.csproj deleted file mode 100644 index 21c6fc3..0000000 --- a/src/MyCSharp.HttpClientHints.AspNetCore/MyCSharp.HttpClientHints.AspNetCore.csproj +++ /dev/null @@ -1,42 +0,0 @@ - - - - HTTP Client Hints Extensions for ASP.NET Core - HTTP Client Hints Extensions for ASP.NET Core - - - - true - readme.md - LICENSE.txt - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - diff --git a/src/MyCSharp.HttpClientHints/MyCSharp.HttpClientHints.csproj b/src/MyCSharp.HttpClientHints/MyCSharp.HttpClientHints.csproj deleted file mode 100644 index 7898ac8..0000000 --- a/src/MyCSharp.HttpClientHints/MyCSharp.HttpClientHints.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - - HTTP Client Agents - Reads HTTP Client Hints to identify Browsers, Platforms and Bots. - - - - true - readme.md - LICENSE.txt - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - - diff --git a/tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHints.AspNetCore.UnitTests.csproj b/tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHints.AspNetCore.UnitTests.csproj new file mode 100644 index 0000000..cdd1059 --- /dev/null +++ b/tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHints.AspNetCore.UnitTests.csproj @@ -0,0 +1,11 @@ + + + + Exe + + + + + + + diff --git a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsHttpContextExtensionsTests.cs b/tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHintsHttpContextExtensionsTests.cs similarity index 100% rename from tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsHttpContextExtensionsTests.cs rename to tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHintsHttpContextExtensionsTests.cs diff --git a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs b/tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs similarity index 89% rename from tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs rename to tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs index 362d63e..12c331f 100644 --- a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs +++ b/tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRegistrationTests.cs @@ -22,14 +22,14 @@ public void AddHttpClientHints_DefaultOptions_RegistersDefaultHeaders() HttpClientHintsMiddlewareConfig options = serviceProvider.GetRequiredService>().Value; // Assert - Assert.Contains("User-Agent", options.ResponseHeader); - Assert.Contains("Sec-CH-UA", options.ResponseHeader); - Assert.Contains("Sec-CH-UA-Platform", options.ResponseHeader); - Assert.Contains("Sec-CH-UA-Platform-Version", options.ResponseHeader); - Assert.Contains("Sec-CH-UA-Arch", options.ResponseHeader); - Assert.Contains("Sec-CH-UA-Bitness", options.ResponseHeader); - Assert.Contains("Sec-CH-UA-Model", options.ResponseHeader); - Assert.Contains("Sec-CH-UA-Mobile", options.ResponseHeader); + Assert.Contains("User-Agent", options.ResponseHeader, StringComparison.Ordinal); + Assert.Contains("Sec-CH-UA", options.ResponseHeader, StringComparison.Ordinal); + Assert.Contains("Sec-CH-UA-Platform", options.ResponseHeader, StringComparison.Ordinal); + Assert.Contains("Sec-CH-UA-Platform-Version", options.ResponseHeader, StringComparison.Ordinal); + Assert.Contains("Sec-CH-UA-Arch", options.ResponseHeader, StringComparison.Ordinal); + Assert.Contains("Sec-CH-UA-Bitness", options.ResponseHeader, StringComparison.Ordinal); + Assert.Contains("Sec-CH-UA-Model", options.ResponseHeader, StringComparison.Ordinal); + Assert.Contains("Sec-CH-UA-Mobile", options.ResponseHeader, StringComparison.Ordinal); Assert.Null(options.LifeTime); } @@ -61,8 +61,8 @@ public void AddHttpClientHints_DisablePlatformHeader_DoesNotRegisterPlatformHead HttpClientHintsMiddlewareConfig options = serviceProvider.GetRequiredService>().Value; // Assert - Assert.DoesNotContain("Sec-CH-UA-Platform", options.ResponseHeader); - Assert.DoesNotContain("Sec-CH-UA-Platform-Version", options.ResponseHeader); + Assert.DoesNotContain("Sec-CH-UA-Platform", options.ResponseHeader, StringComparison.Ordinal); + Assert.DoesNotContain("Sec-CH-UA-Platform-Version", options.ResponseHeader, StringComparison.Ordinal); } [Fact] @@ -78,7 +78,7 @@ public void AddHttpClientHints_CustomAdditionalHeader_RegistersAdditionalHeader( HttpClientHintsMiddlewareConfig options = serviceProvider.GetRequiredService>().Value; // Assert - Assert.Contains("X-Custom-Header", options.ResponseHeader); + Assert.Contains("X-Custom-Header", options.ResponseHeader, StringComparison.Ordinal); } [Fact] diff --git a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRequestMiddlewareTests.cs b/tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRequestMiddlewareTests.cs similarity index 100% rename from tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRequestMiddlewareTests.cs rename to tests/HttpClientHints.AspNetCore.UnitTests/HttpClientHintsRequestMiddlewareTests.cs diff --git a/tests/HttpClientHints.UnitTests/HttpClientHints.UnitTests.csproj b/tests/HttpClientHints.UnitTests/HttpClientHints.UnitTests.csproj new file mode 100644 index 0000000..01b85e5 --- /dev/null +++ b/tests/HttpClientHints.UnitTests/HttpClientHints.UnitTests.csproj @@ -0,0 +1,11 @@ + + + + Exe + + + + + + + diff --git a/tests/MyCSharp.HttpClientHints.UnitTests/HttpClientHintsInterpreterTests.cs b/tests/HttpClientHints.UnitTests/HttpClientHintsInterpreterTests.cs similarity index 100% rename from tests/MyCSharp.HttpClientHints.UnitTests/HttpClientHintsInterpreterTests.cs rename to tests/HttpClientHints.UnitTests/HttpClientHintsInterpreterTests.cs diff --git a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/MyCSharp.HttpClientHints.AspNetCore.UnitTests.csproj b/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/MyCSharp.HttpClientHints.AspNetCore.UnitTests.csproj deleted file mode 100644 index 06453e5..0000000 --- a/tests/MyCSharp.HttpClientHints.AspNetCore.UnitTests/MyCSharp.HttpClientHints.AspNetCore.UnitTests.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - Exe - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - \ No newline at end of file diff --git a/tests/MyCSharp.HttpClientHints.UnitTests/MyCSharp.HttpClientHints.UnitTests.csproj b/tests/MyCSharp.HttpClientHints.UnitTests/MyCSharp.HttpClientHints.UnitTests.csproj deleted file mode 100644 index 99e0ece..0000000 --- a/tests/MyCSharp.HttpClientHints.UnitTests/MyCSharp.HttpClientHints.UnitTests.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - Exe - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - all - runtime; build; native; contentfiles; analyzers - - - - - - - - \ No newline at end of file