In Visual Studio 2017 we have a C#, ASP.NET, MVC project that fails to build when we inline the out variable declaration for int.TryParse, as suggested by Intellisense. The project successfully builds when we declare the variable before executing int.TryParse. We have Visual Studio 2017 version 4.7.02053. The Target Framework is 4.5.2.
This pattern builds in VS 2017.
int consumerID = 0;
int.TryParse(model.TextConsumerID, out consumerID);
This pattern fails to build in VS 2017.
int.TryParse(model.TextConsumerID, out int consumerID);
We use the first pattern in multiple places in the application. When we inline any of the int.TryParse declarations, per the Intellisense suggestion, then Visual Studio fails to build and shows 0 Errors and 0 Warnings. If I have any classes opened that contain other int.TryParse commands that are not inlined, then the following Messages will appear: "Variable declaration can be inlined."
Both patterns should work.
The "Treat warnings as errors" option is set to "None" under the project Properties > Build tab. There is no visible option for treating Messages as errors.
Is this a Visual Studio 2017 bug, or is there some build setting that I need to adjust to fix this? Thanks.