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

Format document with conditional compilation in C# will not format code ignored by condition #926

Closed
aeschli opened this issue Nov 14, 2016 · 1 comment

Comments

@aeschli
Copy link
Contributor

aeschli commented Nov 14, 2016

From @PeterHimschoot on November 13, 2016 11:31

  • VSCode Version:
  • OS Version:

Steps to Reproduce:

  1. For example, this code:
    #define WITH_DISPOSE

using System;

namespace HiddenIDisposables
{
#if WITH_DISPOSE
public class SomeResource : ISomeResource, IDisposable
{
public string Foo()
{
return "Foo";
}

    void IDisposable.Dispose()
    {
        System.Console.WriteLine("Resource has been disposed");
    }
}

#else
public class SomeResource : ISomeResource
{
public string Foo()
{
return "Foo";
}
}
#endif
}

  1. Format document ignores the #else part

Copied from original issue: microsoft/vscode#15423

@DustinCampbell
Copy link
Member

This is by design and works the same as it does in Visual Studio. Disabled blocks are simply never parsed. Remember that anything can go in disabled blocks of code, including random non-C# text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants