Skip to content

Migrate to .NET 9 with Microsoft.Extensions.DependencyInjection#43

Open
erichexter wants to merge 4 commits into
mhinze:masterfrom
erichexter:modernize-dotnet9
Open

Migrate to .NET 9 with Microsoft.Extensions.DependencyInjection#43
erichexter wants to merge 4 commits into
mhinze:masterfrom
erichexter:modernize-dotnet9

Conversation

@erichexter
Copy link
Copy Markdown

Summary

  • Drop all 6 legacy IoC container integrations (Autofac, Ninject, SimpleInjector, StructureMap, Unity, Windsor) — all are unmaintained, deprecated, or superseded by the standard .NET DI system
  • Add ShortBus.Extensions.DependencyInjection — a new integration package for Microsoft.Extensions.DependencyInjection, the standard DI container since .NET Core 1.0
  • Migrate all projects to SDK-style .csproj, targeting netstandard2.0 + net9.0
  • Add GitHub Actions CI with NuGet publish on v* tags
  • Update README with modern setup examples

New setup (3 lines)

services.AddShortBus();
services.AddShortBusHandlers(typeof(Program).Assembly);
var mediator = provider.GetRequiredService<IMediator>();

Breaking changes

  • Requires .NET Standard 2.0 or .NET 9 (drops .NET Framework 4.5 direct support, though netstandard2.0 covers .NET Framework 4.6.1+)
  • The 6 IoC container packages are removed — projects using them will need to switch to ShortBus.Extensions.DependencyInjection or implement IDependencyResolver directly
  • Derived-type handler resolution (e.g. registering a handler for Ping and calling with PingALing : Ping) was previously supported implicitly by StructureMap's variance handling but is not supported by MEDI's exact-type matching

Tests

8 tests passing covering: request/response, async request/response, multi-interface handlers, notifications, and container resolution.

🤖 Generated with Claude Code

erichexter and others added 4 commits May 23, 2026 11:39
Breaking changes:
- Drop all legacy IoC container integrations (Autofac, Ninject, SimpleInjector,
  StructureMap, Unity, Windsor) — all are unmaintained or superseded
- Add ShortBus.Extensions.DependencyInjection for Microsoft.Extensions.DI
  (the standard .NET DI since .NET Core 1.0)

What's new:
- SDK-style projects, netstandard2.0 + net9.0 targets
- services.AddShortBus() registers IMediator
- services.AddShortBusHandlers(assemblies) scans and registers all handler types
- ServiceProviderDependencyResolver wraps IServiceProvider as IDependencyResolver
- Directory.Build.props for shared version metadata (v2.0.0)
- GitHub Actions CI with NuGet publish on v* tags
- Updated README with MEDI setup examples

Co-Authored-By: Eric Hexter <eric.hexter@gmail.com>
- Add MediatorTests.cs: 30 tests covering sync/async request-response,
  exception capture, no-handler behavior, fan-out notifications, partial
  failures with AggregateException, DI registration, and DependencyResolver
- Fix TargetInvocationException wrapping in Mediator reflection calls;
  now unwraps using ExceptionDispatchInfo to preserve original exception type
- Fix nullable reference warnings across Mediator, Response, DependencyResolver
- Add coverlet.collector to test project for code coverage collection
- Exclude coverage output dirs from .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant