static bool IsValidFieldOfType(this IDeclaredElement element, Type type) { IDeclaredType fieldType = element.GetValidatedFieldType(); if (fieldType == null) { return(false); } return(new CLRTypeName(fieldType.GetCLRName()) == new CLRTypeName(type.FullName)); }
static bool IsValidFieldOfType(this IDeclaredElement element, string typeFullName) { IDeclaredType fieldType = element.GetValidatedFieldType(); if (fieldType == null) { return(false); } return(fieldType.GetTypeElement().HasAttributeInstance(new ClrTypeName(typeFullName), false)); }
static bool IsValidFieldOfType(this IDeclaredElement element, Type type) { IDeclaredType fieldType = element.GetValidatedFieldType(); if (fieldType == null) { return(false); } #if RESHARPER_6 return(fieldType.GetClrName().FullName == type.FullName); #else return(new CLRTypeName(fieldType.GetCLRName()) == new CLRTypeName(type.FullName)); #endif }
public static IClass GetFirstGenericArgument(this IDeclaredElement element) { IDeclaredType fieldType = element.GetValidatedFieldType(); if (fieldType == null) { return(null); } var firstArgument = fieldType.GetSubstitution().Domain.First(); var referencedType = fieldType.GetSubstitution().Apply(firstArgument).GetScalarType(); if (referencedType != null) { return(referencedType.GetTypeElement() as IClass); } return(null); }