Skip to content

Commit 35aa2ce

Browse files
Merge pull request #702 from jconnop/Issue701_MultiLineHandles
Trim whitespace from event source identifiers. Fixes #701
2 parents a0b737f + eb9fa3b commit 35aa2ce

2 files changed

Lines changed: 95 additions & 1 deletion

File tree

CodeConverter/CSharp/DeclarationNodeVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ string GetCSharpIdentifierText(VBSyntax.EventContainerSyntax p)
629629
case VBSyntax.KeywordEventContainerSyntax _:
630630
return "this";
631631
default:
632-
return CommonConversions.CsEscapedIdentifier(p.GetText().ToString()).Text;
632+
return CommonConversions.CsEscapedIdentifier(p.GetText().ToString().Trim()).Text;
633633
}
634634
}
635635
}

Tests/CSharp/MemberTests/EventMemberTests.cs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,5 +608,99 @@ public int TestConversion(object ai_ID)
608608
}
609609
");
610610
}
611+
612+
[Fact]
613+
public async Task Test_Issue701_MultiLineHandlesSyntaxAsync()
614+
{
615+
await TestConversionVisualBasicToCSharpAsync(@"Public Class Form1
616+
Private Sub MultiClickHandler(sender As Object, e As EventArgs) Handles Button1.Click,
617+
Button2.Click
618+
End Sub
619+
End Class
620+
621+
Partial Class Form1
622+
Inherits System.Windows.Forms.Form
623+
624+
Private Sub InitializeComponent()
625+
Me.Button1 = New System.Windows.Forms.Button()
626+
Me.Button2 = New System.Windows.Forms.Button()
627+
End Sub
628+
629+
Friend WithEvents Button1 As System.Windows.Forms.Button
630+
Friend WithEvents Button2 As System.Windows.Forms.Button
631+
End Class",
632+
@"using System;
633+
using System.Runtime.CompilerServices;
634+
635+
public partial class Form1
636+
{
637+
private void MultiClickHandler(object sender, EventArgs e)
638+
{
639+
}
640+
}
641+
642+
public partial class Form1 : System.Windows.Forms.Form
643+
{
644+
private void InitializeComponent()
645+
{
646+
_Button1 = new System.Windows.Forms.Button();
647+
_Button1.Click += new EventHandler(MultiClickHandler);
648+
_Button2 = new System.Windows.Forms.Button();
649+
_Button2.Click += new EventHandler(MultiClickHandler);
650+
}
651+
652+
private System.Windows.Forms.Button _Button1;
653+
654+
internal System.Windows.Forms.Button Button1
655+
{
656+
[MethodImpl(MethodImplOptions.Synchronized)]
657+
get
658+
{
659+
return _Button1;
660+
}
661+
662+
[MethodImpl(MethodImplOptions.Synchronized)]
663+
set
664+
{
665+
if (_Button1 != null)
666+
{
667+
_Button1.Click -= MultiClickHandler;
668+
}
669+
670+
_Button1 = value;
671+
if (_Button1 != null)
672+
{
673+
_Button1.Click += MultiClickHandler;
674+
}
675+
}
676+
}
677+
678+
private System.Windows.Forms.Button _Button2;
679+
680+
internal System.Windows.Forms.Button Button2
681+
{
682+
[MethodImpl(MethodImplOptions.Synchronized)]
683+
get
684+
{
685+
return _Button2;
686+
}
687+
688+
[MethodImpl(MethodImplOptions.Synchronized)]
689+
set
690+
{
691+
if (_Button2 != null)
692+
{
693+
_Button2.Click -= MultiClickHandler;
694+
}
695+
696+
_Button2 = value;
697+
if (_Button2 != null)
698+
{
699+
_Button2.Click += MultiClickHandler;
700+
}
701+
}
702+
}
703+
}", hasLineCommentConversionIssue:true);
704+
}
611705
}
612706
}

0 commit comments

Comments
 (0)