Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Bug fixes #43

Merged
merged 8 commits into from
Jan 27, 2015
Merged

Bug fixes #43

merged 8 commits into from
Jan 27, 2015

Conversation

jaredpar
Copy link
Member

A couple of bug fixes for the formatter.

This is a straw man design for the problem being discussed in issue #38.
Essentially let the developer specify on the command line what
configurations they want the code to be formatted under.  This is much
safer than assuming all configurations in the file are valid.
This adds tests for how we handle preprocessor directives with respect
to file formatting.

closes #38
Consider the following code:

``` csharp
void M()
{
G();

// Comment
}
```

The new line between G() and the comment is meaningful and should be
kept by the tool.  This change fixes that and a couple of subtle issues
around white spaces and new lines.

closes #36
While plumbing through a CancellationToken I noticed that
IFormattingFilter had no async implementations.  Made it sync until an
actual async version is needed.
Moved the checks for the existance of the file and having a non-readonly
nature to an actual IFormattingFilter instance.
This change adds the preprocessor symbol DOTNET_FORMATTER to every
project in the formatted Solution.  This allows developers to exempt
code from formatting by surrounding blocks with

``` csharp
#if !DOTNET_FORMATTER
```

This should only be done on the rare occasions where insignificant white
space serves to make the code significantly more readable.  For example
in large unicode tables.  In general this feature should be avoided.

closes #37
@jaredpar
Copy link
Member Author

@nslottow if code wants to exist solely for the code formatter they could change #if false to #if DOTNET_CODEFORMATTER.

I'm truthfully not very concerned about the #if false case though. A developer has explicitly labeled code as dead, why bother maintaining it for them if they can't even get it to compile under any circumstances? It's something I flag on code reviews and ask authors to simply delete. No reason to keep it around.

Conflicts:
	src/CodeFormatter/Program.cs
	src/Microsoft.DotNet.CodeFormatting/IFormattingEngine.cs
jaredpar added a commit that referenced this pull request Jan 27, 2015
@jaredpar jaredpar merged commit 3c16dd4 into dotnet:master Jan 27, 2015
@jaredpar jaredpar deleted the bug-fixes branch January 27, 2015 15:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants