You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NullReferenceException when LockFileUtilities.GetLockFile returns null; error reason silently swallowed #740
ProjectAnalysisService.AnalyzeProjectAsync calls LockFileUtilities.GetLockFile(lockFilePath, NullLogger.Instance) and later on dereferences the result without a null check.
GetLockFile can return null for several reasons, and when that happens the tool crashes with a bare NullReferenceException further down, where lockFile.Targets is accessed:
Discovering projects...
Analyzing project(s)...
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at DotNetOutdated.Core.Services.ProjectAnalysisService.AnalyzeProjectAsync(String projectPath, Boolean runRestore, Boolean includeTransitiveDependencies, Int32
transitiveDepth, String runtime) in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated.Core/Services/ProjectAnalysisService.cs:line 56
at DotNetOutdated.Program.<>c__DisplayClass98_0.<<OnExecute>b__0>d.MoveNext() in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated/Program.cs:line 209
...
The actionable problem isn't only the NRE--it's that the reason GetLockFile failed is not surfaced. The NuGet lock-file reader writes diagnostics through the ILogger it's given, but the call site passes NullLogger.Instance, so any warning or error that might have explained the failure is discarded. The user is left with no clue what happened exactly.
Two things should change:
Pass a real ILogger to GetLockFile so any underlying reason (when one is logged at all--it isn't always) reaches the user.
Null-check the returned LockFile and throw a clear, contextual exception (or skip the project) instead of letting the NRE propagate.
Activity
Fix NullReferenceException when GetLockFile returns null (dotnet-outd…
Fix NullReferenceException when GetLockFile returns null (#740) (#741)