• 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

7.58
/Cpp2IL.Core/Model/CustomAttributes/AnalyzedCustomAttribute.cs
1
using System.Collections.Generic;
2
using System.Text;
3
using Cpp2IL.Core.Model.Contexts;
4

5
namespace Cpp2IL.Core.Model.CustomAttributes;
6

7
/// <summary>
8
/// A class which represents a managed custom attribute applied to some object (type, member, assembly).
9
/// </summary>
10
public class AnalyzedCustomAttribute(MethodAnalysisContext constructor)
12✔
11
{
12
    /// <summary>
13
    /// The constructor that is being used to create this custom attribute.
14
    /// </summary>
15
    public readonly MethodAnalysisContext Constructor = constructor;
12✔
16

17
    /// <summary>
18
    /// Any arguments that are passed to the constructor.
19
    /// </summary>
20
    public readonly List<BaseCustomAttributeParameter> ConstructorParameters = [];
12✔
21

22
    /// <summary>
23
    /// Any fields that are set on the custom attribute.
24
    /// </summary>
25
    public readonly List<CustomAttributeField> Fields = [];
12✔
26

27
    /// <summary>
28
    /// Any properties that are set on the custom attribute.
29
    /// </summary>
30
    public readonly List<CustomAttributeProperty> Properties = [];
12✔
31

32
    /// <summary>
33
    /// Returns true if this custom attribute's constructor has any parameters.
34
    /// </summary>
NEW
35
    public bool HasAnyParameters => Constructor.Parameters.Count > 0;
×
36

37
    /// <summary>
38
    /// Returns true if either the constructor has no parameters or if all of the parameters are assigned values.
39
    /// </summary>
NEW
40
    public bool IsSuitableForEmission => !HasAnyParameters || ConstructorParameters.Count == Constructor.Parameters.Count;
×
41

42
    public bool AnyFieldsOrPropsSet => Fields.Count + Properties.Count > 0;
×
43

44
    public override string ToString()
45
    {
46
        var sb = new StringBuilder("[");
×
47

48
        var attributeTypeName = Constructor.DeclaringType!.Name!;
×
49

50
        const string suffix = "Attribute";
51
        if (attributeTypeName.EndsWith(suffix))
×
52
            attributeTypeName = attributeTypeName[..^suffix.Length];
×
53

54
        sb.Append(attributeTypeName);
×
55

56
        if (HasAnyParameters || AnyFieldsOrPropsSet)
×
57
            sb.Append('(');
×
58

59
        if (!IsSuitableForEmission)
×
60
            sb.Append("/*Cpp2IL Warning: missing at least one required parameter*/");
×
61

62
        if (ConstructorParameters.Count + Fields.Count + Properties.Count > 0)
×
63
        {
64
            var needComma = false;
×
65

66
            foreach (var param in ConstructorParameters)
×
67
            {
68
                if (needComma)
×
69
                    sb.Append(", ");
×
70

71
                sb.Append(param);
×
72
                needComma = true;
×
73
            }
74

75
            foreach (var field in Fields)
×
76
            {
77
                if (needComma)
×
78
                    sb.Append(", ");
×
79

80
                sb.Append(field);
×
81
                needComma = true;
×
82
            }
83

84
            foreach (var prop in Properties)
×
85
            {
86
                if (needComma)
×
87
                    sb.Append(", ");
×
88

89
                sb.Append(prop);
×
90
                needComma = true;
×
91
            }
92
        }
93

94
        if (HasAnyParameters || AnyFieldsOrPropsSet)
×
95
            sb.Append(')');
×
96

97
        sb.Append(']');
×
98
        return sb.ToString();
×
99
    }
100
}
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