<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/101487>101487</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] C# attribute on auto property lead to strange formatting
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TobiasFunk
</td>
</tr>
</table>
<pre>
Hey when i execute clang-format.exe --verbose --style=file -i Program.cs on this code:
`using System;
namespace ConsoleApp2
{
[AttributeUsage(AttributeTargets.All)]
public class SimpleAttribute : Attribute
{
}
internal class Program
{
bool AutoAllowKnownApps
{
get;
[Simple]
set;
}
static void Main(string[] args)
{
}
}
}
`
i get a really strange result code
`using System;
namespace ConsoleApp2
{
[AttributeUsage(AttributeTargets.All)]
public class SimpleAttribute : Attribute
{
}
internal class Program
{
bool AutoAllowKnownApps
{
get; [Simple]
set;
}
static void Main(string[] args)
{
}
}
}
`
i found out that it is related to the attribute when removing it everything seems to format correctly.
only for completenes i use this config but it also happens with the default config
`Language: CSharp
BasedOnStyle: Microsoft
Standard: c++20
UseTab: Never
IndentWidth: 4
ColumnLimit: 120
SortIncludes: CaseSensitive
AlignConsecutiveMacros: true
NamespaceIndentation: All
IndentCaseLabels: false
IndentPPDirectives: None
IndentWrappedFunctionNames: false
AllowShortFunctionsOnASingleLine: None
AllowShortBlocksOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
FixNamespaceComments: false
CommentPragmas: '^(\\|\/)*\W*(<\w*|\\\w*){1}' # Don't mess around with doxygen
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
PointerAlignment: Left
KeepEmptyLinesAtTheStartOfBlocks: false
AlignAfterOpenBracket: Align
AccessModifierOffset: -4
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
BreakAfterAttributes: Leave
BreakBeforeBraces: Custom
BraceWrapping:
AfterNamespace: true
AfterEnum: true
AfterStruct: true
AfterClass: true
AfterUnion: true
AfterFunction: true
AfterExternBlock: true
AfterCaseLabel: true
AfterControlStatement: true
AfterObjCDeclaration: true
BeforeCatch: true
BeforeLambdaBody: true
BeforeElse: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWF9v6joS_zThxWoFgRT6wEOAUy069IAuPTrPQzJJfOvYWXsCZT_9yk5CAoRztav7clEFxPOb8fz5zdgFjOGpRJx7wcILVgMoKVN6_qEOHMxbKT8HBxWf5__CMztlKBln-IVRScgiATJ9SpTOgZ7xC9nT0xH1QRn7zdBZoDdeJVwge-Jsp1WqIX-ODFOSUcYNi1SM3jj0hitv2Ly_DEvDZcr2Z0OYe-NFVyohR1NAhGyppFECw6Lwa8C0RjIvWIREmh9Kwp8GUvT82WXhA3SKZJ5DITz_1QtWtRJjrCgPgkc2KGPYnueFwIsa88Yhuzy1Ou2u7mHVddYucUmoJYjaap2DPv2DUoKFJalQCHX6LtVJhkVhWujdds0rRfLGC9ZGX_l-FVvzMg57a_TObQclIB6xo-IxewcuPX9mSHOZVjRhoFN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