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

SamboyCoding / Cpp2IL / 22021596307

14 Feb 2026 05:41PM UTC coverage: 34.555% (+0.2%) from 34.4%
22021596307

push

github

SamboyCoding
Lib: Support v35, v38, v39

1847 of 6675 branches covered (27.67%)

Branch coverage included in aggregate %.

281 of 350 new or added lines in 34 files covered. (80.29%)

1 existing line in 1 file now uncovered.

4252 of 10975 relevant lines covered (38.74%)

219034.19 hits per line

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

33.33
/Cpp2IL.Core/Model/CustomAttributes/CustomAttributeArrayParameter.cs
1
using System.Collections.Generic;
2
using System.IO;
3
using System.Linq;
4
using Cpp2IL.Core.Extensions;
5
using Cpp2IL.Core.Model.Contexts;
6
using Cpp2IL.Core.Utils;
7
using LibCpp2IL.BinaryStructures;
8
using LibCpp2IL.Metadata;
9

10
namespace Cpp2IL.Core.Model.CustomAttributes;
11

12
/// <summary>
13
/// Represents a custom attribute parameter which is an array of other parameters, which can themselves potentially be arrays, enums, etc.
14
///
15
/// When parsing this, first check IsNullArray - if it's true, emit a null and continue.
16
///
17
/// Then check EnumType - if it's non-null, it means this is an enum array, not a simple primitive array, and the type of the enum should be used when emitting.
18
///
19
/// If it's null, use ArrType to determine the type of the array, which will be a primitive, string, or type.
20
///
21
/// Then read the ArrayElements list and output each one. Remember to type-prefix if ArrType is Object.
22
/// </summary>
23
public class CustomAttributeArrayParameter(AnalyzedCustomAttribute owner, CustomAttributeParameterKind kind, int index)
24
    : BaseCustomAttributeParameter(owner, kind, index)
1✔
25
{
26
    public bool IsNullArray;
27
    public Il2CppType? EnumType;
28

29
    public Il2CppTypeEnum ArrType;
30

31
    public List<BaseCustomAttributeParameter> ArrayElements = [];
1✔
32

33
    public override void ReadFromV29Blob(BinaryReader reader, ApplicationAnalysisContext context)
34
    {
35
        var arrLength = reader.BaseStream.ReadUnityCompressedInt();
1✔
36
        if (arrLength == -1)
1!
37
        {
38
            //Array length is -1 when the array itself is null
39
            IsNullArray = true;
×
40
            return;
×
41
        }
42

43
        ArrType = (Il2CppTypeEnum)reader.ReadByte();
1✔
44
        if (ArrType == Il2CppTypeEnum.IL2CPP_TYPE_ENUM)
1!
45
        {
46
            var enumTypeIndex = reader.BaseStream.ReadUnityCompressedInt();
×
47

48
            //Save the actual enum type for later.
NEW
49
            EnumType = context.Binary.GetType(Il2CppVariableWidthIndex<Il2CppType>.MakeTemporaryForFixedWidthUsage(enumTypeIndex)); //DynWidth: enumTypeIndex is already compressed, they didn't make it dynamic
×
50

51
            //We read as the primitive underlying type.
52
            var enumClass = EnumType.AsClass();
×
53
            ArrType = enumClass.EnumUnderlyingType.Type;
×
54
        }
55

56
        var arrayElementsAreTypePrefixed = reader.ReadBoolean();
1✔
57

58
        if (arrayElementsAreTypePrefixed && ArrType != Il2CppTypeEnum.IL2CPP_TYPE_OBJECT)
1!
59
            throw new("Array elements are type-prefixed, but the array type is not object");
×
60

61
        for (var i = 0; i < arrLength; i++)
2!
62
        {
63
            var thisType = ArrType;
×
64

65
            if (arrayElementsAreTypePrefixed)
×
66
                thisType = (Il2CppTypeEnum)reader.ReadByte();
×
67

68
            //ConstructParameterForType will handle reading the enum type
69
            var arrayElement = V29AttributeUtils.ConstructParameterForType(reader, context, thisType, Owner, CustomAttributeParameterKind.ArrayElement, i);
×
70

71
            arrayElement.ReadFromV29Blob(reader, context);
×
72

73
            ArrayElements.Add(arrayElement);
×
74
        }
75
    }
1✔
76

77
    public override string ToString()
78
    {
79
        if (IsNullArray)
×
80
            return "(array) null";
×
81

82
        var arrType = ArrType.ToString();
×
83
        if (EnumType != null)
×
84
            arrType = EnumType.AsClass().ToString();
×
85

86
        return $"new {arrType}[] {{{string.Join(", ", ArrayElements.Select(x => x.ToString()))}}}";
×
87
    }
88
}
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

© 2026 Coveralls, Inc