Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
fix possible NullReferenceExceptions in ResolveExtensionMethod; shoul…
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Aug 29, 2010
1 parent 7dc9284 commit e209002
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -28,21 +28,24 @@ public MenuItem Create(RefactoringMenuContext context)
return null;
if (!(context.ResolveResult is UnknownMethodResolveResult))
return null;
if (context.ProjectContent == null)
return null;

UnknownMethodResolveResult rr = context.ResolveResult as UnknownMethodResolveResult;

if (rr.CallingClass == null)

This comment has been minimized.

Copy link
@dgrunwald

dgrunwald Aug 29, 2010

Member

Looks like this check isn't necessary as you're not using CallingClass anymore

return null;

MenuItem item = new MenuItem() {
Header = string.Format(StringParser.Parse("${res:AddIns.SharpRefactoring.ResolveExtensionMethod}"), rr.CallName),
Icon = ClassBrowserIconService.GotoArrow.CreateImage()
};

List<IClass> results = new List<IClass>();

IProjectContent pc = rr.CallingClass.ProjectContent;

SearchAllExtensionMethodsWithName(results, pc, rr.CallName);
SearchAllExtensionMethodsWithName(results, context.ProjectContent, rr.CallName);

foreach (IProjectContent content in pc.ReferencedContents)
foreach (IProjectContent content in context.ProjectContent.ReferencedContents)
SearchAllExtensionMethodsWithName(results, content, rr.CallName);

if (!results.Any())
Expand Down

0 comments on commit e209002

Please sign in to comment.