<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang-format C# spaceRequiredBettween does not add a space between "using(FileStream ...""
   href="https://bugs.llvm.org/show_bug.cgi?id=43100">43100</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format C# spaceRequiredBettween does not add a space between "using(FileStream ..."
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Formatter
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mydeveloperday@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>(see Rational)

No Space is left between "using" and ( when clang-formatting  (Irrespective of

Before
---------------------
            using (FileStream fs = new FileStream(path, FileMode.Open,
FileAccess.Read, FileShare.Read, bufferSize : 1))
            {
---------------------

After
---------------------                
            using(FileStream fs = new FileStream(path, FileMode.Open,
FileAccess.Read, FileShare.Read, bufferSize : 1))
               ^^^^^
            {
---------------------


wget -O File.cs
<a href="https://raw.githubusercontent.com/dotnet/corefx/master/src/Common/src/CoreLib/Internal/IO/File.cs">https://raw.githubusercontent.com/dotnet/corefx/master/src/Common/src/CoreLib/Internal/IO/File.cs</a>
clang-format -i File.cs

--------- code to fix (something like) ------------------

diff --git a/clang/lib/Format/TokenAnnotator.cpp
b/clang/lib/Format/TokenAnnotator.cpp
index c391c489dc2..74499442a6c 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2614,6 +2614,9 @@ bool TokenAnnotator::spaceRequiredBetween(const
AnnotatedLine &Line,
     if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
         (Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
       return true;
+    // using (FileStream fs...
+    if (Style.isCSharp() && Left.is(tok::kw_using))
+      return true;
     return Line.Type == LT_ObjCDecl || Left.is(tok::semi) ||


--------------------------------------

Rational:
---------
clang-format C# support needs some extra knowledge of C# syntax.

As a driver for this I'm taking .NET core project "corefx" and running
clang-format over the code and seeing how it varies from the original with the
out of box default CSharp .clang-format configuration of just

-- .clang-format -------------------
Language: CSharp
BasedOnStyle: Microsoft
------------------------------------

There are 2 goals here, determine the best default settings that can be added
to the getMicrosoftStyle() function, using the existing C# capabilities that
most closely matches either code which is part of the .NET Core and/or code
new-generated by VS "New C# project"

  if (Style.isCSharp()) {
    Style.NamespaceIndentation = FormatStyle::NI_All;
    Style.AccessModifierOffset = 4;
    Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
    Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
    Style.SpaceInEmptyBlock = true;
    Style.SpaceAfterCStyleCast = false;
  }

We may identify cases that are either missing for C# specifics (as in this
using case here), that may include adding some new styles to give finer
control.

The aim is to identify those changes that are required in clang-format to
ensure good C# code formatting with clang-format (without impacting the other
language usages (ObjC, C++ etc..)

MyDeveloperDay</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>