blob: 1d370d58aea3357eface4ac2770945d786fb98be (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
using Mono.Cecil;
using Mono.Documentation.Updater;
using Mono.Documentation.Util;
using System.Collections.Generic;
using System.Linq;
namespace mdoc.Mono.Documentation.Updater
{
public class DynamicTypeProvider
{
private const string DynamicAttributeFulleName = "System.Runtime.CompilerServices.DynamicAttribute";
private ICustomAttributeProvider provider;
public DynamicTypeProvider(ICustomAttributeProvider provider)
{
this.provider = provider;
}
public IList<bool> GetDynamicTypeFlags()
{
CustomAttribute dynamicAttribute = FindDynamicAttribute();
if (dynamicAttribute != null)
{
CustomAttributeArgument[] attributeValues = new CustomAttributeArgument[0];
if (dynamicAttribute.ConstructorArguments.Count > 0)
{
attributeValues = (CustomAttributeArgument[])dynamicAttribute.ConstructorArguments[0].Value;
}
return attributeValues.Select(t => (bool)t.Value).ToList();
}
return null;
}
private CustomAttribute FindDynamicAttribute()
{
if (provider.HasCustomAttributes)
{
return provider.CustomAttributes.SafeCast<CustomAttribute>().SingleOrDefault(ca => ca.GetDeclaringType() == DynamicAttributeFulleName);
}
return null;
}
}
}
|