Skip to content

add performance enhancements #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 90 additions & 91 deletions .editorconfig

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
130 changes: 97 additions & 33 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
<Project>

<PropertyGroup>
<Authors>MyCSharp.de, Benjamin Abt, Günther Foidl and Contributors</Authors>
<PropertyGroup Label="Project">
<Product>MyCSharp.HttpClientHints</Product>
<DefaultLanguage>en-US</DefaultLanguage>
<NoPackageAnalysis>true</NoPackageAnalysis>
<DebugType>embedded</DebugType>
</PropertyGroup>

<PropertyGroup Label="Env">

<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<IsBenchmarkProject>$(MsBuildProjectName.Contains('Benchmark'))</IsBenchmarkProject>
</PropertyGroup>

<PropertyGroup Label="Package">
<PackageProjectUrl>https://github.com/mycsharp/HttpClientHints</PackageProjectUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<Description>HTTP Client Hints for .NET</Description>
<MinClientVersion>2.12</MinClientVersion>
<IsPackable>false</IsPackable>
<PackageTags>UserAgent, User Agent, Client Hints, Browser, Client, Detector, Detection, Console, ASP, Desktop, Mobile</PackageTags>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Authors>MyCSharp.de, Benjamin Abt, Günther Foidl and Contributors</Authors>
<Company>MyCSharp.de</Company>
</PropertyGroup>

<PropertyGroup Label="Project Defaults">
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Label="Vars">
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>

<PropertyGroup Label="C#">
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsTestProject>$(MSBuildProjectName.EndsWith('Tests'))</IsTestProject>
<IsUnitTestProject>$(MSBuildProjectName.EndsWith('UnitTests'))</IsUnitTestProject>
<IsIntegrationTestProject>$(MSBuildProjectName.EndsWith('IntegrationTests'))</IsIntegrationTestProject>
<IsBenchmarkProject>$(MsBuildProjectName.EndsWith('Benchmarks'))</IsBenchmarkProject>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true'">
<GenerateDocumentationFile Condition="'$(Configuration)' == 'Release'">true</GenerateDocumentationFile>
<PropertyGroup Label="Assembly">
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<RootNamespace>MyCSharp.$(MSBuildProjectName)</RootNamespace>
<AssemblyName>MyCSharp.$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -52,10 +35,91 @@
</PublicKey>
</PropertyGroup>

<!-- Block Projects with Privacy/Security Concerns -->
<PropertyGroup Label="Compiler">
<LangVersion>preview</LangVersion>
<DebugType>embedded</DebugType>
<Nullable>enable</Nullable>
<DefaultLanguage>en-US</DefaultLanguage>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Label="Package">
<IsPackable>false</IsPackable>
<NoPackageAnalysis>true</NoPackageAnalysis>
<MinClientVersion>2.12</MinClientVersion>
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<Description>HTTP Client Hints for .NET</Description>
<PackageProjectUrl>https://github.com/mycsharp/HttpClientHints</PackageProjectUrl>
<RepositoryUrl>https://github.com/mycsharp/HttpClientHints</RepositoryUrl>
<PackageTags>UserAgent, User Agent, Client Hints, Browser, Client, Detector, Detection, Console, ASP, Desktop, Mobile</PackageTags>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' != 'true' AND '$(IsBenchmarkProject)' != 'true'">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Label="Visual Studio">
<!-- https://devblogs.microsoft.com/visualstudio/visual-studio-2022-17-5-performance-enhancements/ -->
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>

<PropertyGroup Label="NuGet Audit">
<NuGetAudit>true</NuGetAudit>
<NuGetAuditMode>all</NuGetAuditMode>
<NuGetAuditLevel>low</NuGetAuditLevel>
</PropertyGroup>

<ItemGroup Label="Default Test Dependencies" Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="NSubstitute.Analyzers.CSharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.v3.extensibility.core"/>
<PackageReference Include="xunit.v3.assert" />
<PackageReference Include="xunit.runner.console">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Label="Default Analyzers">
<PackageReference Include="Roslynator.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Meziantou.Analyzer">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<!-- Block Projects with Privacy/Security/License Concerns -->
<Target Name="CheckBlockedPackages" AfterTargets="ResolvePackageDependenciesForBuild">
<Error Code="420" Text="Blocked package dependency detected: %(PackageDependencies.Identity)"
Condition="'%(PackageDependencies.Identity)' == 'Devlooped.SponsorLink'" />
<Error Code="420" Text="Blocked package dependency detected: %(PackageDependencies.Identity)"
Condition="'%(PackageDependencies.Identity)' == 'FluentAssertions'" />
</Target>

</Project>
42 changes: 28 additions & 14 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,54 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup Label=".NET Dependencies">
<ItemGroup Label="Dependencies">
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
</ItemGroup>

<ItemGroup Label="Tests / Performance">
<ItemGroup Label="Benchmarks">
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
</ItemGroup>

<ItemGroup Label="Tests">
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="9.4.0" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.console" Version="2.9.2">
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
<PackageVersion Include="xunit.v3" Version="2.0.1" />
<PackageVersion Include="xunit.v3.extensibility.core" Version="2.0.1" />
<PackageVersion Include="xunit.v3.assert" Version="2.0.1" />
<PackageVersion Include="xunit.runner.console" Version="2.9.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="coverlet.msbuild" Version="6.0.0">
</ItemGroup>

<ItemGroup Label="Analyzers">
<PackageVersion Include="Roslynator.Analyzers" Version="4.13.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
</ItemGroup>
<ItemGroup Label="Roslyn">
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.9">
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.13.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.9">
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.13.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.9">
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.13.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.13.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.195">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
Expand Down
10 changes: 5 additions & 5 deletions MyCSharp.HttpClientHints.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "9.0.100"
}
"sdk": {
"version": "10.0.100-preview.2.25164.34"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MyCSharp.HttpClientHints.AspNetCore\MyCSharp.HttpClientHints.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\HttpClientHints.AspNetCore\HttpClientHints.AspNetCore.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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())
Expand All @@ -44,5 +44,4 @@
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");


app.Run();
27 changes: 27 additions & 0 deletions src/HttpClientHints.AspNetCore/HttpClientHints.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Product>HTTP Client Hints Extensions for ASP.NET Core</Product>
<Description>HTTP Client Hints Extensions for ASP.NET Core</Description>
</PropertyGroup>

<PropertyGroup Label="Package">
<IsPackable>true</IsPackable>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>

<ItemGroup>
<None Include="readme.md" Pack="true" PackagePath="" />
<None Include="LICENSE.txt" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HttpClientHints\HttpClientHints.csproj" />
</ItemGroup>

</Project>
Loading