I am having trouble with extension methods. Another method was causing the same error, now I am having the same issue again. While compiling - visual studio is marking my extension method as ambiguous. But I am pretty sure this is the only implementation I have -
The extension method I have is -
public static class TypeInfoExtensions
{
/// <summary>
/// Gets the property dictionary.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="types">The types.</param>
/// <returns></returns>
public static IEnumerable<Dictionary<string, object>> GetPropertyDictionaryList<T>(this IEnumerable<TypeInfo> types) where T : Attribute
{
return types.Select(x => x.GetPropertyDictionary<T>());
}
/// <summary>
/// Gets the property dictionary.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="type">The type.</param>
/// <returns></returns>
public static Dictionary<string, object> GetPropertyDictionary<T>(this TypeInfo type) where T : Attribute
{
var dict = new Dictionary<string, object>();
return dict;
}
}
And it is used like this -
var model = ...... // other codes
var parameters = Assembly.GetAssembly(typeof (Model.Domain.Tenants.Tenant)).DefinedTypes;
model.AvailableProperties = parameters.GetPropertyDictionaryList<MessageTemplateItem>().ToList()
This is the only implementation I have, I just added it, but VS is showing this error -
Error 81 The call is ambiguous between the following methods or properties: 'SMP.Core.Extensions.TypeInfoExtensions.GetPropertyDictionary(System.Reflection.TypeInfo)' and 'SMP.Core.Extensions.TypeInfoExtensions.GetPropertyDictionary(System.Reflection.TypeInfo)'
I am thinking this might be a temporary error, may be cleaning the solution is not cleaning references or cache. But if any body else have faced this error, I would very much appreciate your feedback.
UPDATE Strangely enough this code works -
public static IEnumerable<Dictionary<string, object>> GetPropertyDictionaryList<T>(this IEnumerable<TypeInfo> types) where T : Attribute
{
return types.Select(x => GetPropertyDictionary<T>(x));
}
I am really confused now, so far I knew these are the same for an extension method -
GetPropertyDictionary<T>(x)
x.GetPropertyDictionary<T>()
Any ideas guys?