I have a standard pipeline agent that works for CI whenever a pull request merged into master. It was working fine until I merged a pull request created by a visual-studio-2019 developed branch. Now I am getting
error CS8107: Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.
It is working fine when I push any changes with vs2017.
What should I do to avoid this error?
P.S: I want to keep using vs2019
Thanks in advance.
This happen when you have code like the following:
MyType foo = default; // assign the default value for this type
In C# 7, the supported syntax is:
MyType foo = default(MyType);
but the simpler form was added in 7.1.
There are two ways to fix this:
default
to have a type, and change the settings so that the IDE will prefer the verbose form. Here's a picture with the new form turned on, just change the Yes to a No:
If you're using .editorconfig files, you can configure the csharp_prefer_simple_default_expression
setting.latest
it may use a different version between your development box (VS2019) and your build agent (e.g. possibly still on VS2017).I just solved this issue by updating my Agent Pool in the build pipeline to use "Hosted Windows 2019 with VS2019"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With