Summary
Formats source code in a given directory to a specified code format.
- Assembly
- NAnt
.Contrib .dll - Namespace
- NAnt
.Contrib .Tasks - Base Types
-
- ExternalProgramBase
graph BT
Type-->Base0["ExternalProgramBase"]
Type["Astyle"]
class Type type-node
Syntax
[TaskName("astyle")]
public class Astyle : ExternalProgramBase
Examples
<astyle style="NAnt" cleanup="true">
<sources>
<include name="**/**.cs" />
</sources>
</astyle>
Remarks
Most examples inline have been produced by Tal Davidson and team and are part of the astyle documentation. They have been included in the task documentation as an easy reference.
NOTE: This task relies on the astyle.exe file being in your path variable. Please download the astyle.exe from http://astyle.sourceforge.net.Attributes
Type | Description |
---|---|
TaskName |
Properties
Name | Value | Summary |
---|---|---|
BracketsAttach | bool |
true if brackets should be attached.
|
BracketsLinux | bool |
true if brackets should be put on a new line and
indented.
|
BracketsNewLine | bool |
true if brackets should be put on a new line.
|
BreakBlocks | bool |
true to break block statements with an empty line.
|
BreakBlocksAll | bool |
true to break all block statements, even on
nested ifs with an empty line.
|
BreakClosing | bool |
true if the line after a bracket (i.e. an else
statement after the closing if) should be placed on the next line.
|
BreakElseif | bool |
true to put the if component of an else if on a
new line.
|
CleanUp | bool |
Astyle leaves the original files around, renamed with a different
suffix. Setting this to
will remove these files.
|
CommandLineArguments | string |
The command-line arguments for the program.
|
CommandOptions | Hashtable |
A collection of command line option switches.
|
ConvertTabs | bool |
true to convert tabs to spaces.
|
FillEmptyLines | bool |
true if empty lines should be filled with the
whitespace of the previous line.
|
IndentBlock | bool |
true if block statements should be indented.
The default:
if (isFoo)
{
bar();
}
else
anotherBar();
becomes:
if (isFoo)
{
bar();
}
else
anotherBar();
|
IndentBracket | bool |
if bracket statements should be indented.
|
IndentCase | bool |
true if case statements should be indented.
|
IndentClass | bool |
true if class statements should be indented.
|
IndentLabels | bool |
true if label statements should be indented.
|
IndentMax | int |
Indicate the maximum number of spaces to indent relative to a
previous line.
|
IndentMin | int |
Indicate the maximum number of spaces to indent relative to a
previous line.
|
IndentNamespaces | bool |
true if namespace statements should be indented.
|
IndentNumSpaces | int |
Indicate the maximum number of spaces to indent relative to a
previous line.
|
IndentNumTabs | int |
Indicate that tabs should be used to indent sources. The number
specified indicates the maximum number of spaces the tab character
will represent.
|
IndentNumTabsForce | int |
Indent using tab characters. Treat each tab as # spaces. Uses tabs as
indents in areas '--indent=tab' prefers to use spaces, such as
inside multi-line statements.
|
IndentSwitch | bool |
true if switch statements should be indented.
|
NoBreakComplex | bool |
true to keep complex statements on the same line.
|
No |
bool |
true to keep single line statements on the same line.
|
PadAll | bool |
true to pad operators and parenthesis.
|
PadOperators | bool |
true to pad operators with a space.
|
PadParenthesis | bool |
true to pad parenthesis with a space.
|
ProgramArguments | string |
Gets the command-line arguments for the external program.
|
Sources | FileSet |
Used to select the files to copy.
|
Style | string |
Indicate the preset style to use.
ansi
namespace foospace
{
int Foo()
{
if (isBar)
{
bar();
return 1;
}
else
return 0;
}
}
kr ( Kernighan&Ritchie )
namespace foospace {
int Foo() {
if (isBar) {
bar();
return 1;
} else
return 0;
}
}
linux
namespace foospace
{
int Foo()
{
if (isBar) {
bar();
return 1;
} else
return 0;
}
}
gnu
namespace foospace
{
int Foo()
{
if (isBar)
{
bar();
return 1;
}
else
return 0;
}
}
java
class foospace {
int Foo() {
if (isBar) {
bar();
return 1;
} else
return 0;
}
}
NAnt
namespace foospace {
class foo() {
#region Protected Static Fields
private int Foo() {
if (isBar) {
bar();
return 1;
} else {
return 0;
}
}
#endregion
}
|
Suffix | string |
The suffix to append to original files, defaults to
.orig
if not specified.
|
Methods
Name | Value | Summary |
---|---|---|
ExecuteTask |
void | |
PrepareProcess |
void |
Build up the command line arguments, determine which executable is
being used and find the path to that executable and set the working
directory.
|
SetCommandOption |
void |
Adds a new command option if none exists. If one does exist then
the use switch is toggled on or of.
|