autofac / autofac/Autofac.Extras.DynamicProxy
EnableClassInterceptors does not take into account enum KeyFilter parameters in the constructor
- Dominant language
- C#
- Stars
- 108
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
## Describe the Bug
When using `EnableClassInterceptors()` and registering a class with `WithAttributeFiltering()`, parameters decorated with `KeyFilter` will not have their filter taken into account when trying to intercept the class
## Steps to Reproduce
```c#
using Autofac;
using Autofac.Extras.DynamicProxy;
using Autofac.Features.AttributeFilters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Pruebas
{
[TestClass]
public class TestClassWithKeyedAttributeConstructor
{
enum TestEnum { STRING_ONE }
public class ClassWithKeyedAttributeConstructor
{
private readonly string str;
public ClassWithKeyedAttributeConstructor([KeyFilter(TestEnum.STRING_ONE)] string str) => this.str = str;
public string GetStr() => str;
}
[TestMethod]
public void TestClassWithKeyedAttributeConstructorCannotBeIntercepted()
{
var builder = new ContainerBuilder();
builder.Register(c => "Hello").Keyed(TestEnum.STRING_ONE);
builder.Register(c => "World");
//builder.RegisterType().WithAttributeFiltering();
builder.RegisterType().WithAttributeFiltering().EnableClassInterceptors();
var container = builder.Build();
using var scope = container.BeginLifetimeScope();
Assert.AreEqual("Hello", scope.Resolve().GetStr());
}
}
}
```
## Expected Behavior
## Exception with Stack Trace
```text
Message:
Assert.AreEqual failed. Expected:. Actual:.
Stack Trace:
TestClassWithKeyedAttributeConstructor.TestClassWithKeyedAttributeConstructorCannotBeIntercepted() line 32
```
## Dependency Versions
Autofac: 8.1.1
Autofac.Extras.DynamicProxy: 7.1.0
MSTest: 3.6.2
## Additional Info
If we uncomment line 26 and comment line 27. The test will execute correctly.
Contributor guide
Assessment
This issue has not been assessed yet.