C# Version for development, build, and deployment
I'm having a little trouble understanding a couple things, but mainly:
What language version am able to use when writing code?I've got a solution with .NET 4.8 Framework assemblies, .NET Standard 2.0, .NET 6, and .NET 7 in co-existence. .NET 8 rolled out recently with C# 12 and for example, there are now collection expressions that I would like to use, but not sure how to safely ensure that I'm not breaking the build/deployment by doing so. Do I just need to install .NET 8 on the development machine, build server, and deployment server to ensure that everything works across the board or is there more to it? Is accessible C# features tied to .NET version of application? Or installed on machine?
Collection expressions (Collection literals) - C#
Collection expressions are expressions that convert to many different collection types. They enable you to write literal values for collection elements, or import other collection elements into a new collection.
17 Replies
if you need to target all those frameworks then you're limited to the lowest common language version afaik
which would be C# 7.3?
I see. I guess I'm confused as why I'm getting suggestions for collection expressions in the .NET Standard 2.0 project. Also I believe a coworker had already pushed changes that used a collection expression and it was able to build and deploy yet none of the projects are .NET 8 yet - which is what spawned my confusion
Will that present in a runtime error when that code is exercised?
i mean, if it compiles i'd expect it to work
😦
I mean that's good? But doesn't help my understanding on versions here haha
i'm lucky enough to not have to do any multi-targeting or major legacy code support so i'm not super familiar with it
you can go higher with features that don't need runtime support if you use a polyfill like the Polysharp nuget package (cc @chronolinq)
That makes sense. I have no polyfills though and it's just... working haha
not all features need a polyfill
things like records and
init
on props do though
nullable ref types can be used downlevel as well, though it'll be annoying since none of the BCL will annotated for itUnknown User•11mo ago
Message Not Public
Sign In & Join Server To View
y scared by net7? 👀 tbh net 4.8 been killing us 😦
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Yea I agree
We have some dependencies we need to kill/migrate before we can go to net8, but hopefully we can soon
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
Old monolith web app in net 4.8
Took on a ton of dependencies that are difficult to break out
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
It is
ns2.1 is where is stopped
My guy it was only superseded in November lmao
There's still a few months