Lapiniot / Lapiniot/Net.MQTT

Make use of C# 15 discriminated union feature for PacketDescriptor record types across entire codebase.

Open
#198 0 comments 0 reactions 1 assignee Claimed by @Lapiniot View on GitHub
area-client-lib area-mqtt-v3 area-mqtt-v5 area-server-lib code-style enhancement experimental feature reliability
Dominant language
C#
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
We currently have several types in our codebase:
- Net.Mqtt.Client.MqttClient5.PacketDescriptor
- Net.Mqtt.Server.Protocol.V5.MqttServerSession5.PacketDescriptor
- Net.Mqtt.PacketDescriptor

These exist primarily for performance and memory efficiency reasons, and represent data block structures to hold MQTT packet data in one of the possible optimized forms, for instance:

- Reference to the packet object instance of `Net.Mqtt.IMqttPacket5` type
- Precomputed packet data for any packet of 4 bytes size
- Precomputed packet data for any packet of 2 bytes size

We basically work with such types as hand-crafted discriminated unions, in fact. Since we now have official language support for discriminated unions in C# 15, we can convert those type to language unions and provide better code expressivenes and clarity for the purpose.

**Describe the solution you'd like**
Just start using C# 'discriminated unions' feature where it makes sense.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.