Skip to content

Commit

Permalink
Make some adjustments for Windsor
Browse files Browse the repository at this point in the history
 * Windsor needs `TypeUtil.GetAllInterfaces`, so make it public again.

 * Windsor is currently relying on `DelegateProxyGenerator`, but there
   is now another, more public API to build delegate proxies (see PR
   #436) so that class can
   now be removed. The unit tests for it are rewritten in terms of the
   newer API to demonstrate that it is indeed a suitable replacement.
  • Loading branch information
stakx committed Jun 7, 2020
1 parent 67d3543 commit 66ad575
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ public class DelegateProxyTestCasE : BasePEVerifyTestCase
{
private Type GenerateProxyType<TDelegate>()
{
var scope = generator.ProxyBuilder.ModuleScope;
var proxyGenerator = new DelegateProxyGenerator(scope, typeof (TDelegate))
{
Logger = generator.ProxyBuilder.Logger
};
return proxyGenerator.GetProxyType();
var options = new ProxyGenerationOptions();
options.AddDelegateTypeMixin(typeof(TDelegate));
return generator.ProxyBuilder.CreateClassProxyType(typeof(object), null, options);
}

private T GetProxyInstance<T>(T func, params IInterceptor[] interceptors)
{
var type = GenerateProxyType<T>();
var instance = Activator.CreateInstance(type, func, interceptors);
var methodInfo = instance.GetType().GetMethod("Invoke");
return (T)(object)methodInfo.CreateDelegate(typeof(T), instance);
return (T)(object)ProxyUtil.CreateDelegateToMixin(instance, typeof(T));
}

[Test]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

133 changes: 0 additions & 133 deletions src/Castle.Core/DynamicProxy/Generators/DelegateProxyGenerator.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal static Type[] GetAllInterfaces(params Type[] types)
return Sort(interfaces);
}

internal static Type[] GetAllInterfaces(this Type type)
public static Type[] GetAllInterfaces(this Type type) // NOTE: also used by Windsor
{
return GetAllInterfaces(new[] { type });
}
Expand Down

0 comments on commit 66ad575

Please sign in to comment.