-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModifier.cs
49 lines (43 loc) · 1.86 KB
/
Modifier.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
41
42
43
44
45
46
47
48
49
using System;
namespace Cecil.AspectN
{
[Flags]
public enum Modifier
{
WithinClass = 0x1,
DerivedClassSameAssembly = 0x2,
NonDerivedClassSameAssembly = 0x4,
DerivedClassDifferentAssembly = 0x8,
NonDerivedClassDifferentAssembly = 0x10,
Static = 0x20,
Private = WithinClass,
PrivateProtected = WithinClass | DerivedClassSameAssembly,
Internal = WithinClass | DerivedClassSameAssembly | NonDerivedClassSameAssembly,
Protected = WithinClass | DerivedClassSameAssembly | DerivedClassDifferentAssembly,
ProtectedInternal = WithinClass | DerivedClassSameAssembly | NonDerivedClassSameAssembly | DerivedClassDifferentAssembly,
Public = WithinClass | DerivedClassSameAssembly | NonDerivedClassSameAssembly | DerivedClassDifferentAssembly | NonDerivedClassDifferentAssembly,
PrivateStatic = Private | Static,
PrivateProtectedStatic = PrivateProtected | Static,
InternalStatic = Internal | Static,
ProtectedStatic = Protected | Static,
ProtectedInternalStatic = ProtectedInternal | Static,
PublicStatic = Public | Static,
}
public static class ModifierExtensions
{
public static string ToDefinitionString(this Modifier modifier)
{
var str = (modifier & Modifier.Public) switch
{
Modifier.Public => "public",
Modifier.ProtectedInternal => "protectedinternal",
Modifier.Protected => "protected",
Modifier.Internal => "internal",
Modifier.PrivateProtected => "privateprotected",
Modifier.Private => "private",
_ => throw new ArgumentException($"Unknow modifier value ({modifier})")
};
return (modifier & Modifier.Static) == 0 ? str : str + " static";
}
}
}