Object Where Procedure is Required

Identifies places in which an object is used but a procedure is required and a default member exists on the object.

Reasoning

Providing an object where a procedure is required leads to an implicit call to the object's default member. This behavior is not obvious, and most likely unintended.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

Class1 (ClassModule)
Public Function Foo() As Long Attibute Foo.VB_UserMemId = 0 Foo = 42 End Function
Module (StandardModule)
Public Sub DoSomething(ByVal arg As Class1) arg End Sub

This example should NOT trigger a result

Class1 (ClassModule)
Public Function Foo() As Long Attibute Foo.VB_UserMemId = 0 Foo = 42 End Function
Module (StandardModule)
Public Sub DoSomething(ByVal arg As Class1) arg.Foo End Sub

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