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
9 Replies
that one appears to also target .net6
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.
furthermore from your own link, if you open the
lib
folder you can see a net6.0
folder inside it
@ja yeti@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
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 allgreat, that sounds clear to me now
if there's any more in depth resource explaining this I'd be interested to read more
what part in particular?
if you mean the
#if
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directivesC# preprocessor directives - C#
Learn the different C# preprocessor directives that control conditional compilation, warnings, nullable analysis, and more
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.
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