public async Task <string> GenerateTypeScriptProxy(string packageName, CancellationToken cancellationToken = default) { var assembly = await _packages.FindAssemblyByNameAsync(packageName, cancellationToken); if (assembly == null) { return(null); } return(Pooling.StringBuilderPool.Scoped(sb => { var map = BuildTypeMap(assembly); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SideCar.polyfills.ts")) { if (stream != null) { using (var reader = new StreamReader(stream)) { var polyfills = reader.ReadToEnd(); sb.AppendLine(polyfills); } } } // // Interfaces: foreach (var type in map.Keys) { if (CanExportType(type)) { AppendInterface(sb, 0, type, map); } else if (type.IsEnum) { AppendEnum(sb, 0, type); } } // // Forwarding Classes: foreach (var type in map.Keys) { if (CanExportType(type)) { AppendClass(sb, 0, packageName, type, map); } else if (type.IsEnum) { AppendEnum(sb, 0, type); } } })); }
public async Task <string> GenerateTypeScriptProxy(string packageName, CancellationToken cancellationToken = default) { var assembly = await _packages.FindAssemblyByNameAsync(packageName, cancellationToken); if (assembly == null) { return(null); } return(Pooling.StringBuilderPool.Scoped(sb => { //sb.AppendLine($"declare module \"{packageName}\" {{"); //sb.AppendLine(); var map = BuildTypeMap(assembly); // // Interfaces: foreach (var type in map.Keys) { if (type.IsClass || type.IsInterface) { AppendInterface(sb, 0, type, map); } else if (type.IsEnum) { AppendEnum(sb, 0, type); } } // // Forwarding Classes: foreach (var type in map.Keys) { if (type.IsClass || type.IsInterface) { AppendClass(sb, 0, packageName, type, map); } else if (type.IsEnum) { AppendEnum(sb, 0, type); } } // sb.AppendLine("}"); // module })); }