英文:
How to fix Visual Studio "bad compile constant value" error when using the C# 11 Raw String Literals feature?
问题
I'm writing a test method that appears to be reasonable to have a JSON value attributed to a variable. I decided to use the C# 11 Raw String Literals feature to improve the code readability. The thing is Visual Studio still complaining about the usage of this feature and returning the "bad compile constant value" error.
The above value was copied from the Microsoft Docs https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings
Info regarding the project:
It's a C# NUnit test project.
I'm using .NET 6 which I know uses C#10 as the default language (as we can see here).
So, using Directory.build.props as directives to build the projects I added to the root build.props file the following line:
<LangVersion>11.0</LangVersion>
The projects in the whole solution compile even using Visual Studio IDE or with the dotnet build command line (and also the tests are passing).
How to fix that?
I tried to determine the default language for the project using visual studio project properties (and it looks like ok).
I also tried the indentation thing as suggested in this answer https://stackoverflow.com/a/75825615/3434514
I'm expecting Visual Studio to recognize the usage of the "Raw string literals declaration."
英文:
I'm writing a test method that appears to be reasonable to have a JSON value attributed to a variable. I decided to use the C# 11 Raw String Literals feature to improve the code readability. The thing is Visual Studio still complaining about the usage of this feature and returning the "bad compile constant value" error.
The above value was copied from the Microsoft Docs https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings
Info regarding the project:
It's a C# NUnit test project.
I'm using .NET 6 which I know uses C#10 as the default language (as we can see here).
So, using Directory.build.props as directives to build the projects I added to the root build.props file the following line:
<LangVersion>11.0</LangVersion>
The projects in the whole solution compile even using Visual Studio IDE or with the dotnet build command line (and also the tests are passing).
How to fix that?
I tried to determine the default language for the project using visual studio project properties (and it looks like ok).
I also tried the indentation thing as suggested in this answer https://stackoverflow.com/a/75825615/3434514
I'm expecting to Visual Studio recognize the usage of the usage of """ Raw string literals declaration.
答案1
得分: 1
你需要安装最新版本的JetBrains ReSharper。
英文:
You need the latest version of JetBrains ReSharper installed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论