Implicit Unbound Default Member Access

Identifies the use of indexed default member accesses for which the default member cannot be determined at compile time.

Reasoning

Default member accesses hide away the actually called member. This is especially misleading if there is no indication in the expression that such a call is made and if the default member cannot be determined from the declared type of the object. As a consequence, errors in which a member was forgotten to be called can go unnoticed and should there not be a suitable default member at runtime, an error 438 'Object doesn't support this property or method' will be raised.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal arg As Object) Dim bar As Variant bar = arg End Sub

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal arg As Object) Dim bar As Variant arg = bar End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal arg As Object) Dim bar As Variant bar = arg.SomeValueReturningMember End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal arg As Object) Dim bar As Variant arg.SomePropertyLet = bar End Sub

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