C
C#11mo ago
ja yeti

Can anyone explain me why referencing newer package versions is possible? net8 in net6 solution

In a .NET6 project this seems to work without problems, how it is possible and is it just so that https://nuget.info/packages/Microsoft.Extensions.Configuration.Abstractions/8.0.0 package containts lib/net6 version built? How can I be sure there's no compatibility issues at some time of usage I couldn't spot now? Example
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
9 Replies
jcotton42
jcotton4211mo ago
that one appears to also target .net6
jcotton42
jcotton4211mo ago
Microsoft.Extensions.Configuration.Abstractions 8.0.0
Provides abstractions of key-value pair based configuration. Interfaces defined in this package are implemented by classes in Microsoft.Extensions.Configuration and other configuration packages.
jcotton42
jcotton4211mo ago
furthermore from your own link, if you open the lib folder you can see a net6.0 folder inside it @ja yeti
ja yeti
ja yetiOP11mo ago
@jcotton42thanks, just been wondering, since it's 2 major versions, how compatiblity is preserved, is it solely based on target version eg net6 lib wouldn't use methods added in net8, so it wouldn't crash, fail or so
jcotton42
jcotton4211mo ago
yes if there's anything .net8-specific in there it would've been #if'd out for the .net 6 build otherwise it wouldn't have compiled at all
ja yeti
ja yetiOP11mo ago
great, that sounds clear to me now if there's any more in depth resource explaining this I'd be interested to read more
jcotton42
jcotton4211mo ago
what part in particular?
jcotton42
jcotton4211mo ago
C# preprocessor directives - C#
Learn the different C# preprocessor directives that control conditional compilation, warnings, nullable analysis, and more
ja yeti
ja yetiOP11mo ago
I've seen some different stuff like type forwards, been curious how many other things like that are there https://github.com/dotnet/runtime/blob/4068acbe4862fd4f8f3758f31a034851ffffc4ce/src/libraries/System.Collections/src/System/Collections/BitArray.cs#L17C38-L17C55 this is older framework as far as I know, but makes build system complex and I would want to understand how many things like this exist I've refined the search to verify how much stuff specific to newer .NET could be there, seems it's safe for this particular extensions library https://github.com/search?q=repo%3Adotnet%2Fruntime+if+NET7_0_OR_GREATER+Extensions&type=code
GitHub
Build software better, together
GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
From An unknown user
From An unknown user
From An unknown user
GitHub
runtime/src/libraries/System.Collections/src/System/Collections/Bit...
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. - dotnet/runtime
Want results from more Discord servers?
Add your server