Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObsoleteCallInspection is throwing an ArgumentNullException #431

Closed
retailcoder opened this issue May 4, 2015 · 0 comments
Closed

ObsoleteCallInspection is throwing an ArgumentNullException #431

retailcoder opened this issue May 4, 2015 · 0 comments
Labels
bug Identifies work items for known bugs feature-inspections up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky
Milestone

Comments

@retailcoder
Copy link
Member

Repro:

Sub dosomething()
    Call foo
End Sub

Sub foo()
End Sub

Stack trace (only the relevant part):

System.ArgumentNullException: Value cannot be null.
Parameter name: [context] and [comment] cannot both be null.
   at Rubberduck.Inspections.ObsoleteCallStatementInspection.<GetInspectionResults>b__2(IdentifierReference issue) in c:\Users\Mathieu\Source\Repos\Rubberduck\RetailCoder.VBE\Inspections\ObsoleteCallStatementInspection.cs:line 24

The problem is with the soft cast on this line:

issue.Context.Parent as VBAParser.ExplicitCallStmtContext

Which returns a null reference. The base constructor for a CodeInspectionResultBase does not accept that, by design:

        if (context == null && comment == null)
            throw new ArgumentNullException("[context] and [comment] cannot both be null.");

Fixing the soft cast will fix that bug.

@retailcoder retailcoder added bug Identifies work items for known bugs feature-inspections up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky labels May 4, 2015
@retailcoder retailcoder added this to the Version 1.31 milestone May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies work items for known bugs feature-inspections up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky
Projects
None yet
Development

No branches or pull requests

1 participant