@@ -503,6 +503,7 @@ Private Sub abc_Foo(ByRef arg1 As Integer)
503503 var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
504504 . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
505505 . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
506+ . AddComponent ( "Class3" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
506507 . Build ( ) ;
507508 var vbe = builder . AddProject ( project ) . Build ( ) ;
508509
@@ -538,6 +539,7 @@ Private Sub abc_Foo(ByVal arg1 As Integer)
538539 var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
539540 . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
540541 . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
542+ . AddComponent ( "Class3" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
541543 . Build ( ) ;
542544 var vbe = builder . AddProject ( project ) . Build ( ) ;
543545
@@ -574,6 +576,7 @@ Private Sub abc_Foo(ByRef arg1 As Integer)
574576 var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
575577 . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
576578 . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
579+ . AddComponent ( "Class3" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
577580 . Build ( ) ;
578581 var vbe = builder . AddProject ( project ) . Build ( ) ;
579582
@@ -610,6 +613,7 @@ Private Sub abc_Foo(ByRef arg1 As Integer, ByRef arg2 As Integer)
610613 var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
611614 . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
612615 . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
616+ . AddComponent ( "Class3" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
613617 . Build ( ) ;
614618 var vbe = builder . AddProject ( project ) . Build ( ) ;
615619
@@ -851,6 +855,70 @@ Private Sub IClass1_DoSomething(ByVal a As Integer, ByRef b As Integer)
851855 Assert . AreEqual ( expectedCode3 , module3 . Lines ( ) ) ;
852856 }
853857
858+ [ TestMethod ]
859+ [ TestCategory ( "Inspections" ) ]
860+ public void ParameterCanBeByVal_EVentMember_MultipleParams_OneCanBeByVal_QuickFixWorks ( )
861+ {
862+ //Input
863+ const string inputCode1 =
864+ @"Public Event Foo(ByRef a As Integer, ByRef b As Integer)" ;
865+ const string inputCode2 =
866+ @"Private WithEvents abc As Class1
867+
868+ Private Sub abc_Foo(ByRef a As Integer, ByRef b As Integer)
869+ a = 42
870+ End Sub" ;
871+ const string inputCode3 =
872+ @"Private WithEvents abc As Class1
873+
874+ Private Sub abc_Foo(ByRef a As Integer, ByRef b As Integer)
875+ End Sub" ;
876+
877+ //Expected
878+ const string expectedCode1 =
879+ @"Public Event Foo(ByRef a As Integer, ByVal b As Integer)" ;
880+ const string expectedCode2 =
881+ @"Private WithEvents abc As Class1
882+
883+ Private Sub abc_Foo(ByRef a As Integer, ByVal b As Integer)
884+ a = 42
885+ End Sub" ;
886+ const string expectedCode3 =
887+ @"Private WithEvents abc As Class1
888+
889+ Private Sub abc_Foo(ByRef a As Integer, ByVal b As Integer)
890+ End Sub" ;
891+
892+ //Arrange
893+ var builder = new MockVbeBuilder ( ) ;
894+ var project = builder . ProjectBuilder ( "TestProject1" , vbext_ProjectProtection . vbext_pp_none )
895+ . AddComponent ( "Class1" , vbext_ComponentType . vbext_ct_ClassModule , inputCode1 )
896+ . AddComponent ( "Class2" , vbext_ComponentType . vbext_ct_ClassModule , inputCode2 )
897+ . AddComponent ( "Class3" , vbext_ComponentType . vbext_ct_ClassModule , inputCode3 )
898+ . Build ( ) ;
899+
900+ var module1 = project . Object . VBComponents . Item ( "Class1" ) . CodeModule ;
901+ var module2 = project . Object . VBComponents . Item ( "Class2" ) . CodeModule ;
902+ var module3 = project . Object . VBComponents . Item ( "Class3" ) . CodeModule ;
903+ var vbe = builder . AddProject ( project ) . Build ( ) ;
904+
905+ var mockHost = new Mock < IHostApplication > ( ) ;
906+ mockHost . SetupAllProperties ( ) ;
907+ var parser = MockParser . Create ( vbe . Object , new RubberduckParserState ( vbe . Object , new Mock < ISinks > ( ) . Object ) ) ;
908+
909+ parser . Parse ( new CancellationTokenSource ( ) ) ;
910+ if ( parser . State . Status >= ParserState . Error ) { Assert . Inconclusive ( "Parser Error" ) ; }
911+
912+ var inspection = new ParameterCanBeByValInspection ( parser . State ) ;
913+ var inspectionResults = inspection . GetInspectionResults ( ) ;
914+
915+ inspectionResults . Single ( ) . QuickFixes . Single ( s => s is PassParameterByValueQuickFix ) . Fix ( ) ;
916+
917+ Assert . AreEqual ( expectedCode1 , module1 . Lines ( ) ) ;
918+ Assert . AreEqual ( expectedCode2 , module2 . Lines ( ) ) ;
919+ Assert . AreEqual ( expectedCode3 , module3 . Lines ( ) ) ;
920+ }
921+
854922 [ TestMethod ]
855923 [ TestCategory ( "Inspections" ) ]
856924 public void ParameterCanBeByVal_IgnoreQuickFixWorks ( )
0 commit comments