/// <summary> /// Generates formatted source code containing general information about the symbol's /// containing assembly, and the public, protected, and protected-or-internal interface of /// which the given ISymbol is or is a part of into the given document /// </summary> /// <param name="document">The document to generate source into</param> /// <param name="symbolCompilation">The <see cref="Compilation"/> in which <paramref name="symbol"/> is resolved.</param> /// <param name="symbol">The symbol to generate source for</param> /// <param name="formattingOptions">Options to use to format the document.</param> /// <param name="cancellationToken">To cancel document operations</param> /// <returns>The updated document</returns> public static Task <Document> AddSourceToAsync(Document document, Compilation symbolCompilation, ISymbol symbol, OmniSharpSyntaxFormattingOptionsWrapper formattingOptions, CancellationToken cancellationToken) { var service = document.GetRequiredLanguageService <IMetadataAsSourceService>(); var options = new CleanCodeGenerationOptions( GenerationOptions: CodeGenerationOptions.GetDefault(document.Project.LanguageServices), CleanupOptions: formattingOptions.CleanupOptions); return(service.AddSourceToAsync(document, symbolCompilation, symbol, options, cancellationToken)); }
/// <summary> /// Generates formatted source code containing general information about the symbol's /// containing assembly, and the public, protected, and protected-or-internal interface of /// which the given ISymbol is or is a part of into the given document /// </summary> /// <param name="document">The document to generate source into</param> /// <param name="symbolCompilation">The <see cref="Compilation"/> in which <paramref name="symbol"/> is resolved.</param> /// <param name="symbol">The symbol to generate source for</param> /// <param name="formattingOptions">Options to use to format the document.</param> /// <param name="cancellationToken">To cancel document operations</param> /// <returns>The updated document</returns> public static Task <Document> AddSourceToAsync(Document document, Compilation symbolCompilation, ISymbol symbol, OmniSharpSyntaxFormattingOptionsWrapper formattingOptions, CancellationToken cancellationToken) { var service = document.GetRequiredLanguageService <IMetadataAsSourceService>(); return(service.AddSourceToAsync(document, symbolCompilation, symbol, formattingOptions.UnderlyingObject, cancellationToken)); }
internal static async ValueTask <OmniSharpSyntaxFormattingOptionsWrapper> GetFormattingOptionsAsync(Document document, OmniSharpOptions omnisharpOptions) => omnisharpOptions.FormattingOptions.EnableEditorConfigSupport ? await OmniSharpSyntaxFormattingOptionsWrapper.FromDocumentAsync(document, CancellationToken.None) : WrapFormattingOptions(omnisharpOptions.FormattingOptions);