fix(csharp,python)!: replace MqttLocalId inheritance with composition - #70
Open
ronan-fesselier wants to merge 3 commits into
Open
ronan-fesselier wants to merge 3 commits into
ronan-fesselier wants to merge 3 commits into
Conversation
…LSP violation Adds a failing test per language simulating a real-world function signature that accepts a LocalId parameter (exactly what happens when an MqttLocalId is passed as an argument, since it IS-A LocalId): the returned string is the MQTT format instead of the standard dnv-v2 format.
… inheriting LocalId BREAKING CHANGE: MqttLocalId no longer inherits from LocalId (C#) / is no longer a subclass of LocalId (Python). Code that upcasts MqttLocalId to LocalId, or checks `is LocalId`/`isinstance(x, LocalId)`, will no longer compile (C#) or will start returning False (Python). MqttLocalId publicly inherited from LocalId but produced a fundamentally incompatible ToString()/__str__() format (no leading slash, underscores, no meta/ section), violating Liskov substitution: a caller holding a LocalId reference could silently receive MQTT-topic text instead of the standard dnv-v2 format. MqttLocalId now composes a LocalIdBuilder directly. NamingRule/NAMING_RULE and members unused by the MQTT format (VerboseMode/HasCustomTag/MetadataTags) are reachable via .Builder/.builder instead of being duplicated.
ronan-fesselier
force-pushed
the
fix/mqtt-local-id-lsp-violation
branch
2 times, most recently
from
September 15, 2026 18:51
65e20da to
88e6873
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
MqttLocalIdoverridesToString()/__str__()with a format incompatible withLocalId.Passing one where a
LocalIdis expected silently corrupts any pipeline that round-trips through the string:LocalId.TryParse(mqttLocalId.ToString())fails.The first commit adds failing tests that demonstrate the issue directly.
Replaced inheritance with composition.
This is a breaking change:
MqttLocalIdis no longer assignable toLocalId(C#) / no longerisinstance-true against it (Python).Any project relying on that relationship will need updating.
See attached scripts and outputs for a concrete illustration:
cs_mqtt_lsp_violation.zip
py_mqtt_lsp_violation.zip
I looked at a less invasive fix first by keeping the inheritance (
sealed/newon the C# side to block the unsafe upcast) but dropped it because Python has no static dispatch, sostr()always calls the subclass's method regardless of the declared type, and I did not find a way to make both languages behave the same way.Composition was the only option I found that worked in both.