dotnet / dotnet/extensions

Microsoft.Extensions.DependencyInjection.AutoActivation is not working.

Open
#7,499 1 comment 2 reactions 0 assignees View on GitHub
area-compliance bug untriaged
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

### Description

`Microsoft.Extensions.DependencyInjection.AutoActivation` is not working.

### Reproduction Steps

```csharp
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddActivatedSingleton();
Console.WriteLine("Build Before");
ServiceProvider provider = services.BuildServiceProvider();
Console.WriteLine("Build After");
provider.GetRequiredService();
Console.WriteLine("End");

class MyService
{
public MyService() => Console.WriteLine("MyService Created");
}
```

### Expected behavior

The expected output should be, in order:
`"Build Before"`
`"MyService Created"`
`"Build After"`
`"End"`

### Actual behavior

The actual output is:
`"Build Before"`
`"Build After"`
`"MyService Created"`
`"End"`

### Regression?

_No response_

### Known Workarounds

_No response_

### Configuration

```
Microsoft.Extensions.DependencyInjection: 10.0.7
Microsoft.Extensions.DependencyInjection.AutoActivation: 10.5.0

.NET SDK:
Version: 10.0.203
Commit: c23858a6d8
Workload version: 10.0.200-manifests.f8ca1cb9
MSBuild version: 18.3.3+c23858a6d

OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.203\
```

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.