/// <summary> /// Transforms the specified input assembly. /// </summary> /// <param name="inputAssemblyPath">The input assembly path.</param> /// <param name="outputPath">The output path.</param> /// <param name="transformerOptions">The transformer options.</param> /// <param name="filesCreated">The files created.</param> public void Transform(string inputAssemblyPath, string outputPath, SymbioticTransformerOptions transformerOptions, out IReadOnlyCollection <string> filesCreated) { if (string.IsNullOrEmpty(inputAssemblyPath) || !File.Exists(inputAssemblyPath)) { throw new ArgumentException($"The specified input assembly path does not exist: '{inputAssemblyPath}'.", nameof(inputAssemblyPath)); } if (string.IsNullOrEmpty(outputPath)) { throw new ArgumentException($"The specified output path is not valid: '{outputPath}'.", nameof(outputPath)); } if (transformerOptions == null) { throw new ArgumentNullException(nameof(transformerOptions)); } using (AssemblyResolutionManager assemblyResolver = TsAssemblyResolutionManager.Create(inputAssemblyPath, transformerOptions)) { TsTypeManager typeManager = new TsTypeManager(); Assembly assembly = Assembly.LoadFrom(inputAssemblyPath); IReadOnlyList <Assembly> assemblies = typeManager.DiscoverAssemblies(assembly); IReadOnlyList <Type> types = typeManager.DiscoverTypes(assemblies); IReadOnlyList <TsTypeSymbol> typeSymbols = typeManager.ResolveTypeSymbols(types); IFileSink fileSink = new DirectoryFileSink(outputPath); AuditingFileSink auditingFileSink = new AuditingFileSink(fileSink); TsSymbolWriter symbolWriter = new TsSymbolWriter(auditingFileSink); symbolWriter.WriteSymbols(typeSymbols); filesCreated = auditingFileSink.FilesCreated; } }
public void WriteTypeSymbols(Type type) { string expectedResourceQualifier = $@"Content\UnitTests\{type.Name}"; TsTypeManager manager = new TsTypeManager(); MemoryFileSink fileSink = new MemoryFileSink(); TsSymbolWriter symbolWriter = new TsSymbolWriter(fileSink); IReadOnlyList <Type> discoveredTypes = manager.DiscoverTypes(type); IReadOnlyList <TsTypeSymbol> symbols = manager.ResolveTypeSymbols(discoveredTypes); symbolWriter.WriteSymbols(symbols); IFileSource fileSource = AssemblyResourceFileSource.WithResourceQualifier( typeof(TsSymbolWriterTests).Assembly, expectedResourceQualifier); try { fileSource.AssertSameSource(fileSink.ToSource()); } catch { IFileSink debugFileSink = new DirectoryFileSink(Path.Combine(testTempPath, expectedResourceQualifier)); fileSink.CopyTo(debugFileSink); throw; } }