Merge pull request #48 from ohadho/master

Allow CompositionProxyTypeBuilder to proxy objects with protected constructors
This commit is contained in:
Marko Lahma
2013-11-10 07:30:45 -08:00
4 changed files with 24 additions and 2 deletions

View File

@@ -197,8 +197,8 @@ namespace Spring.Proxy
{
il.Emit(OpCodes.Ldarg_S, i);
}
il.Emit(OpCodes.Newobj, TargetType.GetConstructor(
ReflectionUtils.GetParameterTypes(constructor.GetParameters())));
il.Emit(OpCodes.Newobj, constructor);
il.Emit(OpCodes.Stfld, targetInstance);
}

View File

@@ -169,6 +169,14 @@ namespace Spring.Context.Support
IApplicationContext context = ContextRegistry.GetContext("bingo");
}
[Test]
public void CanBuildProxyForClassWithProtectedConstructor()
{
CompositionProxyTypeBuilder typeBuilder = new CompositionProxyTypeBuilder();
typeBuilder.TargetType = typeof(ClassWithProtectedCtor);
typeBuilder.BuildProxyType();
}
[Test]
public void ClearWithDynamicProxies()
{

View File

@@ -0,0 +1,13 @@
namespace Spring.Objects
{
public class ClassWithProtectedCtor : IOther
{
protected ClassWithProtectedCtor()
{
}
public void Absquatulate()
{
}
}
}

View File

@@ -339,6 +339,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="HookableContextHandler.cs" />
<Compile Include="Objects\ClassWithProtectedCtor.cs" />
<Compile Include="Objects\ExpressionTestObject.cs" />
<Compile Include="Objects\Factory\Attributes\PostConstructAttributeTests.cs" />
<Compile Include="Objects\Factory\Attributes\AutowireByTypeNormalTests.cs" />