• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SamboyCoding / Cpp2IL / 12482099346

24 Dec 2024 01:06PM UTC coverage: 27.491%. Remained the same
12482099346

Pull #401

github

web-flow
Merge 5634335bc into 5d4be29eb
Pull Request #401: Fix lookup namespace for MethodInfo

1251 of 6376 branches covered (19.62%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

3360 of 10397 relevant lines covered (32.32%)

124804.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/Cpp2IL.Core/Utils/AsmResolver/TypeDefinitionsAsmResolver.cs
1
using System.Collections.Generic;
2
using System.Diagnostics.CodeAnalysis;
3
using AsmResolver.DotNet;
4

5
namespace Cpp2IL.Core.Utils.AsmResolver;
6

7
[SuppressMessage("ReSharper", "InconsistentNaming")]
8
public static class TypeDefinitionsAsmResolver
9
{
10
    private static Dictionary<string, TypeDefinition> _primitiveTypeMappings = new();
1✔
11

12
#nullable disable
13
    public static TypeDefinition Boolean;
14
    public static TypeDefinition SByte;
15
    public static TypeDefinition Byte;
16
    public static TypeDefinition Char;
17
    public static TypeDefinition Int16;
18
    public static TypeDefinition UInt16;
19
    public static TypeDefinition Int32;
20
    public static TypeDefinition UInt32;
21
    public static TypeDefinition Int64;
22
    public static TypeDefinition UInt64;
23
    public static TypeDefinition Single;
24
    public static TypeDefinition Double;
25
    public static TypeDefinition IntPtr;
26
    public static TypeDefinition UIntPtr;
27

28
    public static TypeDefinition Object;
29
    public static TypeDefinition IConvertible;
30
    public static TypeDefinition ValueType;
31
    public static TypeDefinition Enum;
32
    public static TypeDefinition Type;
33
    public static TypeDefinition TypedReference;
34
    public static TypeDefinition String;
35
    public static TypeDefinition Array;
36
    public static TypeDefinition IEnumerable;
37
    public static TypeDefinition Exception;
38
    public static TypeDefinition Void;
39
    public static TypeDefinition Attribute;
40
    public static TypeDefinition MethodInfo;
41
#nullable restore
42

43
    public static void Reset()
44
    {
45
        _primitiveTypeMappings.Clear();
30✔
46

47
        Boolean = null!;
30✔
48
        SByte = null!;
30✔
49
        Byte = null!;
30✔
50
        Char = null!;
30✔
51
        Int16 = null!;
30✔
52
        UInt16 = null!;
30✔
53
        Int32 = null!;
30✔
54
        UInt32 = null!;
30✔
55
        Int64 = null!;
30✔
56
        UInt64 = null!;
30✔
57
        Single = null!;
30✔
58
        Double = null!;
30✔
59
        IntPtr = null!;
30✔
60
        UIntPtr = null!;
30✔
61

62
        Object = null!;
30✔
63
        IConvertible = null!;
30✔
64
        ValueType = null!;
30✔
65
        Enum = null!;
30✔
66
        Type = null!;
30✔
67
        TypedReference = null!;
30✔
68
        String = null!;
30✔
69
        Array = null!;
30✔
70
        IEnumerable = null!;
30✔
71
        Exception = null!;
30✔
72
        Void = null!;
30✔
73
        Attribute = null!;
30✔
74
        MethodInfo = null!;
30✔
75
    }
30✔
76

77
    public static TypeDefinition? GetPrimitive(string name)
78
    {
79
        if (_primitiveTypeMappings.TryGetValue(name, out var ret))
×
80
            return ret;
×
81

82
        return null;
×
83
    }
84

85
    public static void CacheNeededTypeDefinitions()
86
    {
87
        Object = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Object")!;
×
88
        ValueType = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.ValueType")!;
×
89
        Enum = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Enum")!;
×
90
        String = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.String")!;
×
91
        Int64 = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Int64")!;
×
92
        Single = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Single")!;
×
93
        Double = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Double")!;
×
94
        Int32 = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Int32")!;
×
95
        UInt32 = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.UInt32")!;
×
96
        UInt64 = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.UInt64")!;
×
97
        IntPtr = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.IntPtr")!;
×
98
        UIntPtr = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.UIntPtr")!;
×
99
        Boolean = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Boolean")!;
×
100
        Array = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Array")!;
×
101
        IEnumerable = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Collections.IEnumerable")!;
×
102
        Exception = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Exception")!;
×
103
        Void = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Void")!;
×
104
        Attribute = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Attribute")!;
×
105
        SByte = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.SByte")!;
×
106
        Byte = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Byte")!;
×
107
        Boolean = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Boolean")!;
×
108
        Char = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Char")!;
×
109
        Int16 = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Int16")!;
×
110
        UInt16 = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.UInt16")!;
×
111
        Type = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Type")!;
×
112
        TypedReference = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.TypedReference")!;
×
113
        IConvertible = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.IConvertible")!;
×
NEW
114
        MethodInfo = AsmResolverUtils.TryLookupTypeDefKnownNotGeneric("System.Reflection.MethodInfo")!;
×
115

116

117
        _primitiveTypeMappings = new Dictionary<string, TypeDefinition>
×
118
        {
×
119
            { "string", String },
×
120
            { "long", Int64 },
×
121
            { "float", Single },
×
122
            { "double", Double },
×
123
            { "int", Int32 },
×
124
            { "bool", Boolean },
×
125
            { "uint", UInt32 },
×
126
            { "ulong", UInt64 }
×
127
        };
×
128
    }
×
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc