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

SamboyCoding / Cpp2IL / 13494977167

24 Feb 2025 09:38AM UTC coverage: 27.383% (+0.04%) from 27.341%
13494977167

Pull #414

github

web-flow
Merge 2fd947674 into 16c3a7581
Pull Request #414: Fix explicit interface method overrides

1261 of 6406 branches covered (19.68%)

Branch coverage included in aggregate %.

17 of 87 new or added lines in 10 files covered. (19.54%)

1 existing line in 1 file now uncovered.

3375 of 10524 relevant lines covered (32.07%)

123786.14 hits per line

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

36.11
/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; }
45,552✔
13

14
    public List<TypeAnalysisContext> GenericArguments { get; } = [];
560,844✔
15

NEW
16
    public override TypeAttributes TypeAttributes => GenericType.TypeAttributes;
×
17

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

20
    public override string DefaultNs => GenericType.Namespace;
×
21

22
    public sealed override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_GENERICINST;
×
23

24
    public sealed override bool IsGenericInstance => true;
×
25

26
    public sealed override int GenericParameterCount => GenericArguments.Count;
×
27

28
    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. 
×
29

30
    public GenericInstanceTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext referencedFrom) : base(referencedFrom)
61,068✔
31
    {
32
        //Generic type has to be a type definition
33
        var gClass = rawType.GetGenericClass();
61,068✔
34
        GenericType = AppContext.ResolveContextForType(gClass.TypeDefinition) ?? throw new($"Could not resolve type {gClass.TypeDefinition.FullName} for generic instance base type");
61,068!
35

36
        GenericArguments.AddRange(gClass.Context.ClassInst.Types.Select(referencedFrom.ResolveIl2CppType)!);
61,068✔
37
    }
61,068✔
38

39
    public GenericInstanceTypeAnalysisContext(TypeAnalysisContext genericType, IEnumerable<TypeAnalysisContext> genericArguments, AssemblyAnalysisContext referencedFrom) : base(referencedFrom)
168,950✔
40
    {
41
        GenericType = genericType;
168,950✔
42
        GenericArguments.AddRange(genericArguments);
168,950✔
43
        OverrideBaseType = genericType.BaseType;
168,950✔
44
    }
168,950✔
45

46
    public override string GetCSharpSourceString()
47
    {
48
        var sb = new StringBuilder();
×
49

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

60
            sb.Append(genericArgument.GetCSharpSourceString());
×
61
        }
62

63
        sb.Append('>');
×
64

65
        return sb.ToString();
×
66
    }
67
}
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