blob: 472a5658b683c6d1f12e0d5f44e23c52a125972e (
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
|
using Mono.Cecil;
namespace Xamarin.Forms.Build.Tasks
{
static class PropertyDefinitionExtensions
{
// public static PropertyDefinition MakeGeneric (this PropertyDefinition self, GenericInstanceType declaringTypeReference)
// {
// if (declaringTypeReference == null)
// throw new ArgumentNullException ("declaringTypeReference");
// if (self == null)
// throw new ArgumentNullException ("self");
//
// var propertyType = declaringTypeReference.GenericArguments[((GenericParameter)self.PropertyType).Position];
// self.PropertyType = propertyType;
// self.SetMethod = self.SetMethod.MakeGeneric (propertyType).Resolve ();
// self.GetMethod.ReturnType = propertyType;
//
// return self;
// }
public static TypeReference ResolveGenericPropertyType(this PropertyDefinition self,
TypeReference declaringTypeReference)
{
if (self.PropertyType.IsGenericParameter)
{
return
((GenericInstanceType)declaringTypeReference).GenericArguments[((GenericParameter)self.PropertyType).Position];
}
return self.PropertyType;
}
}
}
|