public TypeScriptType BuildAndImportType(TypeScriptUnit targetUnit, IAttributeProvider?attributeProvider, ITypeInfo typeInfo) { var(isNullable, resultType) = TypeScriptGeneratorHelpers.ProcessNullable(attributeProvider, typeInfo, Options.NullabilityMode); var targetType = GetTypeScriptType(targetUnit, resultType, attributeProvider); return(TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(targetType, isNullable, Options)); }
public TypeScriptType BuildAndImportType([NotNull] TypeScriptUnit targetUnit, [CanBeNull] ICustomAttributeProvider customAttributeProvider, [NotNull] Type type) { var(isNullable, resultType) = TypeScriptGeneratorHelpers.ProcessNullable(customAttributeProvider, type, Options.NullabilityMode); var targetType = GetTypeScriptType(targetUnit, resultType, customAttributeProvider); return(TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(targetType, isNullable, Options)); }
private TypeScriptType GetMaybeNullableComplexType(TypeScriptUnit unit, ITypeInfo type, IPropertyInfo property, bool isNullable) { var propertyType = BuildAndImportType(unit, property, type); if (property.PropertyType.IsGenericParameter) { propertyType = new TypeScriptTypeReference(property.PropertyType.Name); } return(TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(propertyType, isNullable, Options)); }
public TypeScriptTypeMemberDeclaration?ResolveProperty(TypeScriptUnit unit, ITypeInfo typeInfo, IPropertyInfo propertyInfo) { var customMemberDeclaration = customTypeGenerator.ResolveProperty(unit, this, typeInfo, propertyInfo); if (customMemberDeclaration != null) { return(customMemberDeclaration); } if (propertyInfo.IsNameDefined(nameof(ContractGeneratorIgnoreAttribute))) { return(null); } var(isNullable, trueType) = TypeScriptGeneratorHelpers.ProcessNullable(propertyInfo, propertyInfo.PropertyType, Options.NullabilityMode); return(new TypeScriptTypeMemberDeclaration { Name = propertyInfo.Name.ToLowerCamelCase(), Optional = isNullable && Options.EnableOptionalProperties, Type = GetMaybeNullableComplexType(unit, trueType, propertyInfo, isNullable), }); }
public TypeScriptTypeMemberDeclaration ResolveProperty([NotNull] TypeScriptUnit unit, [NotNull] Type type, [NotNull] PropertyInfo property) { var customMemberDeclaration = customTypeGenerator.ResolveProperty(unit, this, type, property); if (customMemberDeclaration != null) { return(customMemberDeclaration); } if (property.GetCustomAttributes <ContractGeneratorIgnoreAttribute>().Any()) { return(null); } var(isNullable, trueType) = TypeScriptGeneratorHelpers.ProcessNullable(property, property.PropertyType, Options.NullabilityMode); return(new TypeScriptTypeMemberDeclaration { Name = property.Name.ToLowerCamelCase(), Optional = isNullable && Options.EnableOptionalProperties, Type = GetMaybeNullableComplexType(unit, trueType, property, isNullable), }); }