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

SamboyCoding / Cpp2IL / 15052278841

15 May 2025 06:16PM UTC coverage: 34.038% (-0.4%) from 34.453%
15052278841

push

github

SamboyCoding
Support injecting anything
* Nested types
* Events
* Properties
* Assemblies

Support additional metadata in injected assemblies

Make setter for TypeAnalysisContext::OverrideBaseType public

TypeAnalysisContext::InterfaceContexts as list rather than array

Fix sign bug

Support generic parameters on type contexts and method contexts

Make GenericParameterTypeAnalysisContext instances unique

Revert change to Il2CppGenericParameter::Index

Use attributes to determine if injected methods are static
* Also add hide by sig attribute for injected constructors

Support overrides on injected methods

In ControlFlowGraphOutputFormat, exclude injected assemblies

Ensure injected assemblies can't delete existing assemblies

Backing field on .NET Standard for injected method overrides

Implement requested change

1774 of 6622 branches covered (26.79%)

Branch coverage included in aggregate %.

147 of 196 new or added lines in 27 files covered. (75.0%)

53 existing lines in 2 files now uncovered.

4155 of 10797 relevant lines covered (38.48%)

188267.61 hits per line

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

59.18
/Cpp2IL.Core/Model/Contexts/EventAnalysisContext.cs
1
using System;
2
using System.Reflection;
3
using Cpp2IL.Core.Utils;
4
using LibCpp2IL.Metadata;
5
using StableNameDotNet.Providers;
6

7
namespace Cpp2IL.Core.Model.Contexts;
8

9
public class EventAnalysisContext : HasCustomAttributesAndName, IEventInfoProvider
10
{
11
    public readonly TypeAnalysisContext DeclaringType;
12
    public readonly Il2CppEventDefinition? Definition;
13
    public readonly MethodAnalysisContext? Adder;
14
    public readonly MethodAnalysisContext? Remover;
15
    public readonly MethodAnalysisContext? Invoker;
16

17
    protected override int CustomAttributeIndex => Definition?.customAttributeIndex ?? -1;
315!
18

19
    public override AssemblyAnalysisContext CustomAttributeAssembly => DeclaringType.DeclaringAssembly;
720✔
20

21
    public override string DefaultName => Definition?.Name ?? throw new($"Subclasses must override {nameof(DefaultName)}.");
75!
22

23
    public virtual EventAttributes EventAttributes => Definition?.EventAttributes ?? throw new($"Subclasses must override {nameof(EventAttributes)}.");
75!
24

25
    public virtual TypeAnalysisContext EventTypeContext => DeclaringType.DeclaringAssembly.ResolveIl2CppType(Definition?.RawType) ?? throw new($"Subclasses must override {nameof(EventAttributes)}.");
75!
26

NEW
27
    public virtual bool IsStatic => Definition?.IsStatic ?? throw new($"Subclasses must override {nameof(IsStatic)}.");
×
28

29
    public EventAnalysisContext(Il2CppEventDefinition definition, TypeAnalysisContext parent) : base(definition.token, parent.AppContext)
345✔
30
    {
31
        Definition = definition;
345✔
32
        DeclaringType = parent;
345✔
33

34
        InitCustomAttributeData();
345✔
35

36
        Adder = parent.GetMethod(definition.Adder);
345✔
37
        Remover = parent.GetMethod(definition.Remover);
345✔
38
        Invoker = parent.GetMethod(definition.Invoker);
345✔
39
    }
345✔
40

41
    protected EventAnalysisContext(MethodAnalysisContext? adder, MethodAnalysisContext? remover, MethodAnalysisContext? invoker, TypeAnalysisContext parent) : base(0, parent.AppContext)
42✔
42
    {
43
        if (adder is null && remover is null && invoker is null)
42!
NEW
44
            throw new ArgumentException("Event must have at least one method");
×
45

46
        DeclaringType = parent;
42✔
47
        Adder = adder;
42✔
48
        Remover = remover;
42✔
49
        Invoker = invoker;
42✔
50
    }
42✔
51

NEW
52
    public override string ToString() => $"Event: {DeclaringType.Name}::{Name}";
×
53

54
    #region StableNameDotNet Impl
55

NEW
56
    public ITypeInfoProvider EventTypeInfoProvider => Definition!.RawType!.ThisOrElementIsGenericParam()
×
57
        ? new GenericParameterTypeInfoProviderWrapper(Definition.RawType!.GetGenericParamName())
×
58
        : TypeAnalysisContext.GetSndnProviderForType(AppContext, Definition.RawType!);
×
59

NEW
60
    public string EventName => Name;
×
61

62
    #endregion
63
}
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