Misleading ByRef Parameter

Flags the value-parameter of a property mutators that are declared with an explict ByRef modifier.

Reasoning

Regardless of the presence or absence of an explicit ByRef or ByVal modifier, the value-parameter of a property mutator is always treated as though it had an explicit ByVal modifier. Exception: UserDefinedType and Array parameters are always passed by reference.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Private fizzField As Long Public Property Get Fizz() As Long Fizz = fizzField End Property Public Property Let Fizz(ByRef arg As Long) fizzField = arg End Property

This example should NOT trigger a result

MyModule (StandardModule)
Private fizzField As Long Public Property Get Fizz() As Long Fizz = fizzField End Property Public Property Let Fizz(arg As Long) fizzField = arg End Property

Rubberduck.CodeAnalysis.Inspections.Concrete.MisleadingByRefParameterInspection.cs (Prerelease-v2.5.9.6289)