@ -190,6 +190,22 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -190,6 +190,22 @@ namespace ICSharpCode.NRefactory.CSharp
/// Creates sharp develop indent style CSharpFormatting options.
/// </summary>
public static CSharpFormattingOptions CreateSharpDevelop ( )
{
var baseOptions = CreateKRStyle ( ) ;
baseOptions . IfElseBraceForcement = BraceForcement . AddBraces ;
baseOptions . ForBraceForcement = BraceForcement . AddBraces ;
baseOptions . ForEachBraceForcement = BraceForcement . AddBraces ;
baseOptions . WhileBraceForcement = BraceForcement . AddBraces ;
baseOptions . UsingBraceForcement = BraceForcement . AddBraces ;
baseOptions . FixedBraceForcement = BraceForcement . AddBraces ;
return baseOptions ;
}
/// <summary>
/// The K&R style, so named because it was used in Kernighan and Ritchie's book The C Programming Language,
/// is commonly used in C. It is less common for C++, C#, and others.
/// </summary>
public static CSharpFormattingOptions CreateKRStyle ( )
{
return new CSharpFormattingOptions ( ) {
IndentNamespaceBody = true ,
@ -350,6 +366,52 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -350,6 +366,52 @@ namespace ICSharpCode.NRefactory.CSharp
baseOptions . ArrayInitializerBraceStyle = BraceStyle . EndOfLine ;
return baseOptions ;
}
/// <summary>
/// The Whitesmiths style, also called Wishart style to a lesser extent, is less common today than the previous three. It was originally used in the documentation for the first commercial C compiler, the Whitesmiths Compiler.
/// </summary>
public static CSharpFormattingOptions CreateWhitesmiths ( )
{
var baseOptions = CreateSharpDevelop ( ) ;
baseOptions . NamespaceBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . ClassBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . InterfaceBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . StructBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . EnumBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . MethodBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . ConstructorBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . DestructorBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . AnonymousMethodBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . PropertyBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . PropertyGetBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . PropertySetBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . EventBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . EventAddBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . EventRemoveBraceStyle = BraceStyle . NextLineShifted ;
baseOptions . StatementBraceStyle = BraceStyle . NextLineShifted ;
return baseOptions ;
}
/// <summary>
/// Like the Allman and Whitesmiths styles, GNU style puts braces on a line by themselves, indented by 2 spaces,
/// except when opening a function definition, where they are not indented.
/// In either case, the contained code is indented by 2 spaces from the braces.
/// Popularised by Richard Stallman, the layout may be influenced by his background of writing Lisp code.
/// In Lisp the equivalent to a block (a progn)
/// is a first class data entity and giving it its own indent level helps to emphasize that,
/// whereas in C a block is just syntax.
/// Although not directly related to indentation, GNU coding style also includes a space before the bracketed
/// list of arguments to a function.
/// </summary>
public static CSharpFormattingOptions CreateGNU ( )
{
var baseOptions = CreateAllman ( ) ;
baseOptions . StatementBraceStyle = BraceStyle . NextLineShifted2 ;
return baseOptions ;
}
}
}