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

RSRP-469308: Using a validation utility method which has been properly annotated generates 'Expression is always true/false/null' warnings on usages

$
0
0
Reporter James McManus (MrLore) James McManus (MrLore)
Created Apr 18, 2018 12:38:01 PM
Updated Apr 18, 2018 12:38:01 PM
Subsystem No Subsystem
Assignee Unassigned
Priority Normal
State Submitted
Type Usability Problem
Fix version No Fix versions
Affected versions 2017.3.2
Fixed In Version ReSharper Undefined
VsVersion All Versions

Consider the following utility method, which I created to use in custom 'bool TryParse(object input, out T value)' methods:

[ContractAnnotation("=> true; value:null => toFill:null, true; value:notnull => toFill:notnull, true")]
public static bool ValidFill<T>(out T toFill, T value)
{
    toFill = value;
    return true;
}

It simply allows you to fill the out parameter and return true in the same line, however using this method will generate a warning saying 'Expression is always true'. This is actually exactly what I want, but I don't want to replace one of those saved lines of fill and return code with a disable resharper warning - is there any way I can tell resharper that I know all these methods always return the same value and that is precisely the point of them?


Viewing all articles
Browse latest Browse all 106942

Trending Articles