Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3058,4 +3058,33 @@ public C(string a)
}
""",
new(options: Option(CodeStyleOptions2.QualifyPropertyAccess, true, NotificationOption2.Error)));

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79734")]
public Task TestAttributeOnAccessor()
=> TestInRegularAndScriptAsync(
"""
class AAttribute : Attribute;

class C
{
[|int _i;|]
int I
{
[A]
get => _i;
}
}
""",
"""
class AAttribute : Attribute;

class C
{
int I
{
[A]
get;
}
}
""");
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -221,7 +220,7 @@ protected override ImmutableArray<AbstractFormattingRule> GetFormattingRules(
{
// If the final property is only simple `get;set;` accessors, then reformat the property to be on a single line.
if (propertyDeclaration is PropertyDeclarationSyntax { AccessorList.Accessors: var accessors } &&
accessors.All(a => a is { ExpressionBody: null, Body: null }))
accessors.All(a => a is { ExpressionBody: null, Body: null, AttributeLists.Count: 0 }))
{
return [new SingleLinePropertyFormattingRule(), .. Formatter.GetDefaultFormattingRules(document)];
}
Expand Down
Loading