private static FileContent GetPublicSurface(ISourceFile originalFile, ITypeChecker checker) { using (var writer = new ScriptWriter()) { var printer = new PublicSurfacePrinter(writer, new SemanticModel(checker)); FileContent publicContent; var result = printer.TryPrintPublicSurface(originalFile, out publicContent); XAssert.IsTrue(result); return(publicContent); } }
private static bool TryPrintSurfaceForSpecs(Workspace workspace, bool skipTypeInference, out string result, params ISourceFile[] sourceFiles) { using (var writer = new ScriptWriter()) { var printer = new PublicSurfacePrinter(writer, workspace.GetSemanticModel(), skipTypeInferenceForTesting: skipTypeInference); foreach (var sourceFile in sourceFiles) { ((IVisitableNode)sourceFile).Accept(printer); } result = writer.ToString(); // If the CancellationRequest is true, then the error happen during public facade computation return(!printer.CancellationRequested); } }
private FileContent CreatePublicFacadeContent(ISourceFile sourceFile, ISemanticModel semanticModel) { var specPath = sourceFile.Path.AbsolutePath; using (var sw = m_statistics.PublicFacadeComputation.Start(specPath)) { using (var writer = new ScriptWriter()) { var printer = new PublicSurfacePrinter(writer, semanticModel); if (!printer.TryPrintPublicSurface(sourceFile, out var publicFacadeContent)) { m_statistics.PublicFacadeGenerationFailures.Increment(sw.Elapsed); } return(publicFacadeContent); } } }