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

C# Collections and .NET 2.0

Discussion in 'Project Tiny' started by furroy, Jun 7, 2019.

  1. furroy

    furroy

    Joined:
    Feb 24, 2017
    Posts:
    93
    It's my understanding that I have to write to .NET 2.0 standards for Tiny. A bit of a drag but I can live with that if it wasn't so painful to know what's valid vs invalid, because I'm not always sure what that means in practice. Due to all the errors I get trying to import some code, it's clear that HashSet<T> isn't supported. My Visual Studio happily compiles up everything just fine, but then it all dies trying to build in Unity.

    Anyone have a quick rundown on what is valid to use? I't seems like Dictionary was in 2.0 but I'm having trouble getting any code that used it running, so not sure if I'm having other issues. Is Linq allowed?

    I could have swore Visual Studio would let you specify what versions of C# and .NET to build with, as it would be much easier to get errors there. I can't figure out where to set any of that in VS now. It seems like my Visual Studio project that Unity made should already be setup this way?

    ps. While I have you here, is the debugger in Visual Studio supposed to work with Tiny yet? I can't get it to work and I don't know if I don't have something configured right or it's just not a thing yet.
     
  2. yossi_horowitz_artie

    yossi_horowitz_artie

    Joined:
    Jan 30, 2019
    Posts:
    87
    Ferran_SP likes this.
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    It is not .NET Standard 2.0. We just made an empty mscorlib.dll project and kept manually adding stuff until our sample content and the ECS system compiled. It's really small right now. This was the only way we could ensure that you pay only for what you need and that out of the box the game can compile to a very small size. The default .NET Standard 2.0 mscorlib.dll is horrible in this regard in a sense that even for an empty app it's pretty big.

    As the poster above me noted, you can look at the source code to see what's available.
     
  4. furroy

    furroy

    Joined:
    Feb 24, 2017
    Posts:
    93
    that's fine i can handle being back in the stone age and writing my own sets and hashtables etc. it's just annoying because it all builds in visual studio fine and then dies when trying to build in unity. is there not a way to tell visual studio to use this stripped down .net ?

    hmm actually it looks like dictionaries are in there but i could not get mine to build in unity and had to write my own to get anything working..
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Are you talking about Unity generated VS project or one outside of Unity? If it's Unity one, means we have a project generation bug...
     
  6. furroy

    furroy

    Joined:
    Feb 24, 2017
    Posts:
    93
    well i didn't make this solution/project, so i'm assuming it was unity that did. o_O also when i try to get the project properties inside VS, the screen just flashes and no dialog appears. perhaps a related issue.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You should file a bug report on that if you can (intellisense not matching what Unity is compiling against).
     
  8. robertg_unity

    robertg_unity

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    32
    Just some clarification... there is currently 2 solution file that can be accessed by users:

    The classic solution file is the same one that Unity has been generating for years, and is accessible through the
    Assets -> Open C# Project
    menu item. This one is associated with the Unity project, hence it links with the full .Net profile, and thus, you can use
    Dictionary
    and everything else.

    Then there's the DOTS solution file, which is completely different. It is accessible through the
    Assets -> Open DOTS C# Project
    menu item. It is the solution file that is actually used when you launch a build of a Tiny project. It links with the Tiny .Net profile and thus will generate proper errors when trying to use unsupported API such as
    Dictionary
    .

    Our story around this feature set is currently not complete. For instance, right now if you click a .cs file, it will open the classic solution file instead of the dots one. Also, you do not get proper error highlighted because it links with the full .Net profile.

    On the other hand, one reason why we keep the ability to have the classic project solution is to allow Unity to compile it in editor, so that when you add a new component from code, we are able to display it in the inspector in the Add Component menu, etc. This also allow users to extend the editor code if they need.
     
  9. furroy

    furroy

    Joined:
    Feb 24, 2017
    Posts:
    93
    aaaah this is the magic sauce i had been missing. i had just been double clicking random scripts to open VS and getting the normal c# and not DOTS.