Closed chrbanx closed 1 year ago
Thanks for the note; needs some thought. https://github.com/dotnet/csharplang/issues/3376 seems to be discussing roughly this issue.
Indeed, all .NET Framework targets use C# 7.3 as the default. You can update the language version by adding a LangVersion
element in your csproj.
For example:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net462</TargetFramework>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
</ItemGroup>
</Project>
Is this an issue for you?
Were you able to solve your issue by explicitly setting LangVersion
to 10.0?
Were you able to solve your issue by explicitly setting
LangVersion
to 10.0?
Yes, thanks, it does work. It's slightly suboptimal as the newer language versions are officially unsupported with .NET Framework, so care needs to be taken to avoid using other new language features that aren't as compatible with the runtime. Not a major concern though.
v7.0.0 deprecates some extensions and adds
ConfigurationReaderOptions
. This has some properties with init-only setters, which require C# language version 9. The library publishes support for net462/netstandard2.0 though, which use langversion 7.3, and compilation fails withError CS8400 Feature 'init-only setters' is not available
.