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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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:
    1,157
    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:
    6,920
    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:
    1,157
    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:
    6,920
    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:
    1,157
    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:
    6,920
    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:
    54
    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. EdRowlett-Barbu

    EdRowlett-Barbu

    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.
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Note that System.IO.Stream will be in the base class library for the 0.26 release of Project Tiny.
     
    tonialatalo, newguy123 and Thaina like this.
  10. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,157
    Really great news
     
  11. JC-Cimetiere

    JC-Cimetiere

    Unity Technologies

    Joined:
    May 8, 2014
    Posts:
    123
    We plan to have a lightweight JSON implementation for basic parse/write. Planned for this summer.
    It will come after the HTTP Client work completed. We are making good progress there and should be able to share a more precise landing schedule soon.
    Thanks for the feedback.