Skip to content
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
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [10.0.0] - 2025-11-15

### Breaking Changes
- **Upgraded to .NET 10.0** - This version targets `net10.0` exclusively
- **Dropped support for all previous .NET versions** - .NET 9.0, 8.0, and earlier are no longer supported
- Users must upgrade to .NET 10.0 SDK to use this version

### Changed
- Updated all Microsoft.Extensions.* packages from 9.0.10 to 10.0.0
- Updated xUnit packages from 3.1.0 to 3.2.0
- Updated Microsoft.NET.Test.Sdk from 18.0.0 to 18.0.1
- Updated Azure DevOps build pipelines to use .NET 10.0.100 SDK

### Fixed
- Fixed lambda parameter naming conflict with C# `scoped` keyword in example tests

### Migration Guide
To migrate from version 9.x to 10.0.0:
1. Install .NET 10.0 SDK on your development machine
2. Update your project's `TargetFramework` to `net10.0`
3. Update package reference to version 10.0.0 or later:
```xml
<PackageReference Include="Xunit.Microsoft.DependencyInjection" Version="10.0.0" />
```
4. Rebuild and test your project

## [9.2.2] - Previous Release
- See git history for changes prior to version 10.0.0
26 changes: 13 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
</PropertyGroup>
<ItemGroup>
<!-- Microsoft.Extensions packages (core dependencies) -->
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0" />
<!-- xUnit packages -->
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.1.0" />
<PackageVersion Include="xunit.v3" Version="3.1.0" />
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.2.0" />
<PackageVersion Include="xunit.v3" Version="3.2.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<!-- Development and build tools -->
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
</ItemGroup>
</Project>
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
![Nuget](https://img.shields.io/nuget/v/Xunit.Microsoft.DependencyInjection)
![Nuget](https://img.shields.io/nuget/dt/Xunit.Microsoft.DependencyInjection)

# Xunit Dependency Injection framework - .NET 9.0
# Xunit Dependency Injection framework - .NET 10.0

Xunit does not support any built-in dependency injection features, therefore developers have to come up with a solution to recruit their favourite dependency injection framework in their tests.

Expand All @@ -15,7 +15,7 @@ This library brings **Microsoft's dependency injection container** to Xunit by l
## ✨ Key Features

- 🎯 **Multiple injection patterns** - Choose the approach that fits your team's style
- 🔑 **Keyed services support** - Full .NET 9.0 keyed services integration
- 🔑 **Keyed services support** - Full .NET 10.0 keyed services integration
- ⚙️ **Configuration integration** - Support for `appsettings.json`, user secrets, and environment variables
- 🧪 **Service lifetime management** - Transient, Scoped, and Singleton services work as expected
- 📦 **Microsoft.Extensions ecosystem** - Built on the same DI container used by ASP.NET Core
Expand All @@ -26,21 +26,22 @@ This library brings **Microsoft's dependency injection container** to Xunit by l

* For **xUnit** packages use Xunit.Microsoft.DependencyInjection versions **up to** 9.0.5
* For **xUnit.v3** packages use Xunit.Microsoft.DependencyInjection versions **from** 9.1.0
* For **.NET 10.0** use Xunit.Microsoft.DependencyInjection version **10.0.0 or later**

Also please check the [migration guide](https://xunit.net/docs/getting-started/v3/migration) from xUnit for test authors.

### Example on how to reference xunit.v3

```xml
<PackageReference Include="xunit.v3" Version="3.1.0" />
<PackageReference Include="xunit.v3" Version="3.2.0" />
```

## Getting started

### Prerequisites

Before you begin, ensure you have:
- **.NET 9.0 SDK** installed on your development machine
- **.NET 10.0 SDK** installed on your development machine
- **Visual Studio 2022** or **Visual Studio Code** with C# extension
- Basic understanding of dependency injection concepts
- Familiarity with xUnit testing framework
Expand Down
6 changes: 3 additions & 3 deletions azure-pipeline-PR.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
Major: 9
Major: 10
Minor: 0
Patch: 0
BuildConfiguration: Release
Expand All @@ -14,10 +14,10 @@ pool:
steps:
- script: echo Build Number $(name)
- task: UseDotNet@2
displayName: 'Use .NET 9.0 sdk'
displayName: 'Use .NET 10.0 sdk'
inputs:
packageType: sdk
version: 9.0.306
version: 10.0.100
installationPath: $(Agent.ToolsDirectory)/dotnet
- script: echo Started restoring the source code
- task: DotNetCoreCLI@2
Expand Down
10 changes: 5 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variables:
Major: 9
Minor: 2
Revision: 2
Major: 10
Minor: 0
Revision: 0
BuildConfiguration: Release

name: $(Major).$(Minor).$(Revision)
Expand All @@ -22,10 +22,10 @@ pool:
steps:
- script: echo Build Number $(name)
- task: UseDotNet@2
displayName: 'Use .NET 9.0 sdk'
displayName: 'Use .NET 10.0 sdk'
inputs:
packageType: sdk
version: 9.0.306
version: 10.0.100
installationPath: $(Agent.ToolsDirectory)/dotnet
- script: echo Started restoring the source code
- task: DotNetCoreCLI@2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ public void TestComplexFuncPatternWithMultipleServices()
{
// Arrange - Create a complex function that uses multiple services
Func<IScopedService, ISingletonService, ICalculator, string> complexOperation =
(scoped, singleton, calc) =>
(scopedSvc, singletonSvc, calc) =>
{
scoped.Increment();
singleton.IncrementGlobal();
return $"Scoped: {scoped.InstanceId}, Singleton: {singleton.InstanceId}, " +
$"ScopedCounter: {scoped.Counter}, GlobalCounter: {singleton.GlobalCounter}";
scopedSvc.Increment();
singletonSvc.IncrementGlobal();
return $"Scoped: {scopedSvc.InstanceId}, Singleton: {singletonSvc.InstanceId}, " +
$"ScopedCounter: {scopedSvc.Counter}, GlobalCounter: {singletonSvc.GlobalCounter}";
};

// Act - Execute complex operation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions src/Xunit.Microsoft.DependencyInjection.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Version configuration - can be overridden by build system -->
<Version Condition="'$(Version)' == ''">9.2.2</Version>
<Version Condition="'$(Version)' == ''">10.0.0</Version>

<!-- NuGet Package Properties -->
<PackageId>Xunit.Microsoft.DependencyInjection</PackageId>
Expand Down