|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
| 3 | +using System.Linq; |
3 | 4 | using System.Reflection.Metadata; |
4 | 5 |
|
5 | 6 | namespace Semmle.Extraction.CIL.Entities |
@@ -51,19 +52,29 @@ public override IEnumerable<IExtractionProduct> Contents |
51 | 52 | for (var index = 0; index < decoded.FixedArguments.Length; ++index) |
52 | 53 | { |
53 | 54 | var value = decoded.FixedArguments[index].Value; |
54 | | - var stringValue = value?.ToString(); |
55 | | - yield return Tuples.cil_attribute_positional_argument(this, index, stringValue ?? "null"); |
| 55 | + var stringValue = GetStringValue(value); |
| 56 | + yield return Tuples.cil_attribute_positional_argument(this, index, stringValue); |
56 | 57 | } |
57 | 58 |
|
58 | 59 | foreach (var p in decoded.NamedArguments) |
59 | 60 | { |
60 | 61 | var value = p.Value; |
61 | | - var stringValue = value?.ToString(); |
62 | | - yield return Tuples.cil_attribute_named_argument(this, p.Name, stringValue ?? "null"); |
| 62 | + var stringValue = GetStringValue(value); |
| 63 | + yield return Tuples.cil_attribute_named_argument(this, p.Name, stringValue); |
63 | 64 | } |
64 | 65 | } |
65 | 66 | } |
66 | 67 |
|
| 68 | + private static string GetStringValue(object? value) |
| 69 | + { |
| 70 | + if (value is System.Collections.Immutable.ImmutableArray<CustomAttributeTypedArgument<Type>> values) |
| 71 | + { |
| 72 | + return "[" + string.Join(",", values.Select(v => GetStringValue(v.Value))) + "]"; |
| 73 | + } |
| 74 | + |
| 75 | + return value?.ToString() ?? "null"; |
| 76 | + } |
| 77 | + |
67 | 78 | public static IEnumerable<IExtractionProduct> Populate(Context cx, IEntity @object, CustomAttributeHandleCollection attributes) |
68 | 79 | { |
69 | 80 | foreach (var attrib in attributes) |
|
0 commit comments