Skip to content

bugfix - interface is needed for DI#236

Closed
J0EK3R wants to merge 2 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/bugfix-di
Closed

bugfix - interface is needed for DI#236
J0EK3R wants to merge 2 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/bugfix-di

Conversation

@J0EK3R

@J0EK3R J0EK3R commented Jul 5, 2026

Copy link
Copy Markdown

here is the fix for #235
An interface (for MouldKingDeviceManager) is needed for DI to resolve this instance.

@vicocz vicocz added this to the 2026.2 milestone Jul 5, 2026
@vicocz vicocz added the bug Something isn't working label Jul 5, 2026
@vicocz

vicocz commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Root cause: untested changes from #231.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses DI resolution failures for Mould King devices by introducing an interface for MouldKingDeviceManager and switching Mould King device constructors to depend on that interface, allowing Autofac to resolve the dependency given RegisterDeviceManager<T>() registers managers only as IBluetoothLEDeviceManager.

Changes:

  • Added IMouldKingDeviceManager and implemented it in MouldKingDeviceManager.
  • Registered MouldKingDeviceManager as IMouldKingDeviceManager in the vendor DI setup.
  • Updated Mould King device/base constructors to depend on IMouldKingDeviceManager instead of the concrete manager type.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
BrickController2/BrickController2/DeviceManagement/MouldKing/MouldKingDeviceManager.cs Implements IMouldKingDeviceManager so DI can inject it via an interface.
BrickController2/BrickController2/DeviceManagement/MouldKing/MouldKing.cs Registers the manager as IMouldKingDeviceManager for constructor injection.
BrickController2/BrickController2/DeviceManagement/MouldKing/MKBaseNibble.cs Switches dependency from concrete manager to interface.
BrickController2/BrickController2/DeviceManagement/MouldKing/MKBaseByte.cs Switches dependency from concrete manager to interface.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK6.cs Updates constructor to accept IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK5.cs Updates constructor to accept IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK4.cs Updates constructor to accept IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK3_8.cs Updates constructor to accept IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/IMouldKingDeviceManager.cs New interface used for DI-friendly dependency injection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



protected MKBaseByte(string name, string address, byte[] deviceData, IDeviceRepository deviceRepository, IBluetoothLEService bleService, IMKPlatformService mkPlatformService, MouldKingDeviceManager mkDeviceManager,int channelStartOffset, byte[] telegram_Connect, byte[] telegram_Base)
protected MKBaseByte(string name, string address, byte[] deviceData, IDeviceRepository deviceRepository, IBluetoothLEService bleService, IMKPlatformService mkPlatformService, IMouldKingDeviceManager mkDeviceManager,int channelStartOffset, byte[] telegram_Connect, byte[] telegram_Base)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@vicocz

vicocz commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Due ti the failing unit tests, I§v8e used Copilot to fix it as separate PR #237.
Anyway thx for this fix.

@vicocz vicocz closed this Jul 5, 2026
@J0EK3R J0EK3R deleted the merge/vicocz/bugfix-di branch July 6, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants