File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
4141
4242### C# -> VB
4343
44+ * Converts "default" keyword to "Nothing" keyword [ #428 ] ( https://github.com/icsharpcode/CodeConverter/issues/428 )
4445
4546## [ 7.9.0] - 2020-02-27
4647
Original file line number Diff line number Diff line change @@ -820,8 +820,10 @@ public override VisualBasicSyntaxNode VisitParameter(CSS.ParameterSyntax node)
820820
821821 public override VisualBasicSyntaxNode VisitLiteralExpression ( CSS . LiteralExpressionSyntax node )
822822 {
823- // now this looks somehow hacky... is there a better way?
824- if ( node . IsKind ( CS . SyntaxKind . StringLiteralExpression ) && node . Token . Text . StartsWith ( "@" , StringComparison . Ordinal ) ) {
823+ if ( node . IsKind ( CS . SyntaxKind . DefaultLiteralExpression ) ) {
824+ return VisualBasicSyntaxFactory . NothingExpression ;
825+ // This looks somehow hacky... is there a better way to check whether it's a verbatim string?
826+ } else if ( node . IsKind ( CS . SyntaxKind . StringLiteralExpression ) && node . Token . Text . StartsWith ( "@" , StringComparison . Ordinal ) ) {
825827 return SyntaxFactory . StringLiteralExpression (
826828 SyntaxFactory . StringLiteralToken (
827829 node . Token . Text . Substring ( 1 ) ,
Original file line number Diff line number Diff line change @@ -80,6 +80,30 @@ End Sub
8080End Class" ) ;
8181 }
8282
83+ [ Fact ]
84+ public async Task DefaultLiteralExpression ( )
85+ {
86+ await TestConversionCSharpToVisualBasic ( @"public class DefaultLiteralExpression {
87+
88+ public bool Foo {
89+ get {
90+ return (Bar == default);
91+ }
92+ }
93+
94+ public int Bar;
95+
96+ }" , @"Public Class DefaultLiteralExpression
97+ Public ReadOnly Property Foo As Boolean
98+ Get
99+ Return Bar = Nothing
100+ End Get
101+ End Property
102+
103+ Public Bar As Integer
104+ End Class" ) ;
105+ }
106+
83107 [ Fact ]
84108 public async Task IsNullExpression ( )
85109 {
You can’t perform that action at this time.
0 commit comments