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

SamboyCoding / Cpp2IL / 22018529184

14 Feb 2026 01:49PM UTC coverage: 34.4%. Remained the same
22018529184

push

github

SamboyCoding
Fixed broken parenthesis

1819 of 6636 branches covered (27.41%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 2 files covered. (0.0%)

4212 of 10896 relevant lines covered (38.66%)

211063.27 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

9
namespace Cpp2IL.Core.Model.CustomAttributes;
10

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

28
    public Il2CppTypeEnum ArrType;
29

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

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

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

47
            //Save the actual enum type for later.
48
            EnumType = context.Binary.GetType(enumTypeIndex);
×
49

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

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

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

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

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

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

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

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

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

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

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