ZiN*_*NED 1 c# c#-8.0 visual-studio-2019
For one of our projects we're trying to upgrade to use C#8 instead of C#7.1. The upgrade looks like it works, because the compiler looks like it takes C#8 statements (it doesn't mark it as an error). However, when I build the project I get a build failed without any errors showing initially.
The code to test C#8 is of the following lines:
private string TestCSharp8(int x)
{
return x switch
{
0 => "ZERO",
1 => "ONE",
2 => "TWO",
3 => "THREE",
_ => "OTHER"
};
}
Run Code Online (Sandbox Code Playgroud)
The IDE is accepting this code and even suggests to reformat it to this when writing an 'old-fashioned' switch statement. However, when I then build the solution I get the following output in the Error List:

But then the Ouput log shows the following:
When I look at the build log after I put the Ouput verbosity to detailed, I can see the following errors occur:
1>C:\VisualStudio\Repos\XXX\YYY\ZZZ\Repositories\ABC.cs(301,5,301,6): error CS1597: Semicolon after method or accessor block is not valid
1>C:\VisualStudio\Repos\XXX\YYY\ZZZ\Repositories\ABC.cs(304,1,304,2): error CS1022: Type or namespace definition, or end-of-file expected
1>Done executing task "Csc" -- FAILED.
1>Done building target "CoreCompile" in project "XYZ.csproj" -- FAILED.
Run Code Online (Sandbox Code Playgroud)
In the project file I have set the <LangVersion> to latest. The target framework we're targetting is .NET Framework 4.7.1.
The strange thing is all of this works and builds in another solution we're having.
So, can someone please help me in the right direction on how to fix this? At the moment I don't know where to look for the solution.
| 归档时间: |
|
| 查看次数: |
924 次 |
| 最近记录: |