OmniSharp / omnisharp-server

HTTP wrapper around NRefactory allowing C# editor plugins to be written in any language.
http://www.omnisharp.net
MIT License
380 stars 97 forks source link

Fixed NullReferenceException when project context not found #200

Closed jtbm37 closed 9 years ago

jtbm37 commented 9 years ago

I managed to raise this error while running :OmniSharpFindImplementations.

It seems that in my solution with several projects (40+) the server is unable to resolve the context of one of the project.

00053704 System.NullReferenceException: Object reference not set to an instance of an object.
   at OmniSharp.Solution.ProjectFinder.<>c__DisplayClass3.<FindProjectsReferencing>b__2(IAssemblyReference r) in d:\Projects\omnisharp-vim\server\OmniSharp\Solution\ProjectFinder.cs:line 23
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at OmniSharp.Solution.ProjectFinder.<>c__DisplayClass3.<FindProjectsReferencing>b__1(IProject p) in d:\Projects\omnisharp-vim\server\OmniSharp\Solution\ProjectFinder.cs:line 23
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at System.Linq.Enumerable.<SelectManyIterator>d__1`2.MoveNext()
   at OmniSharp.GotoImplementation.GotoImplementationHandler.GetMemberResponse(ITypeResolveContext rctx, MemberResolveResult resolveResult) in d:\Projects\omnisharp-vim\server\OmniSharp\GotoImplementation\GotoImplementationHandle
   at OmniSharp.GotoImplementation.GotoImplementationHandler.FindDerivedMembersAsQuickFixes(GotoImplementationRequest request) in d:\Projects\omnisharp-vim\server\OmniSharp\GotoImplementation\GotoImplementationHandler.cs:line 47
   at OmniSharp.GotoImplementation.GotoImplementationModule.<>c__DisplayClass2.<.ctor>b__0(Object x) in d:\Projects\omnisharp-vim\server\OmniSharp\GotoImplementation\GotoImplementationModule.cs:line 15
   at CallSite.Target(Closure , CallSite , Func`2 , Object )
   at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)
Solution

A simple null check fixes it.