Search Unity

How to use System.IO.Stream in unity tiny wasm?

Discussion in 'Project Tiny' started by Thaina, Dec 30, 2019.

  1. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    344
    Try to build unity tiny with wasm throw this error

    error CS0234: The type or namespace name 'IO' does not exist in the namespace 'System' (are you missing an assembly reference?)​

    It seem like whole `System.IO` was exclude from wasm build, while it understandable for `File` and other low level API, `Stream` and related reader/writer should be accessible anywhere
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,244
    At the moment, nothing from System.IO is in the Tiny profile. We are taking the approach of including the absolute minimum at first, then trying to see what is necessary to add.

    Can you explain more about the use cases you have for code in System.IO? I'd like to better understand what we might need to add to support your use case.
     
  3. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    344
    It simply because many 3rd party library, especially what related to reading data such as parser, require `Stream` as its dependencies

    `Stream` is very basic component that people relying in their API

    Right now I am making DSL parser library and try to make it work in Tiny. Missing of `Stream` is blocking issue that cannot be avoided
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,244
    Can you provide details about which library you are trying to use? Do you know if it requires only System.IO.Stream (the abstract class), or does it use one of the classes derived from Stream?
     
  5. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    344
    If it was a sample library, I am trying to use this library at first

    https://github.com/grownith/jmespath.upm

    There was some API that use that base `Stream` for receiving any kind of stream. But there was also API that use `StringWriter` and `StringReader` which might use some kind of inherited stream underlyingly. And surerly there might also use `MemoryStream`

    Actually what I expect is, except native or hardware like `File` and `Port`. All other functionality in `System.IO` should be included. Because it was utilized as commonly as collection
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,244
    Thanks for the details. We will take a look at this and see what we can do.
     
    Thaina likes this.
  7. SINePrime

    SINePrime

    Joined:
    Jan 24, 2019
    Posts:
    14
    I'd like to add that Unity's low-level networking API (here) also depends on `System.IO` and `Stream`.

    Seems necessary to add these if Project Tiny is going to support networking.
     
  8. Zadirion

    Zadirion

    Joined:
    Mar 16, 2015
    Posts:
    88
    I think I also needed System.IO.Stream for using the SimpleJSON parser. I went through a lot of parser implementations online, all relying on System.IO.Stream. I ended up implementing System.IO.Stream myself in a rudimentary way, to get those libraries to compile., would have been nice to have it available in Tiny. JSON is essential for browser apps if you're communicating with a server API.
     
unityunity