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

SamboyCoding / Cpp2IL / 15104858512

19 May 2025 05:13AM UTC coverage: 34.216% (+0.2%) from 34.047%
15104858512

Pull #462

github

web-flow
Merge e48d6c526 into cc6dfc6a8
Pull Request #462: Support overriding member types

1795 of 6644 branches covered (27.02%)

Branch coverage included in aggregate %.

105 of 190 new or added lines in 33 files covered. (55.26%)

5 existing lines in 5 files now uncovered.

4185 of 10833 relevant lines covered (38.63%)

185357.37 hits per line

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

44.74
/Cpp2IL.Core/Model/Contexts/GenericInstanceTypeAnalysisContext.cs
1
using System.Collections.Generic;
2
using System.Linq;
3
using System.Reflection;
4
using System.Text;
5
using Cpp2IL.Core.Utils;
6
using LibCpp2IL.BinaryStructures;
7

8
namespace Cpp2IL.Core.Model.Contexts;
9

10
public class GenericInstanceTypeAnalysisContext : ReferencedTypeAnalysisContext
11
{
12
    public TypeAnalysisContext GenericType { get; }
111,726✔
13

14
    public List<TypeAnalysisContext> GenericArguments { get; } = [];
1,117,506✔
15

16
    public override TypeAttributes DefaultAttributes => GenericType.DefaultAttributes;
327✔
17

18
    public override TypeAttributes? OverrideAttributes { get => GenericType.OverrideAttributes; set => GenericType.OverrideAttributes = value; }
327✔
19

20
    public override string DefaultName => $"{GenericType.Name}<{string.Join(", ", GenericArguments.Select(a => a.Name))}>";
×
21

NEW
22
    public override string DefaultNamespace => GenericType.Namespace;
×
23

24
    public override TypeAnalysisContext? DefaultBaseType { get; }
65✔
25

26
    public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_GENERICINST;
×
27

28
    public sealed override bool IsGenericInstance => true;
×
29

30
    public sealed override int GenericParameterCount => GenericArguments.Count;
×
31

32
    public sealed override bool IsValueType => GenericType.IsValueType; //We don't set a definition so the default implementation cannot determine if we're a value type or not. 
8,920✔
33

34
    public GenericInstanceTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext referencedFrom) : base(referencedFrom)
103,746✔
35
    {
36
        //Generic type has to be a type definition
37
        var gClass = rawType.GetGenericClass();
103,746✔
38
        GenericType = AppContext.ResolveContextForType(gClass.TypeDefinition) ?? throw new($"Could not resolve type {gClass.TypeDefinition.FullName} for generic instance base type");
103,746!
39

40
        GenericArguments.AddRange(gClass.Context.ClassInst.Types.Select(referencedFrom.ResolveIl2CppType)!);
103,746✔
41
    }
103,746✔
42

43
    public GenericInstanceTypeAnalysisContext(TypeAnalysisContext genericType, IEnumerable<TypeAnalysisContext> genericArguments, AssemblyAnalysisContext referencedFrom) : base(referencedFrom)
349,299✔
44
    {
45
        GenericType = genericType;
349,299✔
46
        GenericArguments.AddRange(genericArguments);
349,299✔
47
        DefaultBaseType = genericType.BaseType;
349,299✔
48
    }
349,299✔
49

50
    public override string GetCSharpSourceString()
51
    {
52
        var sb = new StringBuilder();
×
53

54
        sb.Append(GenericType.GetCSharpSourceString());
×
55
        sb.Append('<');
×
56
        var first = true;
×
57
        foreach (var genericArgument in GenericArguments)
×
58
        {
59
            if (!first)
×
60
                sb.Append(", ");
×
61
            else
62
                first = false;
×
63

64
            sb.Append(genericArgument.GetCSharpSourceString());
×
65
        }
66

67
        sb.Append('>');
×
68

69
        return sb.ToString();
×
70
    }
71
}
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