I'm spinning up a new ASP.NET application, using the default SPA template. I'm going through and cleaning some things up to be more consistent with my style, but I'm running into an issue when trying to convert the template standard property accessors to using C#7 property expression bodies.
For example, I'm attempting to change
public ApplicationSignInManager SignInManager
{
get { return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>(); }
private set { _signInManager = value; }
}
to
public ApplicationSignInManager SignInManager
{
get => _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
private set => _signInManager = value;
}
Which should be functionally equivalent.
After making the change, there are no intellisense errors, and everything appears to be correct. However, when I attempt to build the solution, I only ever see a 'Build Failed' message at the bottom of Visual Studio, with no errors in the error list.
The build output shows the following:
1>------ Build started: Project: GithubDashboard, Configuration: Debug Any CPU ------ 1>...\Controllers\ManageController.cs(34,8,34,10): error CS1043: { or ; expected 1>...\Controllers\ManageController.cs(34,8,34,10): error CS1513: } expected 1>...\Controllers\ManageController.cs(34,90,34,90): error CS1513: } expected 1>...\Controllers\ManageController.cs(35,16,35,18): error CS1043: { or ; expected 1>...\Controllers\ManageController.cs(35,16,35,18): error CS1513: } expected 1>...\Controllers\ManageController.cs(36,4,36,4): error CS1513: } expected
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm using Visual Studio 2017 (this occurs in both RTM and update 15.3.4), and the solution has a single project targeting .NET 4.6. I'm able to do this type of syntax in other projects, but for some reason is failing in this project.
I've also attempted to manually force the language version from default
to C# 7.0
, and when building I receive the following error:
Invalid option '7' for /langversion; must be ISO-1, ISO-2, Default or an integer in range 1 to 6.
Am I missing something getting this to work? Is C#7 not supported when building an ASP.NET application?