public TsZeroType GetTsNullability(PropertyInfo property) { // don't reference the assembly just to get the name of an attribute preventing the dependency conflicts var optional = property.CustomAttributes.All(x => x.AttributeType.Name != "RequiredAttribute"); return(TsZeroType.Optional(optional)); }
public TsZeroType GetTsNullability(PropertyInfo property) { if (property.PropertyType.IsValueType) { return(_defaultTo.GetTsNullability(property)); } var nullability = property.ToContextualProperty().Nullability; return(nullability switch { Namotion.Reflection.Nullability.NotNullable => TsZeroType.None(), Namotion.Reflection.Nullability.Nullable => TsZeroType.Nullable(), Namotion.Reflection.Nullability.Unknown => _defaultTo.GetTsNullability(property), { } unknown => throw new InvalidOperationException( $"Unknown value {unknown} for type {typeof(Namotion.Reflection.Nullability).FullName}") });
public TsZeroType GetTsNullability(PropertyInfo property) => TsZeroType.Optional( property.PropertyType.IsValueType && Nullable.GetUnderlyingType(property.PropertyType) != null);