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

SamboyCoding / Cpp2IL / 15172433337

21 May 2025 08:57PM UTC coverage: 34.294% (+0.2%) from 34.062%
15172433337

Pull #462

github

web-flow
Merge 32601968e into 5807d2b6c
Pull Request #462: Support overriding member types

1801 of 6644 branches covered (27.11%)

Branch coverage included in aggregate %.

128 of 232 new or added lines in 35 files covered. (55.17%)

5 existing lines in 5 files now uncovered.

4199 of 10852 relevant lines covered (38.69%)

186271.78 hits per line

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

67.74
/Cpp2IL.Core/Model/Contexts/PropertyAnalysisContext.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 PropertyAnalysisContext : HasCustomAttributesAndName, IPropertyInfoProvider
10
{
11
    public TypeAnalysisContext DeclaringType { get; }
178,765✔
12
    public Il2CppPropertyDefinition? Definition { get; }
125,965✔
13

14
    public MethodAnalysisContext? Getter { get; }
15,362✔
15
    public MethodAnalysisContext? Setter { get; }
15,360✔
16

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

19
    public override AssemblyAnalysisContext CustomAttributeAssembly => DeclaringType.DeclaringAssembly;
163,404✔
20

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

23
    public virtual bool IsStatic => Definition?.IsStatic ?? throw new($"Subclasses must override {nameof(IsStatic)}.");
15,360!
24

25
    public virtual PropertyAttributes DefaultAttributes => (PropertyAttributes?)Definition?.attrs ?? throw new($"Subclasses must override {nameof(DefaultAttributes)}.");
15,360!
26

27
    public PropertyAttributes? OverrideAttributes { get; set; }
15,360✔
28

29
    public PropertyAttributes Attributes => OverrideAttributes ?? DefaultAttributes;
15,360!
30

31
    public virtual TypeAnalysisContext DefaultPropertyType => DeclaringType.DeclaringAssembly.ResolveIl2CppType(Definition?.RawPropertyType)
15,360!
32
        ?? throw new($"Subclasses must override {nameof(DefaultPropertyType)}.");
15,360✔
33

34
    public TypeAnalysisContext? OverridePropertyType { get; set; }
15,361✔
35

36
    public TypeAnalysisContext PropertyType => OverridePropertyType ?? DefaultPropertyType;
15,361✔
37

38
    public PropertyAnalysisContext(Il2CppPropertyDefinition definition, TypeAnalysisContext parent) : base(definition.token, parent.AppContext)
75,972✔
39
    {
40
        DeclaringType = parent;
75,972✔
41
        Definition = definition;
75,972✔
42

43
        InitCustomAttributeData();
75,972✔
44

45
        Getter = parent.GetMethod(definition.Getter);
75,972✔
46
        Setter = parent.GetMethod(definition.Setter);
75,972✔
47
    }
75,972✔
48

49
    protected PropertyAnalysisContext(MethodAnalysisContext? getter, MethodAnalysisContext? setter, TypeAnalysisContext parent) : base(0, parent.AppContext)
42✔
50
    {
51
        if (getter is null && setter is null)
42!
52
            throw new ArgumentException("Property must have at least one method");
×
53

54
        DeclaringType = parent;
42✔
55
        Getter = getter;
42✔
56
        Setter = setter;
42✔
57
    }
42✔
58

59
    public override string ToString() => $"Property:  {DeclaringType.Name}::{Name}";
×
60

61
    #region StableNameDotNet implementation
62

63
    public ITypeInfoProvider PropertyTypeInfoProvider
NEW
64
        => Definition!.RawPropertyType!.ThisOrElementIsGenericParam()
×
65
            ? new GenericParameterTypeInfoProviderWrapper(Definition.RawPropertyType!.GetGenericParamName())
×
66
            : TypeAnalysisContext.GetSndnProviderForType(AppContext, Definition.RawPropertyType!);
×
67

68
    public string PropertyName => Name;
×
69

70
    #endregion
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