public ITypeInfo[] GetGenericArguments() { if (!NullabilityInfo.IsEmpty() && this.HasItem()) { return new ITypeInfo[] { new TypeInfo(Type.GetGenericArguments()[0], NullabilityInfo.ForItem()) } } ; var args = Type.GetGenericArguments(); var argsNullability = NullabilityInfo.ForGenericArguments(NullabilityInfo, args); return(args.Select((x, i) => (ITypeInfo) new TypeInfo(x, argsNullability[i])).ToArray()); }
public static NullabilityInfo[] ForGenericArguments(NullabilityInfo nullabilityInfo, Type[] args) { if (nullabilityInfo.NullableInfo == null || nullabilityInfo.NullableInfo.Length < 2) { return(args.Select(x => new NullabilityInfo(nullabilityInfo.NullableContext, nullabilityInfo.NullableInfo)).ToArray()); } var result = new List <NullabilityInfo>(); var index = 1; foreach (var arg in args) { var argsLength = GetGenericArgumentsToSkip(arg); result.Add(argsLength == 0 ? Empty : new NullabilityInfo( nullabilityInfo.NullableContext, nullabilityInfo.NullableInfo.Skip(index).Take(argsLength).ToArray() ) ); index += argsLength; } return(result.ToArray()); }
private TypeInfo(Type type, IAttributeProvider memberInfo) { Type = type; Member = memberInfo; NullabilityInfo = NullabilityInfo.From(memberInfo); }
private TypeInfo(Type type, NullabilityInfo nullabilityInfo) { Type = type; NullabilityInfo = nullabilityInfo; }
public bool CanBeNull(NullabilityMode nullabilityMode) { return(!this.NeverNull() && NullabilityInfo.CanBeNull(nullabilityMode)); }
public ITypeInfo GetElementType() { return(new TypeInfo(Type.GetElementType(), NullabilityInfo.ForItem())); }
private RoslynTypeInfo(ITypeSymbol typeSymbol, IAttributeProvider memberInfo) { TypeSymbol = typeSymbol; Member = memberInfo; NullabilityInfo = NullabilityInfo.FromRoslyn(memberInfo); }
private RoslynTypeInfo(ITypeSymbol typeSymbol, NullabilityInfo nullabilityInfo) { TypeSymbol = typeSymbol; NullabilityInfo = nullabilityInfo; }