-
Notifications
You must be signed in to change notification settings - Fork 1
/
DebugOperations.cs
40 lines (36 loc) · 1.6 KB
/
DebugOperations.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Reflection.Emit;
using JetBrains.Annotations;
namespace ILGeneratorExtensions
{
/// <summary>
/// Contains extension methods for operations useful to debuggers
/// </summary>
[PublicAPI]
public static class DebugOperations
{
/// <summary>
/// Performs no operation
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator NoOp(this ILGenerator generator) => generator.FluentEmit(OpCodes.Nop);
/// <summary>
/// Performs no operation
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator NoOperation(this ILGenerator generator) => generator.NoOp();
/// <summary>
/// Signals an attached debugger to break execution
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator Break(this ILGenerator generator) => generator.FluentEmit(OpCodes.Break);
/// <summary>
/// Signals an attached debugger to break execution
/// </summary>
/// <param name="generator">The <see cref="T:System.Reflection.Emit.ILGenerator" /> to emit instructions from</param>
[PublicAPI]
public static ILGenerator BreakInDebugger(this ILGenerator generator) => generator.Break();
}
}