-
Notifications
You must be signed in to change notification settings - Fork 85
Temp to dev #1371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temp to dev #1371
Conversation
- fixed multiple enumeration exception
generic sink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request modernizes logging practices across the bridge and routing infrastructure by migrating from Debug.LogMessage to strongly-typed extension logging methods. It also adds UDP EISC client support, improves XML documentation, and refactors several messenger classes to use strongly-typed message objects. The changes focus on improving code maintainability, observability, and consistency.
Key Changes:
- Migrated logging from
Debug.LogMessageto structured logging extension methods (this.LogDebug,this.LogWarning, etc.) throughoutBridgeBase.csand improved exception logging with stack traces - Added UDP EISC client support in
EiscApiAdvancedFactorywith new type nameseiscapiadvudpandeiscapiadvancedudp - Refactored
DeviceVolumeMessengerto use strongly-typed message classes instead of anonymous objects, and implementedICurrentSourcesinterface inGenericSink
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| DeviceVolumeMessenger.cs | Refactored to use strongly-typed VolumeStateMessage and Volume classes instead of anonymous objects for better type safety |
| CurrentSourcesMessenger.cs | Added dictionary copying with ToDictionary to prevent enumeration issues during event handling |
| GenericSink.cs | Implemented ICurrentSources interface with SetCurrentSource method to track current audio/video sources |
| Extensions.cs | Minor formatting improvements and enhanced log messages to include destination key information |
| BridgeBase.cs | Comprehensive logging migration to extension methods, improved XML documentation, added UDP EISC support, and fixed bugs in ExecuteJoinAction method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| foreach (eRoutingSignalType type in Enum.GetValues(typeof(eRoutingSignalType))) | ||
| { | ||
| var flagValue = Convert.ToInt32(type); | ||
| // Skip if flagValue is 0 or not a power of two (i.e., not a single-bit flag). | ||
| // (flagValue & (flagValue - 1)) != 0 checks if more than one bit is set. | ||
| if (flagValue == 0 || (flagValue & (flagValue - 1)) != 0) | ||
| { | ||
| this.LogDebug("Skipping {type}", type); | ||
| continue; | ||
| } | ||
|
|
||
| this.LogDebug("setting {type}", type); | ||
|
|
||
| if (signalType.HasFlag(type)) | ||
| { | ||
| UpdateCurrentSources(type, sourceListKey, sourceListItem); | ||
| } | ||
| } |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition (flagValue & (flagValue - 1)) != 0 correctly identifies composite flags, but the log message says "Skipping" when these should be skipped. However, the real issue is that this enumeration approach is inefficient. The code iterates through all enum values including composite flags just to filter them out. Consider using only the specific flags you need (e.g., Audio, Video) rather than enumerating all possible enum values.
| this.LogDebug("Skipping {type}", type); | ||
| continue; | ||
| } | ||
|
|
||
| this.LogDebug("setting {type}", type); | ||
|
|
||
| if (signalType.HasFlag(type)) | ||
| { |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debug log statements at lines 62 and 66 will be executed for every enum value checked, which could generate excessive log noise. These debug logs should either be removed or only logged when meaningful work is being done (i.e., when actually updating sources).
| this.LogDebug("Skipping {type}", type); | |
| continue; | |
| } | |
| this.LogDebug("setting {type}", type); | |
| if (signalType.HasFlag(type)) | |
| { | |
| continue; | |
| } | |
| if (signalType.HasFlag(type)) | |
| { | |
| this.LogDebug("setting {type}", type); |
| eisc = new EthernetIntersystemCommunications(controlProperties.IpIdInt, | ||
| controlProperties.TcpSshProperties.Address, Global.ControlSystem); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UDP EISC client creation uses EthernetIntersystemCommunications constructor without specifying the transport type. This constructor signature typically creates a TCP client by default. For UDP support, you likely need to use a different constructor overload or specify the transport protocol explicitly to ensure UDP is actually used instead of TCP.
| eisc = new EthernetIntersystemCommunications(controlProperties.IpIdInt, | |
| controlProperties.TcpSshProperties.Address, Global.ControlSystem); | |
| eisc = new EthernetIntersystemCommunications( | |
| controlProperties.IpIdInt, | |
| controlProperties.TcpSshProperties.Address, | |
| eDeviceEthernetProtocols.UDP, | |
| Global.ControlSystem); |
| // otherwise, audioVideo needs to be handled as two steps. | ||
|
|
||
| Debug.LogMessage(LogEventLevel.Debug, "Attempting to build source route from {sourceKey} of type {type}", destination, source.Key); | ||
| Debug.LogMessage(LogEventLevel.Debug, "Attempting to build source route from {destinationKey} to {sourceKey} of type {type}", destination, source.Key, signalType); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log message is missing a parameter placeholder. The message format includes '{destinationKey}' but the Debug.LogMessage call only provides two arguments after the message: destination (the object) and source.Key. The destination key should be passed as destination.Key to match the placeholder.
| Debug.LogMessage(LogEventLevel.Debug, "Attempting to build source route from {destinationKey} to {sourceKey} of type {type}", destination, source.Key, signalType); | |
| Debug.LogMessage(LogEventLevel.Debug, "Attempting to build source route from {destinationKey} to {sourceKey} of type {type}", destination, destination.Key, source.Key, signalType); |
| // need to copy the dictionaries to avoid enumeration issues | ||
| var currentSourceKeys = sourceDevice.CurrentSourceKeys.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); | ||
| var currentSources = sourceDevice.CurrentSources.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "need to copy the dictionaries to avoid enumeration issues" but the code uses ToDictionary which creates a shallow copy. If the dictionary values themselves are mutable objects, this won't prevent modification issues during enumeration. Consider whether a deep copy is needed, or if locking the dictionaries during access would be more appropriate.
| if (device is IBasicVolumeWithFeedbackAdvanced volumeAdvanced) | ||
| { | ||
| message.Volume.RawValue = volumeAdvanced.RawVolumeLevel.ToString(); | ||
| message.Volume.Units = volumeAdvanced.Units; | ||
| } |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable check here accesses device instead of feedback. The event handler receives feedback as a parameter and should check if feedback implements IBasicVolumeWithFeedbackAdvanced, not the outer device variable. This could result in incorrect behavior if the feedback object differs from the device.
This pull request makes several improvements to the
BridgeBase.csandExtensions.csfiles in thePepperDash.Essentials.Coreproject. The main focus is on refactoring and modernizing logging practices, improving code clarity and documentation, and adding support for UDP EISC clients in the bridge factory. The changes also include minor code cleanups and improved error handling.Key changes include:
Logging Improvements and Refactoring:
Debug.LogMessagewith strongly-typed extension logging methods such asthis.LogDebug,this.LogWarning,this.LogVerbose,this.LogInformation, andthis.LogErrorfor more consistent and structured logging throughoutBridgeBase.cs. [1] [2] [3] [4] [5] [6] [7]ExecuteJoinActionandEisc_SigChange.Code and Documentation Enhancements:
EiscApiAdvancedandEiscApiAdvancedFactory. [1] [2] [3]BridgeApibase class as[Obsolete]to indicate its planned removal in a future major version.Feature Additions:
eiscapiadvudp,eiscapiadvancedudp) in theEiscApiAdvancedFactoryto allow creation of EISC clients over UDP.General Code Cleanup:
Minor Improvements in Routing Extensions:
These changes collectively improve maintainability, observability, and clarity of the bridge and routing infrastructure.
Logging improvements and refactoring:
Debug.LogMessagewith strongly-typed logging extension methods across bridge classes for better log structure and consistency. [1] [2] [3] [4] [5] [6] [7]Code and documentation enhancements:
BridgeApias obsolete. [1] [2] [3] [4]Feature additions:
EiscApiAdvancedFactorywith new type names.General code cleanup:
Routing extensions improvements: