This repository was archived by the owner on Dec 19, 2018. It is now read-only.
Description Version: ASP.NET Core 2.0 Preview 2 with 2017 Preview (preview) (Version 15.3.0 Preview 6.0)
NuGet Version: Microsoft.AspNetCore.All 2.0.0-preview2-final
Though Razor has updated to support C# 7.1 in #1385 , I failed to compile when I use C# 7.1 feature in Razor View Page.
@page
@model IndexModel
@{
ViewData [ "Title" ] = "Home Page" ;
var x = 1 ;
var y = 2 ;
var t = ( x , y ) ;
ViewData [ "X" ] = t . x ;
ViewData [ "Y" ] = t . y ;
}
I suspect this is because explicit LangVersion in csproj is required to use C# 7.1 feature.
<PropertyGroup >
<TargetFramework >netcoreapp2.0</TargetFramework >
<LangVersion >7.1</LangVersion >
</PropertyGroup >
When I set LangVersion and write C# 7.1 feature in a normal csharp class, meaning not a Razor page, it can be compiled.
public static void Main ( string [ ] args )
{
var x = 1 ;
var y = 2 ;
var t = ( x , y ) ;
Console . WriteLine ( t . x ) ;
Console . WriteLine ( t . y ) ;
BuildWebHost ( args ) . Run ( ) ;
}
Is there any workaround to respect LangVersion during razor compilation?
Reactions are currently unavailable
Version: ASP.NET Core 2.0 Preview 2 with 2017 Preview (preview) (Version 15.3.0 Preview 6.0)
NuGet Version: Microsoft.AspNetCore.All 2.0.0-preview2-final
Though Razor has updated to support C# 7.1 in #1385, I failed to compile when I use C# 7.1 feature in Razor View Page.
I suspect this is because explicit LangVersion in csproj is required to use C# 7.1 feature.
When I set LangVersion and write C# 7.1 feature in a normal csharp class, meaning not a Razor page, it can be compiled.
Is there any workaround to respect LangVersion during razor compilation?