コード例 #1
0
        public async Task <Document> FormatNewDocumentAsync(Document document, Document?hintDocument, CodeCleanupOptions options, CancellationToken cancellationToken)
        {
            // if the user prefers Program.Main style instead, then attempt to convert a template with
            // top-level-statements to that form.
            var option = ((CSharpSyntaxFormattingOptions)options.FormattingOptions).PreferTopLevelStatements;

            if (option.Value)
            {
                return(document);
            }

            return(await ConvertProgramTransform.ConvertToProgramMainAsync(document, options.FormattingOptions.AccessibilityModifiersRequired, cancellationToken).ConfigureAwait(false));
        }
        public async Task <Document> FormatNewDocumentAsync(Document document, Document?hintDocument, SyntaxFormattingOptions formattingOptions, CancellationToken cancellationToken)
        {
            var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);

            // if the user prefers Program.Main style instead, then attempt to convert a template with
            // top-level-statements to that form.
            var option = options.GetOption(CSharpCodeStyleOptions.PreferTopLevelStatements);

            if (option.Value)
            {
                return(document);
            }

            return(await ConvertProgramTransform.ConvertToProgramMainAsync(document, cancellationToken).ConfigureAwait(false));
        }