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

Avoid Invalid Cast exception in EmptyMethodInspection #5229

Merged
merged 1 commit into from Oct 18, 2019

Conversation

BZngr
Copy link
Contributor

@BZngr BZngr commented Oct 16, 2019

This PR addresses the invalid cast exception reported by @daFreeMan in chat.

2019-10-16 12:03:10.8715;WARN-2.4.1.5086;Rubberduck.Inspections.Rubberduck.Inspections.Inspector;System.InvalidCastException: Unable to cast object of type 'Rubberduck.Parsing.Symbols.ExternalProcedureDeclaration' to type 'Rubberduck.Parsing.Symbols.ModuleBodyElementDeclaration'.
at Rubberduck.Inspections.Concrete.EmptyMethodInspection.<>c__DisplayClass1_0.b__0(Declaration member) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Concrete\EmptyMethodInspection.cs:line 45
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable1 source) at Rubberduck.Inspections.Abstract.InspectionBase.GetInspectionResults(CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\InspectionBase.cs:line 112 at Rubberduck.Inspections.Rubberduck.Inspections.Inspector.RunInspection(IInspection inspection, ConcurrentBag1 allIssues, CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Inspector.cs:line 179;System.InvalidCastException: Unable to cast object of type 'Rubberduck.Parsing.Symbols.ExternalProcedureDeclaration' to type 'Rubberduck.Parsing.Symbols.ModuleBodyElementDeclaration'.
at Rubberduck.Inspections.Concrete.EmptyMethodInspection.<>c__DisplayClass1_0.b__0(Declaration member) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Concrete\EmptyMethodInspection.cs:line 45
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable1 source) at Rubberduck.Inspections.Abstract.InspectionBase.GetInspectionResults(CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Abstract\InspectionBase.cs:line 112 at Rubberduck.Inspections.Rubberduck.Inspections.Inspector.RunInspection(IInspection inspection, ConcurrentBag1 allIssues, CancellationToken token) in C:\projects\rubberduck\Rubberduck.CodeAnalysis\Inspections\Inspector.cs:line 179

Copy link
Contributor

@MDoerner MDoerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

External procedures are considered to be members since they are used like functions. However, they do not have a body in contrast to module body elements and thus are not in scope for this inspection.

@retailcoder retailcoder merged commit d5c9b77 into rubberduck-vba:next Oct 18, 2019
@BZngr BZngr deleted the EmptyMethos_InvalidCast branch September 25, 2020 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants