Skip to content

Consider removing implementations for unused events in Connection #515

@antiduh

Description

@antiduh

Split from #512 .

The Connection class exposes events that it never fires - RecoverySucceeded and ConnectionRecoveryError. It seems these events are defined in Connection because they're part of the IConnection interface, which seems to define these events on behalf of AutorecoveringConnection.

As an example, here are all of the callsites to the RecoverySucceeded event and its backing field:

        public event EventHandler<EventArgs> RecoverySucceeded
        {
            add
            {
                lock (m_eventLock)
                {
                    m_recoverySucceeded += value;
                }
            }
            remove
            {
                lock (m_eventLock)
                {
                    m_recoverySucceeded -= value;
                }
            }
        }


        private void Dispose(bool disposing)
        {
           ...
                    m_recoverySucceeded = null;
           ...
         }

Since the events are never fired from within Connection, but they need to be implemented by Connection to meet the IConnection interface, the events should be replaced with empty add-remove handlers, and all backing fields should be removed.

        public event EventHandler<EventArgs> RecoverySucceeded
        {
            add { }
            remove { }
        }

        public event EventHandler<ConnectionRecoveryErrorEventArgs> ConnectionRecoveryError
        {
            add { }
            remove {}
        }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions