Skip to content

Migrate solution to .slnx and add DI/startup test coverage for observability registrations - #25

Merged
frasermolyneux merged 5 commits into
mainfrom
copilot/modernise-dotnet-solution
Sep 1, 2026
Merged

frasermolyneux merged 5 commits into
mainfrom
copilot/modernise-dotnet-solution

Conversation

Copilot AI commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Repository still used a legacy .sln and had no test coverage for the package's DI/startup registration paths (AddObservability*), despite all projects already targeting net9.0;net10.0 with SDK-style project files.

Solution format

  • Converted src/MX.Observability.ApplicationInsights.sln to src/MX.Observability.ApplicationInsights.slnx via dotnet sln migrate; removed the legacy .sln.
  • Updated AGENTS.md and .github/copilot-instructions.md references accordingly.
  • Confirmed no legacy project format or workflow changes were needed: all projects are SDK-style, and the reusable dotnet-ci action already auto-discovers solutions and caches keyed on **/*.slnx.

Test coverage

Added unit tests for previously-untested DI wiring:

  • Core: AddObservabilityCore, AddAuditLogging, AddJobTelemetry — registration, lifetimes, safe-default option binding.
  • AspNetCore/WorkerService adapters: AddObservability registers core services and correctly wires TelemetryFilterProcessor into the Application Insights SDK's ITelemetryProcessorFactory pipeline:
services.AddObservability();
using var provider = services.BuildServiceProvider();

var factory = Assert.Single(provider.GetServices<ITelemetryProcessorFactory>());
Assert.IsType<TelemetryFilterProcessor>(factory.Create(new NullTelemetryProcessor()));

Dependency fix (test-only)

Referencing the AspNetCore/WorkerService adapter projects from the test project surfaced a diamond-dependency conflict: Microsoft.ApplicationInsights.AspNetCore 2.23.0 transitively pulls Microsoft.Extensions.DependencyInjection 2.1.1, which collides with the net9/net10 framework-provided version (CS0433 ambiguous ServiceCollection). Pinned an explicit Microsoft.Extensions.DependencyInjection 10.0.11 PackageReference in the test project only — no production package versions changed.

Copilot AI and others added 2 commits August 31, 2026 20:08
Co-authored-by: frasermolyneux <34033625+frasermolyneux@users.noreply.github.com>
Co-authored-by: frasermolyneux <34033625+frasermolyneux@users.noreply.github.com>
Copilot AI changed the title [WIP] Modernise .NET solution and target framework Migrate solution to .slnx and add DI/startup test coverage for observability registrations Aug 31, 2026
Copilot AI requested a review from frasermolyneux August 31, 2026 20:27
@frasermolyneux
frasermolyneux marked this pull request as ready for review August 31, 2026 20:28
Copilot AI lite review requested due to automatic review settings August 31, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are scoped to solution modernisation and additive test coverage, with only minor follow-up nits identified in the new test code.

Pull request overview

Modernises the repository’s solution format to .slnx and adds targeted unit tests that exercise the public DI/startup registration surface (AddObservability*) across the core library and host adapters, aligning with the repo’s multi-targeted net9/net10 setup.

Changes:

  • Migrated the solution from legacy .sln to SDK-style .slnx, removed the old .sln, and updated documentation references.
  • Added DI/startup-focused unit tests for core registrations (AddObservabilityCore, AddAuditLogging, AddJobTelemetry) and adapter registrations (ASP.NET Core + WorkerService AddObservability).
  • Updated the test project to reference adapter projects and pinned Microsoft.Extensions.DependencyInjection to avoid the known diamond-dependency ambiguity; added Microsoft.AspNetCore.App framework reference for adapter test compilation.
File summaries
File Description
src/MX.Observability.ApplicationInsights.Tests/Extensions/ServiceCollectionExtensionsTests.cs Adds unit tests covering core service registrations and option binding defaults/overrides.
src/MX.Observability.ApplicationInsights.Tests/AspNetCore/ServiceCollectionExtensionsTests.cs Adds unit tests for ASP.NET Core adapter DI wiring and telemetry-processor integration.
src/MX.Observability.ApplicationInsights.Tests/WorkerService/ServiceCollectionExtensionsTests.cs Adds unit tests for WorkerService adapter DI wiring and telemetry-processor integration.
src/MX.Observability.ApplicationInsights.Tests/MX.Observability.ApplicationInsights.Tests.csproj Adds adapter project references, framework reference, and pins DI package to resolve transitive conflicts.
src/MX.Observability.ApplicationInsights.slnx Introduces the new .slnx solution file.
src/MX.Observability.ApplicationInsights.sln Removes the legacy .sln solution file.
AGENTS.md Updates solution path and validation commands to use .slnx.
.github/copilot-instructions.md Updates solution path and validation commands to use .slnx.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI and others added 2 commits August 31, 2026 20:37
Co-authored-by: frasermolyneux <34033625+frasermolyneux@users.noreply.github.com>
Co-authored-by: frasermolyneux <34033625+frasermolyneux@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
nuget/Microsoft.Extensions.DependencyInjection 10.0.11 UnknownUnknown

Scanned Files

  • src/MX.Observability.ApplicationInsights.Tests/MX.Observability.ApplicationInsights.Tests.csproj

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modernise .NET solution and target framework

3 participants