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

SamboyCoding / Cpp2IL / 12320749043

13 Dec 2024 06:07PM UTC coverage: 27.79% (-0.3%) from 28.128%
12320749043

Pull #393

github

web-flow
Merge b9caa35d0 into ac99859af
Pull Request #393: Add Type field to AttributeAttribute

1268 of 6370 branches covered (19.91%)

Branch coverage included in aggregate %.

3 of 93 new or added lines in 7 files covered. (3.23%)

45 existing lines in 4 files now uncovered.

3386 of 10377 relevant lines covered (32.63%)

123656.67 hits per line

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

23.64
/Cpp2IL.Core/Model/Contexts/SystemTypesContext.cs
1
using LibCpp2IL.BinaryStructures;
2

3
namespace Cpp2IL.Core.Model.Contexts;
4

5
public class SystemTypesContext
6
{
7
    private ApplicationAnalysisContext _appContext;
8

9
    public TypeAnalysisContext SystemObjectType { get; }
109,139✔
10
    public TypeAnalysisContext SystemVoidType { get; }
68,352✔
11
    public TypeAnalysisContext SystemBooleanType { get; }
21,846✔
12
    public TypeAnalysisContext SystemCharType { get; }
72✔
13
    public TypeAnalysisContext SystemSByteType { get; }
×
14
    public TypeAnalysisContext SystemByteType { get; }
36✔
15
    public TypeAnalysisContext SystemInt16Type { get; }
×
16
    public TypeAnalysisContext SystemUInt16Type { get; }
×
17
    public TypeAnalysisContext SystemInt32Type { get; }
79,410✔
18
    public TypeAnalysisContext SystemUInt32Type { get; }
36✔
19
    public TypeAnalysisContext SystemInt64Type { get; }
562✔
20
    public TypeAnalysisContext SystemUInt64Type { get; }
48✔
21
    public TypeAnalysisContext SystemSingleType { get; }
660✔
22
    public TypeAnalysisContext SystemDoubleType { get; }
×
23
    public TypeAnalysisContext SystemIntPtrType { get; }
9,582✔
24
    public TypeAnalysisContext SystemUIntPtrType { get; }
×
25
    public TypeAnalysisContext SystemExceptionType { get; }
×
26
    public TypeAnalysisContext SystemStringType { get; }
7,218✔
27
    public TypeAnalysisContext SystemTypedReferenceType { get; }
×
28
    public TypeAnalysisContext SystemTypeType { get; }
×
29
    public TypeAnalysisContext SystemAttributeType { get; }
×
30
    public TypeAnalysisContext? UnmanagedCallersOnlyAttributeType { get; }
×
31

32
    public SystemTypesContext(ApplicationAnalysisContext appContext)
16✔
33
    {
34
        _appContext = appContext;
16✔
35

36
        var systemAssembly = _appContext.GetAssemblyByName("mscorlib") ?? throw new("Could not find system assembly");
16!
37

38
        SystemObjectType = systemAssembly.GetTypeByFullName("System.Object")!;
16✔
39
        SystemVoidType = systemAssembly.GetTypeByFullName("System.Void")!;
16✔
40

41
        SystemBooleanType = systemAssembly.GetTypeByFullName("System.Boolean")!;
16✔
42
        SystemCharType = systemAssembly.GetTypeByFullName("System.Char")!;
16✔
43

44
        SystemSByteType = systemAssembly.GetTypeByFullName("System.SByte")!;
16✔
45
        SystemByteType = systemAssembly.GetTypeByFullName("System.Byte")!;
16✔
46

47
        SystemInt16Type = systemAssembly.GetTypeByFullName("System.Int16")!;
16✔
48
        SystemUInt16Type = systemAssembly.GetTypeByFullName("System.UInt16")!;
16✔
49

50
        SystemInt32Type = systemAssembly.GetTypeByFullName("System.Int32")!;
16✔
51
        SystemUInt32Type = systemAssembly.GetTypeByFullName("System.UInt32")!;
16✔
52

53
        SystemInt64Type = systemAssembly.GetTypeByFullName("System.Int64")!;
16✔
54
        SystemUInt64Type = systemAssembly.GetTypeByFullName("System.UInt64")!;
16✔
55

56
        SystemSingleType = systemAssembly.GetTypeByFullName("System.Single")!;
16✔
57
        SystemDoubleType = systemAssembly.GetTypeByFullName("System.Double")!;
16✔
58

59
        SystemIntPtrType = systemAssembly.GetTypeByFullName("System.IntPtr")!;
16✔
60
        SystemUIntPtrType = systemAssembly.GetTypeByFullName("System.UIntPtr")!;
16✔
61

62
        SystemStringType = systemAssembly.GetTypeByFullName("System.String")!;
16✔
63
        SystemTypedReferenceType = systemAssembly.GetTypeByFullName("System.TypedReference")!;
16✔
64
        SystemTypeType = systemAssembly.GetTypeByFullName("System.Type")!;
16✔
65

66
        SystemExceptionType = systemAssembly.GetTypeByFullName("System.Exception")!;
16✔
67
        SystemAttributeType = systemAssembly.GetTypeByFullName("System.Attribute")!;
16✔
68
        
69
        UnmanagedCallersOnlyAttributeType = systemAssembly.GetTypeByFullName("System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute");
16✔
70
    }
16✔
71

72
    public bool IsPrimitive(TypeAnalysisContext context)
73
    {
74
        return context == SystemBooleanType || 
×
75
               context == SystemCharType || 
×
76
               context == SystemSByteType || 
×
77
               context == SystemByteType ||
×
78
               context == SystemInt16Type || 
×
79
               context == SystemUInt16Type || 
×
80
               context == SystemInt32Type || 
×
81
               context == SystemUInt32Type || 
×
82
               context == SystemInt64Type ||
×
83
               context == SystemUInt64Type || 
×
84
               context == SystemSingleType || 
×
85
               context == SystemDoubleType || 
×
86
               context == SystemIntPtrType ||
×
87
               context == SystemUIntPtrType;
×
88
    }
89

90
    public bool TryGetIl2CppTypeEnum(TypeAnalysisContext context, out Il2CppTypeEnum value)
91
    {
NEW
92
        if (context == SystemBooleanType)
×
NEW
93
            value = Il2CppTypeEnum.IL2CPP_TYPE_BOOLEAN;
×
NEW
94
        else if (context == SystemCharType)
×
NEW
95
            value = Il2CppTypeEnum.IL2CPP_TYPE_CHAR;
×
NEW
96
        else if (context == SystemSByteType)
×
NEW
97
            value = Il2CppTypeEnum.IL2CPP_TYPE_I1;
×
NEW
98
        else if (context == SystemByteType)
×
NEW
99
            value = Il2CppTypeEnum.IL2CPP_TYPE_U1;
×
NEW
100
        else if (context == SystemInt16Type)
×
NEW
101
            value = Il2CppTypeEnum.IL2CPP_TYPE_I2;
×
NEW
102
        else if (context == SystemUInt16Type)
×
NEW
103
            value = Il2CppTypeEnum.IL2CPP_TYPE_U2;
×
NEW
104
        else if (context == SystemInt32Type)
×
NEW
105
            value = Il2CppTypeEnum.IL2CPP_TYPE_I4;
×
NEW
106
        else if (context == SystemUInt32Type)
×
NEW
107
            value = Il2CppTypeEnum.IL2CPP_TYPE_U4;
×
NEW
108
        else if (context == SystemInt64Type)
×
NEW
109
            value = Il2CppTypeEnum.IL2CPP_TYPE_I8;
×
NEW
110
        else if (context == SystemUInt64Type)
×
NEW
111
            value = Il2CppTypeEnum.IL2CPP_TYPE_U8;
×
NEW
112
        else if (context == SystemSingleType)
×
NEW
113
            value = Il2CppTypeEnum.IL2CPP_TYPE_R4;
×
NEW
114
        else if (context == SystemDoubleType)
×
NEW
115
            value = Il2CppTypeEnum.IL2CPP_TYPE_R8;
×
NEW
116
        else if (context == SystemIntPtrType)
×
NEW
117
            value = Il2CppTypeEnum.IL2CPP_TYPE_I;
×
NEW
118
        else if (context == SystemUIntPtrType)
×
NEW
119
            value = Il2CppTypeEnum.IL2CPP_TYPE_U;
×
NEW
120
        else if (context == SystemStringType)
×
NEW
121
            value = Il2CppTypeEnum.IL2CPP_TYPE_STRING;
×
NEW
122
        else if (context == SystemTypedReferenceType)
×
NEW
123
            value = Il2CppTypeEnum.IL2CPP_TYPE_TYPEDBYREF;
×
NEW
124
        else if (context == SystemObjectType)
×
NEW
125
            value = Il2CppTypeEnum.IL2CPP_TYPE_OBJECT;
×
NEW
126
        else if (context == SystemVoidType)
×
NEW
127
            value = Il2CppTypeEnum.IL2CPP_TYPE_VOID;
×
128
        else
129
        {
NEW
130
            value = default;
×
NEW
131
            return false;
×
132
        }
NEW
133
        return true;
×
134
    }
135
}
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