Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Commit f454290

Browse files
committed
Fix explicit interface impl of event
1 parent cc5efa7 commit f454290

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Microsoft.DotNet.CodeFormatting.Tests/Rules/ExplicitVisibilityRuleTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ interface I1
120120
{
121121
int Prop { get; set; }
122122
void M();
123+
event EventHandler E;
123124
}
124125
125126
class C : I1
@@ -130,6 +131,8 @@ int I1.Prop
130131
set { }
131132
}
132133
void I1.M() { }
134+
event EventHandler I1.E;
135+
void M() { }
133136
}
134137
";
135138

@@ -138,6 +141,7 @@ internal interface I1
138141
{
139142
int Prop { get; set; }
140143
void M();
144+
event EventHandler E;
141145
}
142146
143147
internal class C : I1
@@ -148,6 +152,8 @@ int I1.Prop
148152
set { }
149153
}
150154
void I1.M() { }
155+
event EventHandler I1.E;
156+
private void M() { }
151157
}
152158
";
153159

src/Microsoft.DotNet.CodeFormatting/Rules/ExplicitVisibilityRule.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax no
8080

8181
public override SyntaxNode VisitEventDeclaration(EventDeclarationSyntax node)
8282
{
83+
if (node.ExplicitInterfaceSpecifier != null)
84+
{
85+
return node;
86+
}
87+
8388
return EnsureVisibility(node, node.Modifiers, (x, l) => x.WithModifiers(l), SyntaxKind.PrivateKeyword);
8489
}
8590

0 commit comments

Comments
 (0)