Skip to content

[Proposal] Move classes and rename to be consistent throughout API #126

@shaggygi

Description

@shaggygi

This proposal is a collection of different modifications and grouped here as there are many breaking changes being proposed. The intent is to review, decide and update (if needed) namespaces, class names and file locations in a consistent structure between the different types of interfaces within System.Device.Gpio API.

This seems to fit with @terrajobst comments during this design review, as well.

Rationale and Usage

Since System.Device.Gpio is in early previews, it seems like the opportune time to review and decide how to structure the core components. This will reduce breaking changes in the future.

Examples

  • GPIO and PWM have abstract classes based on Drivers and are located under the *.Drivers folder. This includes RaspberryPi3Driver, UnixDriver.Linux.cs, etc.. Gpio is not in the file names where I2C/Pwm/SPI are included in the file names.
  • I2C and SPI are based on Devices. However, there are implementations under the *.Drivers folders.

Proposed Changes

The proposed changes are to rename and move files as shown in the folder structure below. To simplify, this attempts to point out only the changes for the files being modified.

GPIO Folder

  • TODO
  1. Drivers and related classes renamed to include "Gpio".
  2. GpioDriver.cs moved to Drivers folder.
Device
  Gpio
    Drivers
      GpioDriver.cs
      HummingBoardGpioDriver.cs
      HummingBoardGpioDriver.Linux.cs
      HummingBoardGpioDriver.Windows.cs
      RaspberryPi3GpioDriver.cs
      RaspberryPi3GpioDriver.Linux.cs
      RaspberryPi3GpioDriver.Windows.cs
      UnixGpioDriver.Linux.cs
      UnixGpioDriver.Windows.cs
      UnixGpioDriverPin.Linux.cs  // Also simplified by removing Device
      Windows10GpioDriver.Linux.cs
      Windows10GpioDriver.Windows.cs
      Windows10GpioDriverPin.Windows.cs
    GpioPinChangeEventHandler.cs
    GpioPinEventTypes.cs
    GpioPinMode.cs
    GpioPinNumberingScheme.cs
    GpioPinValue.cs
    GpioPinValueChangedEventArgs.cs

I2C Folder

  1. Folder renamed from "Drivers" to "Devices".
  2. Namespaces be renamed from "System.Device.I2c.Drivers" to "System.Device.I2c"
  3. I2cDevice.cs moved to Devices folder.

See #118 and #534 for related details

Device
  I2c
    Devices
      I2cDevice.cs
      I2cDevice.Linux.cs
      I2cDevice.Windows.cs
      [other devices here that were not moved or renamed]
    I2cConnectionSettings.cs (didn't change; showing for location purposes)

PWM Folder

  1. PwmDriver.cs moved to Drivers folder.

See #204 for related details

Device
  Pwm
    Drivers
      PwmDriver.cs

SPI Folder

  1. Folder renamed from "Drivers" to "Devices".
  2. Namespaces be renamed from "System.Device.Spi.Drivers" to "System.Device.Spi"
  3. SpiDevice.cs moved to Devices folder.

See #119 and #534 for related details

Device
  Spi
    Devices
      SpiDevice.cs
      SpiDevice.Linux.cs
      SpiDevice.Windows.cs
      [other devices here that were not moved or renamed]
    SpiConnectionSettings.cs (didn't change; showing for location purposes)

Open Questions

  1. It seems a little redundant to have the interface in the file name. For example, GpioPinMode. Is this too redundant knowing it is under the Gpio folder/namespace? It seems like differentiating would be okay, especially when mixing different pin types in code files (e.g. Bindings with a mixture of digital, analog and PWM pins). This would help when adding "usings" or typing entire namespace out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design DiscussionOngoing discussion about design without consensusarea-System.Device.GpioContains types for using general-purpose I/O (GPIO) pinsdocumentationDocumentation bug or enhancement, does not impact product or test code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions