Upgrade to .NET 10 and modernize project infrastructure#48
Conversation
Upgraded all projects to .NET 10 (net10.0) and updated API Versioning packages to 10.0.0-preview.1. Overhauled .editorconfig for modern C# style, formatting, and naming conventions. Refactored codebase for .NET 10 compatibility, including property-based API Versioning usage, improved minimal API/controller patterns, and streamlined test host setup. Suppressed CA1707 in test projects. Performed general code cleanup, improved documentation, and ensured consistency across all files.
Removed the legacy Visual Studio .sln file and added a new .slnx solution file in XML format. The new file organizes projects and solution items into folders, providing a clearer and more structured project hierarchy. This change supports modern tooling and improves solution maintainability.
Replaced xUnit v2 packages with xunit.v3 and updated xunit.runner.visualstudio. Refactored test code to use TestContext.Current.CancellationToken for async HTTP calls, ensuring compatibility with xUnit v3. Removed xunit.runner.json (no longer needed in v3). Simplified global.json by removing msbuild-sdks. Added copilot-instructions.md to document FluentAssertions version constraint. Cleaned up unused usings and updated test.props references.
Updated multiple package versions in Directory.Packages.props, including Azure.Core, Microsoft.Extensions.*, OpenTelemetry, and test dependencies. Revised copilot-instructions.md to clarify FluentAssertions upgrade limits and added a constraint for Swashbuckle.AspNetCore due to breaking changes in Microsoft.OpenApi v2.
Added Api.http file containing example HTTP requests for /hello-world and /WeatherForecast endpoints, including variations with API versioning, custom actions, and resource IDs. This file aids in manual API testing and serves as documentation for available endpoints.
Replaced Docker Compose/Prometheus/Zipkin setup with .NET Aspire Dashboard for local metrics viewing. Updated README instructions and removed related config files to simplify observability setup.
There was a problem hiding this comment.
Pull request overview
Upgrades the ServiceLevelIndicators library and its samples/tests to .NET 10, modernizes solution/build tooling, and updates dependencies (notably xUnit v3 and OpenTelemetry) to newer compatible versions.
Changes:
- Move repository build to .NET 10 (SDK + target frameworks) and update versioning to
10.0-preview.{height}. - Migrate tests to xUnit v3 and update API-versioning-related code to match newer Asp.Versioning APIs.
- Modernize infrastructure: switch solution to
.slnx, refresh EditorConfig, and update local metrics viewing docs/scripts to use the Aspire Dashboard.
Reviewed changes
Copilot reviewed 48 out of 73 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| version.json | Bumps Nerdbank.GitVersioning version string to 10.x preview. |
| global.json | Pins repo SDK to 10.0.100 and removes msbuild-sdks section. |
| Directory.Build.props | Updates default TargetFramework to net10.0. |
| Directory.Packages.props | Central package upgrades (Asp.Versioning 10 preview, OpenTelemetry 1.15, xUnit v3, etc.). |
| .editorconfig | Replaces/modernizes formatting + analyzer settings. |
| README.md | Updates local metrics instructions to Aspire Dashboard. |
| .github/copilot-instructions.md | Adds repo-specific dependency constraints. |
| .gitignore | Removes ignore entry tied to deleted DockerOpenTelemetry output log file. |
| ServiceLevelIndicators.sln | Deletes legacy .sln. |
| ServiceLevelIndicators.slnx | Adds new VS 2026 .slnx solution format. |
| build/xunit.runner.json | Removes runner config file. |
| build/test.props | Switches test packages to xUnit v3 and removes runner json linkage; adds CA1707 suppression. |
| ServiceLevelIndicators/tests/ServiceLevelIndicatorTests.cs | Updates tests for new tooling; removes xUnit abstractions using. |
| ServiceLevelIndicators/tests/LocationIdTests.cs | Formatting-only adjustments. |
| ServiceLevelIndicators/tests/CustomerResourceIdTests.cs | Formatting-only adjustments. |
| ServiceLevelIndicators/src/ServiceLevelIndicatorOptions.cs | Formatting-only adjustments. |
| ServiceLevelIndicators/src/ServiceLevelIndicator.cs | Formatting-only adjustments. |
| ServiceLevelIndicators/src/MeasuredOperation.cs | Formatting-only adjustments. |
| ServiceLevelIndicators/src/IEnrichmentContext.cs | Formatting-only adjustments. |
| ServiceLevelIndicators/src/IEnrichment.cs | Minor formatting/whitespace adjustments. |
| ServiceLevelIndicators/src/ServiceLevelIndicatorMeterProviderBuilderExtensions.cs | Minor formatting/whitespace adjustments. |
| ServiceLevelIndicators.Asp/src/ServiceLevelIndicatorMiddleware.cs | Minor formatting + spacing adjustments. |
| ServiceLevelIndicators.Asp/src/ServiceLevelIndicatorServiceCollectionExtensions.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/WebEnrichmentContext.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/HttpContextExtensions.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/EndpointBuilderExtensions.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/HttpMethodEnrichment.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/Enrich.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/EnrichAsync.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/ServiceLevelIndicatorApplicationBuilderExtensions.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/ServiceLevelIndicatorAttribute.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/src/ServiceLevelIndicatorConvention.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/ServiceLevelIndicatorFeature.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/CustomerResourceIdAttribute.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/CustomerResourceIdMetadata.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/IServiceCollectionExtensions.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/IServiceLevelIndicatorBuilder.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/IServiceLevelIndicatorFeature.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/MeasureAttribute.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/src/MeasureMetadata.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/tests/TestHostBuilder.cs | Refactors host builder setup for newer APIs/style. |
| ServiceLevelIndicators.Asp/tests/TestController.cs | Minor formatting adjustments. |
| ServiceLevelIndicators.Asp/tests/TestEnrichment.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/tests/IServiceCollectionExtensions.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp/tests/ServiceLevelIndicatorAspTests.cs | Updates HTTP calls to pass xUnit v3 cancellation token; removes xUnit abstractions using. |
| ServiceLevelIndicators.Asp.ApiVersioning/src/ServiceLevelIndicatorServiceCollectionExtensions.cs | Formatting-only adjustments. |
| ServiceLevelIndicators.Asp.ApiVersioning/src/ApiVersionEnrichment.cs | Updates Asp.Versioning API usage (extension property). |
| ServiceLevelIndicators.Asp.ApiVersioning/tests/TestSingleController.cs | Using ordering/formatting changes. |
| ServiceLevelIndicators.Asp.ApiVersioning/tests/TestNeutralController.cs | Using ordering/formatting changes. |
| ServiceLevelIndicators.Asp.ApiVersioning/tests/TestDoubleController.cs | Using ordering/formatting changes. |
| ServiceLevelIndicators.Asp.ApiVersioning/tests/ServiceLevelIndicatorVersionedAspTests.cs | Updates HTTP calls to pass xUnit v3 cancellation token; removes xUnit abstractions using. |
| sample/GenerateSli/GenerateSli.csproj | Updates target framework to net10.0. |
| sample/GenerateSli/Program.cs | Trims trailing whitespace/blank lines. |
| sample/ConsoleApp/SampleConsoleSLI.csproj | Updates target framework to net10.0. |
| sample/ConsoleApp/Program.cs | Refactors logging setup; minor formatting (and introduces an extra semicolon). |
| sample/MinApi/Program.cs | Minor whitespace cleanup. |
| sample/MinApi/UserExt.cs | Minor whitespace/formatting cleanup. |
| sample/WebApi/Program.cs | Minor formatting-only change. |
| sample/WebApi/WeatherForecast.cs | Converts to file-scoped namespace and flattens class structure. |
| sample/WebApi/SampleApiMeters.cs | Converts to file-scoped namespace; formatting cleanup. |
| sample/WebApi/ConfigureServiceLevelIndicatorOptions.cs | Formatting-only change. |
| sample/WebApi/Controllers/WeatherForecastController.cs | Refactors GetWeather() to expression-bodied method. |
| sample/WebApi/Api.http | Adds HTTP scratch file for local testing. |
| sample/WebApiVersioned/Program.cs | Using re-ordering + fluent chaining refactor. |
| sample/WebApiVersioned/SampleVersionedWebApplicationSLI.csproj | Suppresses CA1707. |
| sample/WebApiVersioned/AddApiVersionMetadata.cs | Updates Asp.Versioning deprecation API usage. |
| sample/WebApiVersioned/ConfigureSwaggerDefaultOptions.cs | Using order cleanup. |
| sample/WebApiVersioned/Controllers/2023-06-06/HelloWorldController.cs | Formatting-only change. |
| sample/WebApiVersioned/Api.http | Adds HTTP scratch file for local testing. |
| sample/DockerOpenTelemetry/run.cmd | Replaces docker-compose setup with Aspire Dashboard container run command. |
| sample/DockerOpenTelemetry/docker-compose.yaml | Removes docker-compose stack. |
| sample/DockerOpenTelemetry/otel-collector-config.yaml | Removes OTEL collector config. |
| sample/DockerOpenTelemetry/prometheus.yaml | Removes Prometheus scrape config. |
Comments suppressed due to low confidence (3)
ServiceLevelIndicators/tests/ServiceLevelIndicatorTests.cs:13
ITestOutputHelperis referenced but there is nousingfor its namespace in this file. Unless xUnit v3 exposesITestOutputHelperunder theXunitnamespace, this will fail to compile; consider adding the appropriateusing(or fully-qualifying / adding a global using for it).
ServiceLevelIndicators.Asp/tests/ServiceLevelIndicatorAspTests.cs:15ITestOutputHelperis used but there is nousingfor its namespace in this file. If xUnit v3 still keepsITestOutputHelperin a separate namespace/package, the test project will not compile; add the appropriateusing(or a global using) so the type resolves consistently.
ServiceLevelIndicators.Asp.ApiVersioning/tests/ServiceLevelIndicatorVersionedAspTests.cs:21ITestOutputHelperis referenced but there is nousingfor its namespace in this file. Unless xUnit v3 exposes it directly underXunit, this will be a compile error; add the appropriateusing(or a global using) to keep the tests building.
public class ServiceLevelIndicatorVersionedAspTests : IDisposable
{
private const int MillisecondsDelay = 200;
private readonly Meter _meter;
private readonly MeterListener _meterListener;
private readonly ITestOutputHelper _output;
private KeyValuePair<string, object?>[] _actualTags;
private KeyValuePair<string, object?>[] _expectedTags;
private bool _callbackCalled;
private bool _disposedValue;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sample/DockerOpenTelemetry/run.cmd
Outdated
| @@ -1 +1 @@ | |||
| docker-compose up No newline at end of file | |||
| docker run --rm -it -d -p 18888:18888 -p 4317:18889 -e DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS=true -e DASHBOARD__OTLP__AUTHMODE=Unsecured --name aspire-dashboard mcr.microsoft.com/dotnet/aspire-dashboard:latest | |||
There was a problem hiding this comment.
This starts the Aspire dashboard with anonymous/unsecured mode enabled and publishes ports on all interfaces. To reduce the risk of accidental exposure, consider binding the published ports to localhost (e.g., 127.0.0.1:...) and/or adding an inline note in the script that this is for local dev only and should not be used on shared/remote hosts.
sample/ConsoleApp/Program.cs
Outdated
| }); | ||
| }) | ||
| })) | ||
| .AddSingleton<ServiceLevelIndicator>(); ; |
There was a problem hiding this comment.
There is an extra trailing semicolon after the service registration chain (.AddSingleton<ServiceLevelIndicator>(); ;). This compiles as an empty statement but should be removed to avoid lint/noise.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed unnecessary env vars from run.cmd docker command. Updated OpenTelemetry resource serviceName values in Program.cs for clarity. Minor formatting and whitespace adjustments.
Explicitly build the service provider and obtain an ILogger<Program> instance for logging. Also, adjust the catch block's closing brace for correct formatting.
- Add ServiceLevelIndicatorMinimalApiTests for minimal API SLI scenarios, including custom operation names, route param extraction, and enrichment. - Refactor ServiceLevelIndicatorAspTests: centralize metric validation, set MeterListener callback in constructor, and add tests for 404/500 cases. - Fix typos in ServiceLevelIndicator and documentation (CustomerResourceId). - Add unit tests for default meter usage, Record overloads, and MeasuredOperation double-dispose. - Update README and controller XML docs for correct tag names and typos. - Add /server_error endpoint to TestController for 500 error SLI testing.
Add validation to prevent multiple [CustomerResourceId] attributes on a single endpoint or controller action, throwing InvalidOperationException if violated. Update middleware and tests to reflect this constraint, and allow AddAttribute to accept nullable values. Improve test coverage and error reporting for this scenario.
- Add comprehensive XML documentation to public APIs for better IntelliSense and maintainability. - Log warnings in ServiceLevelIndicatorMiddleware when enrichments throw exceptions. - Refactor ServiceLevelIndicatorConvention to apply parameter metadata to all selectors and enforce single CustomerResourceIdAttribute. - Simplify ServiceLevelIndicatorOptions.Meter to an auto-property. - Validate required options in ServiceLevelIndicator constructor. - Apply minor code cleanups, formatting, and explicit access modifiers. - No breaking changes to the public API surface.
Upgrades the ServiceLevelIndicators library from .NET 8 to .NET 10, modernizes tooling, and updates all dependencies to their latest compatible versions.
Changes
Framework & SDK
Target framework: net8.0 → net10.0
SDK: 8.0.100 → 10.0.100 (stable)
Version: 8.0 → 10.0-preview.{height}
Solution format
Migrated from .sln to .slnx (VS 2026 XML-based solution format)
Deleted ServiceLevelIndicators.sln, added ServiceLevelIndicators.slnx
Test framework
Migrated from xUnit 2.8.0 to xUnit v3 (3.2.2)
Removed xunit.runner.json (no longer needed)
Updated async tests to use TestContext.Current.CancellationToken
Removed Xunit.Abstractions namespace references
Package upgrades (via Central Package Management)
Asp.Versioning packages → 10.0.0-preview.1 (extension methods → extension properties)
Azure.Core 1.44.0 → 1.51.1
OpenTelemetry 1.9.0 → 1.15.0
FluentAssertions 6.12.0 → 7.2.0
Microsoft.NET.Test.Sdk 17.9.0 → 18.3.0
coverlet.collector 6.0.2 → 8.0.0
Nerdbank.GitVersioning 3.6.143 → 3.9.50
All Microsoft.AspNetCore/Extensions packages → 10.0.3
Swashbuckle.AspNetCore kept at 6.8.1 (v10+ has breaking OpenAPI v2 changes)