Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-463422: Mistaken possible null report

$
0
0
Reporter Alexander Kurakin (Alexander.Kurakin) Alexander Kurakin (Alexander.Kurakin)
Created Mar 6, 2017 3:28:14 PM
Updated Apr 16, 2018 5:18:42 PM
Subsystem Code Analysis - Annotations
Assignee Ivan Serduk (IvanSerduk)
Priority Major
State Submitted
Type Bug
Fix version 2017.2
Affected versions 2017.1
Fixed In Version ReSharper Undefined
VsVersion All Versions
The code below has ReSharper mistakenly complaining that the results of server.MapPath() can be null, and that therefore File.GetLastWriteTime() is potentially being given a null argument.

If you pass a null to MapPath, ReSharper is (correctly) happy that this result can be passed successfully to GetLastWriteTime() – there is a guaranteed non-null result from GetLastWriteTime(null). If you pass a NON-null argument to MapPath(), ReSharper is also (correctly) happy. It is only if you pass a variable like "file" to the MapPath() method that ReSharper (incorrectly) complains.
private DateTime NullParameterIssue( [NotNull] System.Web.HttpServerUtility server, 
[CanBeNull] string file)
=> System.IO.File.GetLastWriteTime(server.MapPath(file));

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>