Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
114bdd8
chore(package): deterministic CI builds and accurate package metadata
BenjaminAbt Nov 24, 2026
7e1bc8b
ci: check formatting, pin nbgv and add Dependabot
BenjaminAbt Nov 24, 2026
a333e16
docs: private vulnerability reporting and project instructions
BenjaminAbt Nov 24, 2026
fd9df97
ci: combine the coverage reports per line in Assert-CodeCoverage.ps1
BenjaminAbt Nov 24, 2026
1cdfb81
feat: decode brand lists, string lists and booleans; add Bitness, Wow…
BenjaminAbt Nov 24, 2026
923c2f0
feat!: request only low-entropy hints by default, add Critical-CH and…
BenjaminAbt Nov 24, 2026
8f2fdb6
build: validate the packages against 3.3.5 and pack a 128 px icon
BenjaminAbt Nov 24, 2026
7338170
docs: document options, decoders, brand lists and package validation
BenjaminAbt Nov 24, 2026
49f49de
chore: remove the unused myCSharp.de NuGet logo
BenjaminAbt Nov 25, 2026
e34f122
ci: label pull requests for the release notes
BenjaminAbt Nov 25, 2026
25ec846
fix: allocate linearly when decoding lists of strings with escapes
BenjaminAbt Nov 25, 2026
0e0191d
fix: recognize the GREASE brands of older Chromium versions
BenjaminAbt Nov 25, 2026
786ee4c
fix: validate hint names, add Vary once, combine lines of list headers
BenjaminAbt Nov 25, 2026
f095c9a
ci: identify covered lines per class in the coverage gate
BenjaminAbt Nov 25, 2026
6209a2d
docs: document name validation, Vary, field lines and GREASE forms
BenjaminAbt Nov 25, 2026
238b4aa
docs: describe the required pull request checks for main
BenjaminAbt Nov 25, 2026
7d50664
perf: decode brand lists 41% faster with exact-size arrays
BenjaminAbt Nov 25, 2026
96ae616
perf: keep the decoded values in the snapshot record
BenjaminAbt Nov 25, 2026
7c44487
docs: describe decoding once per record and update the benchmarks
BenjaminAbt Nov 25, 2026
599e9f8
feat(middleware): merge Vary headers for response caching
BenjaminAbt Nov 25, 2026
d66fdfa
feat(middleware): enhance response header handling and validation
BenjaminAbt Nov 25, 2026
8d657c9
feat(workflows): improve draft release handling and validation
BenjaminAbt Nov 25, 2026
c232b65
feat(release): update release process and asset handling
BenjaminAbt Nov 25, 2026
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
35 changes: 34 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
- @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.
# Instructions for MyCSharp.HttpClientHints

## Projects

- `src/HttpClientHints`: package `MyCSharp.HttpClientHints` with the `HttpClientHints` record and `HttpClientHintsInterpreter`.
- `src/HttpClientHints.AspNetCore`: package `MyCSharp.HttpClientHints.AspNetCore` with the `Accept-CH` middleware, the `HttpContext` and `IHeaderDictionary` extensions and `IHttpClientHintsFeature`.
- `tests/*.UnitTests`: xUnit v3 tests on Microsoft.Testing.Platform. FluentAssertions is blocked; use `Assert`.
- `tests/HttpClientHints.NativeAot.Smoke`: Native AOT smoke test that roots both packages.
- `perf/HttpClientHints.Benchmarks`: BenchmarkDotNet benchmarks.

## Build and test

- The packages target .NET 8, 9, 10 and 11. Build with the .NET 11 SDK.
- `dotnet build -c Release` must not produce warnings: `TreatWarningsAsErrors` is enabled, with Roslynator, Meziantou and the trimming and AOT analyzers.
- Line and branch coverage of both packages must stay at 100 %: `just test-cov`.
- CI checks the formatting: `just format-check`.
- Native AOT: `dotnet publish tests/HttpClientHints.NativeAot.Smoke -c Release -f net11.0 -r <rid>` must publish without warnings, and the executable must exit with 0.

## Code

- Every C# file starts with `// Copyright © https://myCSharp.de - all rights reserved`.
- Do not use reflection or dynamic code generation; both packages are `IsAotCompatible`.
- Reading Client Hints is on the request path: avoid allocations, measure changes with the benchmarks.
- Public API is part of the NuGet packages: removing or changing members is a breaking change and needs a major version. `dotnet pack` validates the API against `PackageValidationBaselineVersion`; list intended breaking changes in `CompatibilitySuppressions.xml` with `-p:ApiCompatGenerateSuppressionFile=true`.
- Header values are HTTP Structured Fields (RFC 9651). Decode them with `HttpClientHintsInterpreter`, which uses the internal `StructuredFieldReader`.

## Documentation

- `readme.md` and the package readmes in `src/*/readme.md` describe the current behavior only. Do not add version history such as "Since 3.2".
- Link NuGet packages to `https://nubrowse.com/packages/<PackageId>`.

## Commits

Use Conventional Commits, for example `feat:`, `fix:`, `perf:`, `docs:`, `test:`, `ci:` and `chore:`, also for pull request titles: the PR Labeler workflow derives the release note category from the type, and `!` (for example `feat!:`) marks a breaking change.
40 changes: 40 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Dependabot version updates
# https://docs.github.com/code-security/dependabot/working-with-dependabot/dependabot-options-reference

version: 2
updates:
- package-ecosystem: nuget
directory: /
schedule:
interval: weekly
open-pull-requests-limit: 5
commit-message:
prefix: chore
include: scope
ignore:
# The packages reference the lowest version that supports .NET 8. A newer version would raise
# the minimum version for every consumer. NuGetAudit reports vulnerable versions in the build.
- dependency-name: Microsoft.Extensions.Primitives
groups:
analyzers:
patterns:
- Roslynator.*
- Meziantou.Analyzer
tests:
patterns:
- Microsoft.Testing.*
- xunit.*
benchmarks:
patterns:
- BenchmarkDotNet*

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
commit-message:
prefix: ci
groups:
github-actions:
patterns:
- "*"
102 changes: 2 additions & 100 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,108 +1,10 @@
# Release Drafter Configuration
# Documentation: https://github.com/release-drafter/release-drafter
# Release Drafter is used by pr-labeler.yml only for area labels.
template: $CHANGES

name-template: 'Version $RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'

# Categories for organizing release notes
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- 'fix'
- title: '🔧 Maintenance'
labels:
- 'maintenance'
- 'chore'
- 'refactor'
- 'dependencies'
- title: '📚 Documentation'
labels:
- 'documentation'
- 'docs'
- title: '⚡ Performance'
labels:
- 'performance'
- title: '🔒 Security'
labels:
- 'security'

# Exclude certain labels from release notes
exclude-labels:
- 'skip-changelog'
- 'wip'

# Change template (how each PR is listed)
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # Escape special markdown characters

# Template for the release body
template: |
## What's Changed

$CHANGES

## 📦 NuGet Packages

The following packages are included in this release:

- `MyCSharp.HttpClientHints`
- `MyCSharp.HttpClientHints.AspNetCore`

### Installation

```bash
dotnet add package MyCSharp.HttpClientHints
dotnet add package MyCSharp.HttpClientHints.AspNetCore
```

## Contributors

$CONTRIBUTORS

---

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

# Automatically label PRs based on modified files
autolabeler:
- label: 'documentation'
files:
- '*.md'
- 'docs/**/*'
- label: 'bug'
branch:
- '/fix\/.+/'
title:
- '/fix/i'
- label: 'feature'
branch:
- '/feature\/.+/'
title:
- '/feature/i'
- label: 'dependencies'
files:
- '**/packages.lock.json'
- '**/*.csproj'
- 'Directory.Packages.props'
- 'Directory.Build.props'
- label: 'github-actions'
files:
- '.github/workflows/**/*'
- label: 'tests'
files:
- 'tests/**/*'
- '**/*Tests.cs'
- '**/*Test.cs'
- label: 'performance'
files:
- 'perf/**/*'
- '**/*Benchmark*.cs'

# Version resolver (uses version from workflow input)
version-resolver:
default: patch
22 changes: 22 additions & 0 deletions .github/release-notes/4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Upgrading from 3.3.5

In 3.3.5, calling `AddHttpClientHints()` enabled `Platform`, `Architecture` and `Device` by default. In 4.0 the default response requests only `Sec-CH-UA` and `Sec-CH-UA-Mobile`. Applications that use the platform version, architecture or model must opt in to those hints.

```csharp
// 3.3.5
builder.Services.AddHttpClientHints();
```

```csharp
// 4.0
builder.Services.AddHttpClientHints(options =>
{
options.Platform = true;
options.Architecture = true;
options.Device = true;
});
```

In 4.0, `Architecture` also requests `Sec-CH-UA-WoW64` and `Device` also requests `Sec-CH-UA-Form-Factors`. To request individual hints, list their field names in `options.Additional`.

If your application used `Configure<HttpClientHintsMiddlewareConfig>(...)`, move that configuration into the `AddHttpClientHints` callback. Replace direct registration through `app.UseMiddleware<HttpClientHintsRequestMiddleware>()` with `app.UseHttpClientHints()`. Both implementation types are now internal.
20 changes: 20 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
changelog:
exclude:
labels: [skip-changelog, wip]
categories:
- title: '💥 Breaking Changes'
labels: [breaking-change]
- title: '🚀 Features'
labels: [feature, enhancement]
- title: '🐛 Bug Fixes'
labels: [bug, fix]
- title: '🔧 Maintenance'
labels: [maintenance, chore, refactor, dependencies]
- title: '📚 Documentation'
labels: [documentation, docs]
- title: '⚡ Performance'
labels: [performance]
- title: '🔒 Security'
labels: [security]
- title: Other changes
labels: ['*']
30 changes: 26 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # Required for GitVersion
fetch-depth: 0 # NBGV calculates the version from Git history

- name: Test release draft ownership and retries
run: python3 -B -m unittest discover -s tests/workflows

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand All @@ -52,7 +55,7 @@ jobs:
global-json-file: ./global.json

- name: Calculate Version with NBGV
uses: dotnet/nbgv@master
uses: dotnet/nbgv@v0.5.2
id: nbgv
with:
setAllVars: true
Expand All @@ -64,6 +67,9 @@ jobs:
- name: Restore dependencies
run: dotnet restore

- name: Check formatting
run: dotnet format --verify-no-changes --no-restore --verbosity minimal

- name: Build
run: dotnet build --configuration ${{ inputs.configuration }} --no-restore /p:Version=${{ steps.nbgv.outputs.SemVer2 }}

Expand All @@ -83,10 +89,24 @@ jobs:
**/TestResults/**/*.trx
**/TestResults/**/*.cobertura.xml

- name: Pack NuGet packages
if: inputs.create-pack
# Every build packs: package validation compares the API with the baseline version on NuGet.org
- name: Pack and validate NuGet packages
run: dotnet pack --configuration ${{ inputs.configuration }} --no-build --output ./artifacts /p:PackageVersion=${{ steps.nbgv.outputs.SemVer2 }}

- name: Run the public API smoke test against the packed NuGet files
shell: bash
env:
PACKAGE_VERSION: ${{ steps.nbgv.outputs.SemVer2 }}
run: |
consumer=$(mktemp -d)
export NUGET_PACKAGES="$consumer/packages"
dotnet new console --name Consumer --output "$consumer" --framework net11.0 --no-restore
cp tests/HttpClientHints.NativeAot.Smoke/Program.cs "$consumer/Program.cs"
project="$consumer/Consumer.csproj"
dotnet add "$project" package MyCSharp.HttpClientHints.AspNetCore --version "$PACKAGE_VERSION" --no-restore
dotnet restore "$project" --source "$PWD/artifacts" -p:NuGetAudit=false
dotnet run --project "$project" --configuration Release --no-restore

- name: Upload NuGet packages
if: inputs.create-pack
uses: actions/upload-artifact@v6
Expand All @@ -106,6 +126,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand Down
Loading