Reporter | Chris F (psylenced) |
---|---|
Created | Apr 26, 2018 5:42:03 AM |
Updated | Apr 26, 2018 5:42:03 AM |
Subsystem | Code Style - Cleanup |
Assignee | Razmik Seysyan (razmik) |
Priority | Normal |
State | Submitted |
Type | Bug |
Fix version | No Fix versions |
Affected versions | 2018.1 |
Fixed In Version ReSharper | Undefined |
VsVersion | VS 2017 RTM |
I have the following bit of code:
bool BoolField = (this.Service.GetOption("OptionName")?.ValueBool).GetValueOrDefault();
The GetOption
method returns a class which has property of System.Nullable<bool> ValueBool
.
When running code cleanup, the brackets are removed and the code gets changed to:
bool BoolField = this.Service.GetOption("OptionName")?.ValueBool.GetValueOrDefault();
This causes the following error and code is no longer compilable:
Error CS0266: Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)
So the code cleanup does not detect that the brackets are necessary to allow the return to correctly cast to a non-nullable bool.
Visual Studio Version: 2017 (15.6)
Have attached my clean-up settings as an image below.