You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#pragma warning disable 123
namespace foo {
}#pragma warning restore 123 <--- extra enter erased here, after the closing bracket
Sample repro for the #pragma issue:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Formatting;
using static System.Console;
class Program
{
static void Main(string[] args)
{
var tree = SyntaxFactory.ParseSyntaxTree(@"
#pragma warning disable 123
namespace foo {
}
#pragma warning restore 123
");
WriteLine("NormalizeWhitespace()");
WriteLine("=====================");
WriteLine(tree.GetRoot().NormalizeWhitespace().ToFullString());
WriteLine();
WriteLine("Formatter.Format()");
WriteLine("=====================");
WriteLine(Formatter.Format(tree.GetRoot(), new AdhocWorkspace()).ToFullString());
}
}
The text was updated successfully, but these errors were encountered:
There is a problem while formatting (indenting, adding/erasing whitespaces and/or newlines, etc.) directives such as #endregion, #pragma, etc..
The problem lies within the following classes/functions:
These functions are inconsistent with the CSharp compiler, which allows lines such as:
where the conventional way of doing this is:
The formatting erases the whitespace after the directive, giving a non-compilable file like this:
Similar problem with #pragma, where an extra enter is erased while formatting the following:
one gets the following non-compilable code:
Sample repro for the #pragma issue:
The text was updated successfully, but these errors were encountered: