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

Commit 13cc392

Browse files
committed
Merge pull request #223 from davkean/Delegates
Fixed default visibility of VB delegates
2 parents 7df8bd6 + 72be10a commit 13cc392

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,29 @@ Function F1()
863863
Verify(text, expected, runFormatter: false, languageName: LanguageNames.VisualBasic);
864864
}
865865

866+
[Fact]
867+
public void Delegates()
868+
{
869+
var text = @"
870+
Delegate Function Func1() As Boolean
871+
872+
Friend Class Foo
873+
874+
Delegate Function Func2() As Boolean
875+
End Class
876+
";
877+
878+
var expected = @"
879+
Friend Delegate Function Func1() As Boolean
880+
881+
Friend Class Foo
882+
883+
Public Delegate Function Func2() As Boolean
884+
End Class
885+
";
886+
Verify(text, expected, runFormatter: false, languageName: LanguageNames.VisualBasic);
887+
}
888+
866889
/// <summary>
867890
/// VB.Net can have visibility modifiers + explicit interface implementation unlike C#. The
868891
/// visibility rules for these members is the same as normal members.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
164164

165165
public override SyntaxNode VisitDelegateStatement(DelegateStatementSyntax node)
166166
{
167-
return EnsureVisibility(node, node.Modifiers, (x, l) => x.WithModifiers(l), () => SyntaxKind.PublicKeyword);
167+
return EnsureVisibility(node, node.Modifiers, (x, l) => x.WithModifiers(l), () => GetDelegateTypeDefaultVisibility(node));
168168
}
169169

170170
public override SyntaxNode VisitPropertyStatement(PropertyStatementSyntax node)

0 commit comments

Comments
 (0)