Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Unity adopting Net Standard libraries by default

Discussion in 'Experimental Scripting Previews' started by bdovaz, Jul 15, 2017.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,051
    Are you evaluating on adopting some of the following standard libraries? Are you tracking what Microsoft is doing? Do you know some of these libraries?

    https://github.com/aspnet/DependencyInjection
    https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection/

    https://github.com/aspnet/Logging
    https://www.nuget.org/packages/Microsoft.Extensions.Logging/

    https://github.com/aspnet/Localization
    https://www.nuget.org/packages/Microsoft.Extensions.Localization/

    https://github.com/aspnet/Configuration
    https://www.nuget.org/packages/Microsoft.Extensions.Configuration

    https://github.com/aspnet/Options
    https://www.nuget.org/packages/Microsoft.Extensions.Options

    It would be a huge advantage if we could use some of these standard libraries in Unity. Why?

    - So we could bring our external developed libraries to Unity (without depending on UnityEngine like with "Debug.Log" that is a simple example but potential problem. Sometimes we have another c# project with a backend server that could share much code between that project and Unity.
    - Integrate better with third party libraries that could bring to Unity via nuget and "wire up" perfectly. Like I said, think of a library that uses ILogging interface of that Microsoft logging package.
    - Watch out with roadmap future features like: "Basic Player Localization" (https://unity3d.com/es/unity/roadmap). This must use IStringLocalizer and such of Localization package so we can integrate it better with other libraries please.

    Also it would be a huge advantage to use the microsoft standard dependency injection library to use it inside Unity please. I know that we can import it ourself but I mean that Unity uses itself like asp net core "Startup" class works.

    I know that some of them are huge changes but Unity needs to go in the right direction and don't reinvent the wheel. Also it should go for SOLID:

    https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)

    It's better for everyone and helps with TDD:

    https://en.wikipedia.org/wiki/Test-driven_development

    It's a WIN-WIN for Unity itself (doing things better, QA...) and developers.

    Note: Despite of being under "aspnet" versions targeting NET STANDARD 2.0 don't have dependencies on "asp net core" packages.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    I don't have specific knowledge about any of these libraries. However, we are working closely with Microsoft and Xamarin. We're working now on support for .Net Standard 2.0 in Unity, so all of these libraries should just work.

    As to whether we can replace things like Debug.Log, I'm not sure. We'll likely add support for these libraries first, then evaluate how they can be better integrated with Unity.
     
    Enrico-Monese likes this.
  3. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    Yes, that would be great. I guess adopting all these plus TPL, Rx and NuGet would significantly upgrade hmm... cultural background of Unity ecosystem.
     
  4. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    Now when .NET Standard 2.0 is released, are there any estimates on when it is adopted by Unity?

    For example in such scenario: targeting mobile platform in Unity (Android or iOS) I reference dll which is built outside of Unity as regular `.netstandard2.0` assembly. More advanced scenario: some crypto or smth, that is not fully managed and requires some platform-specific support from target framework (which claims to support .NET Standard 2.0).
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    We're still actively working on .NET Standard 2.0 support. I can't say yet when it will land, but we want to get it out as soon as possible.

    Our goal is to support any assembly built against .NET Standard 2.0 on all Unity platforms.
     
    Qbit86 likes this.
  6. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,051
    Fantastic goal.

    I'm curious how are you going to handle nuget package references. I dream one day on resolving them from visual studio.

    Also, what about on my suggestions on adopting standard libraries? What about your localization feature? Or DI and IOC adopted by Unity?
     
    Qbit86 likes this.
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    We're still working out how nuget package references will work. We don't have any plans now for syntonization from Visual Studio to Unity. I think we will just keep the one-way Unity to Visual Studio synchronization.

    Since any library built against .NET standard 2.0 will work, these should as well. We're not yet ready to switch to using this code as the standard practice in Unity though. That will require more time and thought to see if people use them and for us to get a better understanding of how they work.
     
  8. a-shoulson

    a-shoulson

    Joined:
    Jun 24, 2015
    Posts:
    8
    Eagerly awaiting netstandard 2.0 support. Currently working on a game with a standalone server using .NET Core, so being able to share common libraries between Unity and the standalone server will be a huge boost. Hope this makes it into a beta build soon.
     
    mhoward and Qbit86 like this.
  9. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,051
    Any news on this @JoshPeterson? It's been half a year and we already have .NET Standard 2.0 in the current beta.

    Are you thinking on using this basic standard libraries that are used across thousands of developers and that Microsoft work it's built on top of this?
     
    Qbit86 likes this.
  10. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    276
    I am unclear what you are asking for. You should be able to make use of .NET Standard libraries now starting in 2018.1.
     
  11. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,051
    Read my first post please and you should understand it.

    I mean that:
    - If you have in the roadmap that you are going to make a runtime localization API you could use microsoft nuget package that exposes this already and build your API on top of that.
    - You can make Debug class implement microsoft nuget package for logging so we can reuse more code and wire up with other libraries on nuget.
    - You should go for SOLID design and implement microsoft dependency injection library and create and implement interfaces to apply inversion control and be more tdd and mock many tests.

    In our case we have many projects that have a backend in ASP NET Core that we would like to share more and more code and if Unity adopts this Microsoft standard and lightweight libraries it would make life easier for us.

    We are applying SOLID and TDD for our code base but we are facing many issues because of Unity's design.
     
    YurySedyakin and Qbit86 like this.
  12. a-shoulson

    a-shoulson

    Joined:
    Jun 24, 2015
    Posts:
    8
    For what it's worth I have a Unity client and .NET Core (not ASP.NET) server and am having no problems now sharing .NET Standard libraries between them. These are all libraries I've written though, nothing off the shelf.
     
    MunchyYDL likes this.
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,931
    We don't have this on the roadmap now. I wouldn't rule it out in the future, but we're not planning any large-scale changes like this to the Unity API at the moment.