创建ASP。NET Core 6 MVC应用程序,带有Visual Studio 2022中的EF Core和Npgsql。
在中单击“清除所有NuGet缓存”按钮后
Visual Studio > Tools Options > NuGet Package Manager > General
属性Microsoft。代码分析。CSharp。语言版本。源代码中的CSharp9
CSharpParseOptions.Default.WithLanguageVersion(Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp9);
引发编译错误
错误CS0117“LanguageVersion”不包含的定义
'CSharp9'
所有NuGet软件包都是最新的。如何解决此问题?程序集信息不包含CSharp9成员:
#region Assembly Microsoft.CodeAnalysis.CSharp, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// location unknown
// Decompiled with ICSharpCode.Decompiler 6.1.0.5902
#endregion
namespace Microsoft.CodeAnalysis.CSharp
{
//
// Summary:
// Specifies the language version.
public enum LanguageVersion
{
//
// Summary:
// C# language version 1
CSharp1 = 1,
//
// Summary:
// C# language version 2
CSharp2 = 2,
//
// Summary:
// C# language version 3
//
// Remarks:
// Features: LINQ.
CSharp3 = 3,
//
// Summary:
// C# language version 4
//
// Remarks:
// Features: dynamic.
CSharp4 = 4,
//
// Summary:
// C# language version 5
//
// Remarks:
// Features: async, caller info attributes.
CSharp5 = 5,
//
// Summary:
// C# language version 6
//
// Remarks:
// Features:
// ⢠Using of a static class
// ⢠Exception filters
// ⢠Await in catch/finally blocks
// ⢠Auto-property initializers
// ⢠Expression-bodied methods and properties
// ⢠Null-propagating operator ?.
// ⢠String interpolation
// ⢠nameof operator
// ⢠Dictionary initializer
CSharp6 = 6,
//
// Summary:
// C# language version 7.0
//
// Remarks:
// Features:
// ⢠Out variables
// ⢠Pattern-matching
// ⢠Tuples
// ⢠Deconstruction
// ⢠Discards
// ⢠Local functions
// ⢠Digit separators
// ⢠Ref returns and locals
// ⢠Generalized async return types
// ⢠More expression-bodied members
// ⢠Throw expressions
CSharp7 = 7,
//
// Summary:
// C# language version 7.1
//
// Remarks:
// Features:
// ⢠Async Main
// ⢠Default literal
// ⢠Inferred tuple element names
// ⢠Pattern-matching with generics
CSharp7_1 = 701,
//
// Summary:
// C# language version 7.2
//
// Remarks:
// Features:
// ⢠Ref readonly
// ⢠Ref and readonly structs
// ⢠Ref extensions
// ⢠Conditional ref operator
// ⢠Private protected
// ⢠Digit separators after base specifier
// ⢠Non-trailing named arguments
CSharp7_2 = 702,
//
// Summary:
// C# language version 7.3
CSharp7_3 = 703,
//
// Summary:
// C# language version 8.0
CSharp8 = 800,
//
// Summary:
// The latest major supported version.
LatestMajor = 2147483645,
//
// Summary:
// Preview of the next language version.
Preview = 2147483646,
//
// Summary:
// The latest supported version of the language.
Latest = int.MaxValue,
//
// Summary:
// The default language version, which is the latest supported version.
Default = 0
}
}
微软代码分析。CSharp.dll文件不是从任何anyprojet直接引用的。
NuGet窗口不显示任何名称中包含roslyn的包。