-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SetHandle accessibility Fix test. Use Marshal.InitHandle.
- Loading branch information
1 parent
923f6f5
commit 7b99f90
Showing
8 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...m.Runtime.InteropServices/tests/System/Runtime/InteropServices/Marshal/InitHandleTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Xunit; | ||
|
||
namespace System.Runtime.InteropServices.Tests | ||
{ | ||
public class InitHandleTests | ||
{ | ||
[Fact] | ||
public void InitHandle_SetsHandle() | ||
{ | ||
var safeHandle = new TestSafeHandle(); | ||
nint underlyingHandle = 42; | ||
|
||
Marshal.InitHandle(safeHandle, underlyingHandle); | ||
|
||
Assert.Equal((IntPtr)underlyingHandle, safeHandle.DangerousGetHandle()); | ||
} | ||
|
||
class TestSafeHandle : SafeHandle | ||
{ | ||
public TestSafeHandle() : base(IntPtr.Zero, true) { } | ||
|
||
public override bool IsInvalid => handle == IntPtr.Zero; | ||
|
||
protected override bool ReleaseHandle() => true; | ||
} | ||
} | ||
} |