Skip to content

Commit

Permalink
Merge pull request #547 from stakx/uintptr
Browse files Browse the repository at this point in the history
Add support for `System.UIntPtr`
  • Loading branch information
stakx committed Jan 3, 2021
2 parents d58479a + adcc3dd commit c2dac3f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,9 @@
Enhancements:
- .NET Standard 2.0 and 2.1 support (@lg2de, #485)

Bugfixes:
- `System.UIntPtr` unsupported (@stakx, #546)

Deprecations:
- Removed support for the .NET Framework < 4.5 and .NET Standard 1.x. (@stakx, #495, #496)
- Removed support for Code Access Security (CAS). (@stakx, #502)
Expand Down
@@ -0,0 +1,23 @@
// 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.Interfaces
{
using System;

public interface IFooWithOutUIntPtr
{
int Bar(out UIntPtr i);
}
}
@@ -0,0 +1,23 @@
// 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.Interfaces
{
using System;

public interface IFooWithUIntPtr
{
UIntPtr Buffer(UInt32 index);
}
}
Expand Up @@ -158,6 +158,15 @@ public void Target_method_IntPtr()
Assert.AreEqual(IntPtr.Zero, result);
}

[Test]
public void Target_method_UIntPtr()
{
var proxy = CreateProxy<IFooWithUIntPtr>();
var result = new UIntPtr(123);
Assert.DoesNotThrow(() => result = proxy.Buffer(1u));
Assert.AreEqual(UIntPtr.Zero, result);
}

[Test]
public void Target_method_Nullable_parameters()
{
Expand Down Expand Up @@ -192,6 +201,15 @@ public void Target_method_out_IntPtr()
Assert.AreEqual(IntPtr.Zero, result);
}

[Test]
public void Target_method_out_UIntPtr()
{
var proxy = CreateProxy<IFooWithOutUIntPtr>();
var result = new UIntPtr(123);
Assert.DoesNotThrow(() => proxy.Bar(out result));
Assert.AreEqual(UIntPtr.Zero, result);
}

[Test]
public void Target_method_out_ref_parameters()
{
Expand Down
Expand Up @@ -72,7 +72,7 @@ private void EmitByRef(ILGenerator gen)

private bool IsPrimitiveOrClass(Type type)
{
if ((type.IsPrimitive && type != typeof(IntPtr)))
if (type.IsPrimitive && type != typeof(IntPtr) && type != typeof(UIntPtr))
{
return true;
}
Expand Down

0 comments on commit c2dac3f

Please sign in to comment.