[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9520bf146dd3: [clang-format] Update GoogleStyle for C# code 
to match Googles internal C#… (authored by Jonathan Coe 
jb...@google.com).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79715/new/

https://reviews.llvm.org/D79715

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift 
Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be 
between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, 
IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
+#include "BreakableToken.h"
 #include "ContinuationIndenter.h"
 #include "FormatInternal.h"
 #include "FormatTokenLexer.h"
@@ -1068,6 +1069,12 @@
 // #imports, etc.)
 GoogleStyle.IncludeStyle.IncludeBlocks =
 tooling::IncludeStyle::IBS_Preserve;
+  } else if (Language == FormatStyle::LK_CSharp) {
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
+GoogleStyle.BreakStringLiterals = false;
+GoogleStyle.ColumnLimit = 100;
+GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
   }
 
   return GoogleStyle;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- 

[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-14 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe planned changes to this revision.
jbcoe added a comment.

I will get the Google Style guide uploaded and update this patch with a link.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79715/new/

https://reviews.llvm.org/D79715



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Assuming you either work for google and understand their style or are qualified 
to say this is their style then this LGTM

What I couldn't see from the link was where the google C# style guide was?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79715/new/

https://reviews.llvm.org/D79715



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-12 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

In D79715#2029390 , @jbcoe wrote:

> I expect that accepting this patch will need require an update to be made to 
> https://github.com/google/styleguide.


I agree; it would be useful to leave a comment somewhere in this code with a 
link to a Google C# style guide reference.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79715/new/

https://reviews.llvm.org/D79715



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-11 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

I expect that accepting this patch will need require an update to be made to 
https://github.com/google/styleguide.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79715/new/

https://reviews.llvm.org/D79715



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-11 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a reviewer: krasimir.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79715

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -581,8 +581,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift 
Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -639,8 +638,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be 
between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -727,7 +725,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -772,16 +772,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, 
IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
+#include "BreakableToken.h"
 #include "ContinuationIndenter.h"
 #include "FormatInternal.h"
 #include "FormatTokenLexer.h"
@@ -997,6 +998,12 @@
 // #imports, etc.)
 GoogleStyle.IncludeStyle.IncludeBlocks =
 tooling::IncludeStyle::IBS_Preserve;
+  } else if (Language == FormatStyle::LK_CSharp) {
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
+GoogleStyle.BreakStringLiterals = false;
+GoogleStyle.ColumnLimit = 100;
+GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
   }
 
   return GoogleStyle;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -581,8 +581,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -639,8 +638,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -727,7 +725,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -772,16 +772,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include