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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Bugfixes:
- Proxying certain `[Serializable]` classes produces proxy types that fail PEVerify test (@stakx, #367)
- `private protected` methods are not intercepted (@CrispyDrone, #535)
- `System.UIntPtr` unsupported (@stakx, #546)
- DynamicProxy generates two modules when proceeding from a class proxy's protected method to the target, causing an `InvalidOperationException` when saving the generated assembly to disk (@stakx, #569)

Deprecations:
- Removed support for the .NET Framework < 4.5 and .NET Standard 1.x. (@stakx, #495, #496)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2004-2021 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Castle.DynamicProxy.Tests
{
using NUnit.Framework;

[TestFixture]
public class ClassProxyWithTargetTestCase : BasePEVerifyTestCase
{
[Test]
public void Forwards_to_protected_method()
{
var proxy = generator.CreateClassProxyWithTarget(new ClassWithProtectedMethod());
Assert.AreEqual(42, proxy.InvokeFortyTwo());
}

public class ClassWithProtectedMethod
{
public int InvokeFortyTwo()
{
return FortyTwo();
}

protected virtual int FortyTwo()
{
return 42;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ private AbstractTypeEmitter GetEmitter(ClassEmitter @class, INamingScope namingS
uniqueName,
typeof(MulticastDelegate),
Type.EmptyTypes,
DelegateFlags);
DelegateFlags,
forceUnsigned: @class.InStrongNamedModule == false);
@delegate.CopyGenericParametersFromMethod(method.Method);
return @delegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public ClassEmitter(ModuleScope modulescope, string name, Type baseType, IEnumer
{
}

public ClassEmitter(ModuleScope modulescope, string name, Type baseType, IEnumerable<Type> interfaces,
TypeAttributes flags)
: this(modulescope, name, baseType, interfaces, flags, forceUnsigned: false)
{
}

public ClassEmitter(ModuleScope modulescope, string name, Type baseType, IEnumerable<Type> interfaces,
TypeAttributes flags,
bool forceUnsigned)
Expand Down