8000 Add ReliabilityContract attributes. · jbialobr/libgit2sharp@093fca9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 093fca9

Browse files
committed
Add ReliabilityContract attributes.
1 parent 3715ec2 commit 093fca9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

LibGit2Sharp/Core/Handles/SafeHandleBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Runtime.ConstrainedExecution;
34
using System.Globalization;
45
using System.Runtime.InteropServices;
56
using System.Threading;
@@ -13,7 +14,7 @@ internal abstract class SafeHandleBase : SafeHandle
1314
#endif
1415

1516
/// <summary>
16-
/// This is set to non-zero when <see cref="NativeMethods.AddHandle"/> has
17+
/// This is set to 1 when <see cref="NativeMethods.AddHandle"/> has
1718
/// been called for this handle.
1819
/// </summary>
1920
private int registered = 0;
@@ -53,6 +54,7 @@ protected override void Dispose(bool disposing)
5354
UnregisterHandle();
5455
}
5556

57+
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
5658
private void UnregisterHandle()
5759
{
5860
int n = Interlocked.Decrement(ref registered);

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ public LibraryLifetimeObject()
4141
}
4242
}
4343

44+
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
4445
internal static void AddHandle()
4546
{
4647
Interlocked.Increment(ref handlesCount);
4748
}
4849

50+
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
4951
internal static void RemoveHandle()
5052
{
5153
int hCount = Interlocked.Decrement(ref handlesCount);

0 commit comments

Comments
 (0)
0