@@ -13,17 +13,17 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
13
13
/// <why>
14
14
/// Regardless of the presence or absence of an explicit ByRef or ByVal modifier, the value-parameter
15
15
/// of a property mutator is always treated as though it had an explicit ByVal modifier.
16
- /// Exception: UserDefinedType parameters are always passed by reference.
16
+ /// Exception: UserDefinedType and Array parameters are always passed by reference.
17
17
/// </why>
18
18
/// <example hasResult="true">
19
19
/// <module name="MyModule" type="Standard Module">
20
20
/// <![CDATA[
21
21
/// Private fizzField As Long
22
22
/// Public Property Get Fizz() As Long
23
- /// Fizz = fizzFiled
23
+ /// Fizz = fizzField
24
24
/// End Property
25
25
/// Public Property Let Fizz(ByRef arg As Long)
26
- /// fizzFiled = arg
26
+ /// fizzField = arg
27
27
/// End Property
28
28
/// ]]>
29
29
/// </module>
@@ -33,10 +33,10 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
33
33
/// <![CDATA[
34
34
/// Private fizzField As Long
35
35
/// Public Property Get Fizz() As Long
36
- /// Fizz = fizzFiled
36
+ /// Fizz = fizzField
37
37
/// End Property
38
38
/// Public Property Let Fizz(arg As Long)
39
- /// fizzFiled = arg
39
+ /// fizzField = arg
40
40
/// End Property
41
41
/// ]]>
42
42
/// </module>
@@ -50,14 +50,18 @@ public MisleadingByRefParameterInspection(IDeclarationFinderProvider declaration
50
50
protected override bool IsResultDeclaration ( Declaration declaration , DeclarationFinder finder )
51
51
{
52
52
return declaration is ParameterDeclaration parameter
53
- && ! ( parameter . AsTypeDeclaration ? . DeclarationType . HasFlag ( DeclarationType . UserDefinedType ) ?? false )
54
- && parameter . ParentDeclaration is ModuleBodyElementDeclaration enclosingMethod
53
+ && ! IsAlwaysByRef ( declaration )
54
+ && declaration . ParentDeclaration is ModuleBodyElementDeclaration enclosingMethod
55
55
&& ( enclosingMethod . DeclarationType . HasFlag ( DeclarationType . PropertyLet )
56
56
|| enclosingMethod . DeclarationType . HasFlag ( DeclarationType . PropertySet ) )
57
57
&& enclosingMethod . Parameters . Last ( ) == parameter
58
58
&& parameter . IsByRef && ! parameter . IsImplicitByRef ;
59
59
}
60
60
61
+ private static bool IsAlwaysByRef ( Declaration parameter )
62
+ => parameter . IsArray
63
+ || ( parameter . AsTypeDeclaration ? . DeclarationType . HasFlag ( DeclarationType . UserDefinedType ) ?? false ) ;
64
+
61
65
protected override string ResultDescription ( Declaration declaration )
62
66
{
63
67
return string . Format (
0 commit comments