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

SamboyCoding / Cpp2IL / 12482300272

24 Dec 2024 01:24PM UTC coverage: 27.487%. Remained the same
12482300272

push

github

gompoc
Fix construction of GenericParameterSignature

1251 of 6376 branches covered (19.62%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

3360 of 10399 relevant lines covered (32.31%)

124780.1 hits per line

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

0.0
/Cpp2IL.Core/Utils/AsmResolver/ContextToTypeSignature.cs
1
using System;
2
using System.Linq;
3
using AsmResolver.DotNet;
4
using AsmResolver.DotNet.Signatures;
5
using Cpp2IL.Core.Model.Contexts;
6
using LibCpp2IL.BinaryStructures;
7

8
namespace Cpp2IL.Core.Utils.AsmResolver;
9

10
public static class ContextToTypeSignature
11
{
12
    private static TypeDefinition GetTypeDefinition(this TypeAnalysisContext context)
13
    {
14
        return context.GetExtraData<TypeDefinition>("AsmResolverType") ?? throw new($"AsmResolver type not found in type analysis context for {context.FullName}");
×
15
    }
16

17
    public static TypeSignature ToTypeSignature(this TypeAnalysisContext context, ModuleDefinition parentModule) => context switch
×
18
    {
×
19
        GenericParameterTypeAnalysisContext genericParameterTypeAnalysisContext => genericParameterTypeAnalysisContext.ToTypeSignature(parentModule),
×
20
        GenericInstanceTypeAnalysisContext genericInstanceTypeAnalysisContext => genericInstanceTypeAnalysisContext.ToTypeSignature(parentModule),
×
21
        WrappedTypeAnalysisContext wrappedTypeAnalysisContext => wrappedTypeAnalysisContext.ToTypeSignature(parentModule),
×
22
        _ => parentModule.DefaultImporter.ImportType(context.GetTypeDefinition()).ToTypeSignature()
×
23
    };
×
24

25
    public static TypeSignature ToTypeSignature(this GenericInstanceTypeAnalysisContext context, ModuleDefinition parentModule)
26
    {
27
        var genericType = context.GenericType.ToTypeSignature(parentModule).ToTypeDefOrRef();
×
28
        var genericArguments = context.GenericArguments.Select(a => a.ToTypeSignature(parentModule)).ToArray();
×
29

30
        return new GenericInstanceTypeSignature(genericType, context.IsValueType, genericArguments);
×
31
    }
32

33
    public static TypeSignature ToTypeSignature(this GenericParameterTypeAnalysisContext context, ModuleDefinition parentModule)
34
    {
NEW
35
        return new GenericParameterSignature(parentModule, context.Type == Il2CppTypeEnum.IL2CPP_TYPE_VAR ? GenericParameterType.Type : GenericParameterType.Method, context.Index);
×
36
    }
37

38
    public static TypeSignature ToTypeSignature(this WrappedTypeAnalysisContext context, ModuleDefinition parentModule) => context switch
×
39
    {
×
40
        SzArrayTypeAnalysisContext szArrayTypeAnalysisContext => szArrayTypeAnalysisContext.ToTypeSignature(parentModule),
×
41
        PointerTypeAnalysisContext pointerTypeAnalysisContext => pointerTypeAnalysisContext.ToTypeSignature(parentModule),
×
42
        ByRefTypeAnalysisContext byReferenceTypeAnalysisContext => byReferenceTypeAnalysisContext.ToTypeSignature(parentModule),
×
43
        ArrayTypeAnalysisContext arrayTypeAnalysisContext => arrayTypeAnalysisContext.ToTypeSignature(parentModule),
×
44
        _ => throw new ArgumentException($"Unknown wrapped type context {context.GetType()}", nameof(context))
×
45
    };
×
46

47
    public static TypeSignature ToTypeSignature(this SzArrayTypeAnalysisContext context, ModuleDefinition parentModule)
48
    {
49
        return context.ElementType.ToTypeSignature(parentModule).MakeSzArrayType();
×
50
    }
51

52
    public static TypeSignature ToTypeSignature(this PointerTypeAnalysisContext context, ModuleDefinition parentModule)
53
    {
54
        return context.ElementType.ToTypeSignature(parentModule).MakePointerType();
×
55
    }
56

57
    public static TypeSignature ToTypeSignature(this ByRefTypeAnalysisContext context, ModuleDefinition parentModule)
58
    {
59
        return context.ElementType.ToTypeSignature(parentModule).MakeByReferenceType();
×
60
    }
61

62
    public static TypeSignature ToTypeSignature(this ArrayTypeAnalysisContext context, ModuleDefinition parentModule)
63
    {
64
        return context.ElementType.ToTypeSignature(parentModule).MakeArrayTypeWithLowerBounds(context.Rank);
×
65
    }
66

67
    public static TypeSignature ToTypeSignature(this ParameterAnalysisContext context, ModuleDefinition parentModule)
68
    {
69
        return context.ParameterTypeContext.ToTypeSignature(parentModule);
×
70
    }
71

72
    public static TypeSignature ToTypeSignature(this FieldAnalysisContext context, ModuleDefinition parentModule)
73
    {
74
        return context.FieldTypeContext.ToTypeSignature(parentModule);
×
75
    }
76

77
    public static TypeSignature ToTypeSignature(this EventAnalysisContext context, ModuleDefinition parentModule)
78
    {
79
        return context.EventTypeContext.ToTypeSignature(parentModule);
×
80
    }
81

82
    public static TypeSignature ToTypeSignature(this PropertyAnalysisContext context, ModuleDefinition parentModule)
83
    {
84
        return context.PropertyTypeContext.ToTypeSignature(parentModule);
×
85
    }
86
}
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