#include "clang/Format/Format.h"
#include "AffectedRangeManager.h"
+#include "BreakableToken.h"
#include "ContinuationIndenter.h"
#include "FormatInternal.h"
#include "FormatTokenLexer.h"
// #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;
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.
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;
}
}
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.
where TKey : IComparable<TKey>
where TVal : IMyInterface {
public void MyMethod<T>(T t)
- where T : IMyInterface { doThing(); }
+ where T : IMyInterface {
+ doThing();
+ }
})",
Style);
verifyFormat(R"(//
class ItemFactory<T>
- where T : new(),
- IAnInterface<T>,
- IAnotherInterface<T>,
- IAnotherInterfaceStill<T> {})",
+ where T : new(), IAnInterface<T>, IAnotherInterface<T>, IAnotherInterfaceStill<T> {})",
Style);
Style.ColumnLimit = 50; // Force lines to be wrapped.