Reputation: 9356
If I build and publish a NuGet package with a Language Version of 9, can I install and reference the NuGet package in a project using a lower Language version (for example c# 7)?
NuGet Package .csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion>
</PropertyGroup>
</Project>
Consuming library .csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
</Project>
Upvotes: 3
Views: 869
Reputation: 9356
This is possible.
So after a suggestion from @ADyson I tried to do this myself locally.
It took me about 30 minutes to build a .netstandard2.0
project with a reference to IAsyncEnumerable
with the Microsoft.Bcl.AsyncInterfaces 5.0.0 NuGet package as it doesn't natively get included in .netstardard2.0
.
After packing up a NuGet locally, I included it into a Console Application using .netcore2.1
and called a method that used the IAsyncEnumerable
. It worked!
Upvotes: 4