Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting code with an #if section #1101

Closed
mikeage opened this issue Apr 23, 2021 · 3 comments
Closed

Formatting code with an #if section #1101

mikeage opened this issue Apr 23, 2021 · 3 comments
Labels
Resolved-Duplicate This issue or pull request already exists

Comments

@mikeage
Copy link

mikeage commented Apr 23, 2021

Hi,

Given the following code:

#if SOMETHING
good_format;
  bad_format;
#else
good_format;
  bad_format;
#endif

when I run dotnet-format (with no solution or anything like that, just using dotnet-format --folder . (my main project is a Unity project, so it doesn't really have .sln or .csproj or anything like this; this is just a minimal example), it returns the following:

#if SOMETHING
good_format;
  bad_format;
#else
good_format;
bad_format;
#endif

Note that the code within the #if is unformatted.

I realized that by default that code will not be compiled, but if I do, in fact, #define SOMETHING, then it will; is there an easy way I can tell dotnet-format to format everything, regardless of which particular defines might exist? Alternatively, I can probably call it multiple times with every definition (or combination of definitions of course) -- how do I tell it to add custom definitions?

@JoeRobich
Copy link
Member

@mikeage Thanks for opening this issue. Closing as it is a duplicate of #783.

@mikeage
Copy link
Author

mikeage commented May 13, 2021

oh, sorry, I don't know how I missed that when searching. Whoops

@JoeRobich
Copy link
Member

@mikeage No worries. I'd much rather mark something as duplicate than not have it reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolved-Duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants