Giter Site home page Giter Site logo

Comments (2)

joperezr avatar joperezr commented on June 2, 2024

If you see the structure of our package, we basically have three dlls on it:
ref/netstandard2.0/
System.Device.Gpio.dll (<-- This assembly is the reference assembly people will compile against when using our package)
runtimes/linux/lib/netstandard2.0/
System.Devices.Gpio.dll (<-- This assembly will be used when running the app on linux)
runtimes/win/lib/netstandard2.0/
System.Devices.Gpio.dll (<-- This assembly will be used when running the app on Windows)

If we wanted to do what you point out above (making the decision at runtime of which platform to use) we would have a few problems over the current design:

  • Assemblies would become larger and larger with the support of new platforms
  • Runtime will be a bit slower as we would have to do extra checks to see which codepath to use.
  • Assemblies might end up having extra dependencies that won't be required in a given platform (for example, we don't want the linux implementation of our library to depend on .winmd files)
  • .cs files will start to get bigger and bigger with new platforms and are less readable.

For these reasons, we opted to instead produce two different implementations, one for Linux and one for Windows. Our repo infrastructure is set such that if a file is named *.Linux.cs it won't be compiled for the Windows implementation and vice-versa for the *.Windows.cs files. We still need to have a PlatformNotSupported version of the drivers that are platform specific, because people will compile against the reference assembly which will have those drivers as existing, so we don't want to throw a "Type not found" exception at runtime when using a windows driver on Linux, and instead we just want to say that this driver is not supported on the platform.

Does that make sense?

from iot.

shaggygi avatar shaggygi commented on June 2, 2024

Yes, that makes sense. Thank you. I originally created this when tinkering around with #110.

from iot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.