public static string GetTSValueTypeToCheck(TypeTranslation type, ITypeSymbol typeSymbol) { if (Helper.IsNumber(typeSymbol.SpecialType)) { return("Number"); } if (typeSymbol.SpecialType == SpecialType.System_Char) { return("TSChar"); } if (typeSymbol.SpecialType == SpecialType.System_Boolean) { return("Boolean"); } if (typeSymbol.TypeKind == TypeKind.Enum) { return("Number"); } if (typeSymbol.IsValueType) { return(type.Translate()); } return(null); }
public static string GetDefaultValue(TypeTranslation type, ITypeSymbol typeSymbol) { if (Helper.IsNumber(typeSymbol.SpecialType)) { return("0"); } if (typeSymbol.SpecialType == SpecialType.System_Char) { return("''"); } if (typeSymbol.SpecialType == SpecialType.System_Boolean) { return("false"); } if (typeSymbol.SpecialType == SpecialType.System_String) { return("null"); } if (typeSymbol.TypeKind == TypeKind.Enum) { return("0"); } if (typeSymbol.IsValueType) { if (type is GenericNameTranslation) { return($"<{type.Translate()}> structDefault({type.GetTypeIgnoreGeneric()})"); } else { return($"structDefault({type.GetTypeIgnoreGeneric()})"); } } return("null"); }