blob: 23b31c433254a9595d245412ca21eb92d524ea62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
namespace Mono.Linker
{
public class AttributeInfo
{
public Dictionary<ICustomAttributeProvider, CustomAttribute[]> CustomAttributes { get; }
public AttributeInfo ()
{
CustomAttributes = new Dictionary<ICustomAttributeProvider, CustomAttribute[]> ();
}
public void AddCustomAttributes (ICustomAttributeProvider provider, CustomAttribute[] customAttributes)
{
if (!CustomAttributes.TryGetValue (provider, out var existing)) {
CustomAttributes.Add (provider, customAttributes);
} else {
int existingLength = existing.Length;
Array.Resize (ref existing, existingLength + customAttributes.Length);
customAttributes.CopyTo (existing, existingLength);
CustomAttributes[provider] = existing;
}
}
}
}
|