Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

.Net 5 support

Discussion in 'Experimental Scripting Previews' started by Lymdun, Mar 3, 2020.

  1. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Sure! We're working on a Mono upgrade now. This will bring support for the .NET Core class libraries to Unity at the VM level. We're also work on adding support for using CoreCLR as the VM in place of Mono on some platforms. This latter work is more experimental and research-based - it may not prove to be something we can ship.

    The Mono upgrade is something we can and will ship.
     
    ModLunar, Nemikolh, mischa2k and 2 others like this.
  2. Vincenzo

    Vincenzo

    Joined:
    Feb 29, 2012
    Posts:
    146
    Will it land in 2020 LTS?
     
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    It is very unlikely that any .NET Core or .NET 5 support will land in 2020 LTS.
     
  4. Vincenzo

    Vincenzo

    Joined:
    Feb 29, 2012
    Posts:
    146
    And the new mono?
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    I think there is a chance that lands in 2020 LTS, but I'm not yet sure.
     
    valarus, toomasio and Flurgle like this.
  6. Vincenzo

    Vincenzo

    Joined:
    Feb 29, 2012
    Posts:
    146
    If it doesn't land in the LTS that is coming a year from now, it means it will be in something that is LTS 2 years from now. which makes it completely useless for production games. in the short to mid term. (probably even long term)
     
    Neonage likes this.
  7. Lymdun

    Lymdun

    Joined:
    Jan 1, 2017
    Posts:
    46
    Anyway, thanks a lot @JoshPeterson for answering all our questions :)
     
    SenseEater, toomasio and Flurgle like this.
  8. Lymdun

    Lymdun

    Joined:
    Jan 1, 2017
    Posts:
    46
    Just in case, any new thing to report? :)
     
    mischa2k likes this.
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    No, nothing new yet.
     
  10. print_helloworld

    print_helloworld

    Joined:
    Nov 14, 2016
    Posts:
    231
    Fascinating, give a good chunk of props to the researchers from me! @JoshPeterson
     
    SenseEater likes this.
  11. EternalClickbait

    EternalClickbait

    Joined:
    May 5, 2019
    Posts:
    22
    Hey @JoshPeterson ,I'd like to use a .Net 5 (even though it's preview), for the cool features such as C#9 adn the things that come with it. I want to be able to use my .Net 5 library in unity, but it gives me errors because my library uses a higher version of 'System.Runtime'. Is Net 5 support coming in a future version, or will I have to wait until it's out of preview? It would be great if the Unity Team could add support to a alpha/beta version of Unity
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    We don't have any plans for .NET 5 support to announce now. We do plan to support it in the future.
     
  13. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    @JoshPeterson What if we all keep asking for it every single day? Will that make it happen sooner?

    Seriously, though. This is an exciting development. Looking forward to it.
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    I don't think that will make it happen sooner. :) But anyone is free to continue asking. I'll share what information I can when I can.
     
    ModLunar, PKras and MNNoxMortem like this.
  15. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    968
  16. Neonage

    Neonage

    Joined:
    May 22, 2020
    Posts:
    238
    Will .NET 5.0 update provide Roslyn 2.0 with Source Generators feature?
     
    Nemikolh, GilbertoBitt and dadude123 like this.
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    I'm not sure yet. We're doing some work with source generators now (they are pretty cool!), but I can't say yet what will happen in the future with them.
     
    Nemikolh, dadude123 and Neonage like this.
  18. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    If you're going to support .NET 5, why bother with source generators? Why bother with a code editing experience at all? If I were you, I'd just release a NuGet package for dependencies and tell everyone to use Visual Studio to build .dlls for coding. It saves a lot of work for you and drives everyone to the premium coding experience available in the marketplace today.
     
  19. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    There's exactly zero overlap with things that are a "premium experience" and things that involve having Visual Studio installed on your computer.
     
    antosond, xVergilx, JohnnyA and 4 others like this.
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    We support a number of difference code editors. I don't expect that to change with .NET 5 support.
     
  21. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    Why do you need to support any editors at all? Why not just complete the story of building .NET assemblies the developer's editor of choice and consuming it in Unity?

    For game logic, you're a NuGet package away from that. I can imagine how things like Editor extensions and UCB will require a little more work but, in the long run, it would save you so much effort and us so many headaches.
     
    Qbit86 likes this.
  22. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    I guess it has something to do with ease of use. Supposedly, part of the reason why it's easy to start programming with Unity is because you don't have to worry about setting up a class library project and whatnot, but I fail to see the appeal in that — it's not hard at all.
    That said, a nicely integrated option to manage everything yourself would be great. You can do this already, but something about it feels off. Maybe it's just bias. The primary benefit I see is that you wouldn't be stuck with whichever presumably outdated version of Roslyn that Unity is currently using, so you can immediately use new syntactic sugar. You could also use any .NET language, not just C#.
    But I start to question the feasibility of this when I consider the amount of fancy crap that Unity does behind the scenes (which, for example, prohibits the usage of constructors in MonoBehaviours). Who knows what can of worms you open by taking the self-compilation route.
     
    MaxGuernseyIII likes this.
  23. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    Precisely.

    The main problem is accessing dependencies. To write a .NET Standard 2.0 library that depends upon the Unity stuff (so you can, for instance, build MonoBehaviour classes in a .dll), you need to dig up some .dlls. I always used to scrape them out of my editor build. Then I had to make sure my projects properly referenced these .dlls based on location. Then I had to make sure my build server would have them in that location.

    An alternative was to build to the Unity framework. At least it was an option with the Visual Studio. I can say about other IDEs. That's all fine and dandy until you are building on a hosted agent and you can't get the framework installed because you (rightly) do not have permissions.

    Neither of these options are practical. It's cheaper to just keep a layer of Unity-aware code in your Unity project, encapsulated behind abstractions, and pay the occasional costs associated with that strategy.

    The main thing missing is a NuGet package. A package that you can depend upon from a .NET Standard project that provides the dependencies you need to compile Unity-aware code.
     
    Qbit86 and Ramobo like this.
  24. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    430
  25. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    For Unity Tech it's probably worth to consider moving part of the engine to the managed side.
     
    Neonage likes this.
  26. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    Unity does it partially. But I'm curious to see how well Unity performs with .NET 5, both game and editor.
     
  27. Lymdun

    Lymdun

    Joined:
    Jan 1, 2017
    Posts:
    46
    Any news about it?
     
    Qbit86 likes this.
  28. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    The book is not yet closed on 2020 LTS, but I suspect that new Mono will not make it.
     
    GilbertoBitt and Lymdun like this.
  29. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    May be experimental support? :)
     
  30. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    I don't expect event that to be ready.
     
  31. EternalClickbait

    EternalClickbait

    Joined:
    May 5, 2019
    Posts:
    22
    @JoshPeterson When you say
    Do you mean that the 2020 LTS versions of Unity most likely won't support mono, and will probably .Net or IL2CPP?
     
  32. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    No, sorry. I mean that it will not have an upgraded version of Mono. The 2020 LTS release will continue to support the same Mono and IL2CPP versions as the 2020.1 release.
     
  33. EternalClickbait

    EternalClickbait

    Joined:
    May 5, 2019
    Posts:
    22
    Cool, thanks.
     
  34. gui_brawl

    gui_brawl

    Joined:
    Sep 2, 2020
    Posts:
    3
  35. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    430
    Net 5 won't have full feature set this November. Features will be gradually added till Noveber 2021 until NET 6 LTS.
    So, it more likely for Unity to wait NET 6 LTS.
     
  36. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    There is actually no full feature set, which one can also say .NET 6 is not complete and will come with .NET 7 by November 2022. There was a new version every year, and an LTS every 2 years, which will be .NET 6. Is that what you meant?
     
    valarus likes this.
  37. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
  38. thorgeir

    thorgeir

    Joined:
    May 7, 2019
    Posts:
    2

    Attached Files:

  39. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
  40. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    Qbit86 likes this.
  41. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    Compiler only.
     
  42. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    What about types that were already in net core like Span @JoshPeterson ?

    If not then this C# 8 feature:
    Code (CSharp):
    1. Span<int> numbers = stackalloc[] { 1, 2, 3, 4, 5, 6 };
    also won't work without manually adding System.Memory nuget package that I guess isn't supported and may not work correctly.
     
    Ramobo and Qbit86 like this.
  43. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Sure - C# 8 support was added by updating the version of Roslyn that Unity ships with.

    We do plan to support C# 9, although it looks like C# 9 will require the use of the .NET 5 class libraries, so we will need to add .NET 5 support first.

    This is certainly possible (we've done some internal prototyping), but we don't have any plans to announce in this respect now.
     
    saskenergy, Neonage and Qbit86 like this.
  44. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    No, we don't support .NET Standard 2.1 yet, just .NET Standard 2.0.
     
  45. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Yeah, sorry, I should not have written "all" for that blog post entry. I did not intend to be misleading. Instead I just did not think about the C# 8 features that require class library support which is in .NET Standard 2.1 or later.
     
  46. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    Were there any issues? I've upgraded it manually in 2020.1 to fix few C# 7.3 compiler bugs and be able to use
    -a:RoslynAnalyzers\Microsoft.Unity.Analyzers.dll
    in csc.rsp and unity console (get rid of SerializedField false warnings).

    C# 8.0 works for me in 2020.1 by adding
    -langversion:8.0
    to csc.rsp and
    Directory.Build.props
    in project folder:
    Code (CSharp):
    1. <Project>
    2. <PropertyGroup>
    3.    <LangVersion>8.0</LangVersion>
    4. </PropertyGroup>
    5. </Project>
    Had to also delete .vs temp folder to get Directory.Build.props to load.
     
    Neonlyte likes this.
  47. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    No, I don't recall any specific issues that happened here. We're not planning to back port to 2020.1 though, as that release won't be supported for too much longer. Our goal was to get the C# 8 support into the 2020 LTS release.
     
    Kamyker likes this.
  48. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Man, stackalloc would be FIRE LIT
     
  49. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    stackalloc already works, you just have to put it into an int* instead of a span<int>
     
  50. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    Still doesn't work with stuff like Stream.Read.
     
    Qbit86 likes this.