Skip to content
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

Refactor ConnectionInfo in C# #3187

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

bernardnormier
Copy link
Member

This is a companion PR for #3185 - it simplifies ConnectionInfo by switching to readonly fields + protected or internal constructors.

public string connectionId = "";
public readonly string connectionId;

protected ConnectionInfo(ConnectionInfo underlying)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just like for EndpointInfo: when underlying is not null, we use it to set incoming/adapterName/connectionId.

Note that logically:

  • incoming == false => connectionId may be set and adapterName must be empty
  • incoming == true => connectionId is empty and adapterName should be (must be?) set

However, we don't enforce it in this code.

{
_info = _transceiver.getInfo();
}
catch (LocalException)
Copy link
Member Author

Choose a reason for hiding this comment

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

I remove this catch LocalException and create a "default" ConnectionInfo. I don't understand the logic and it's not exercised by the tests.

Copy link
Member

Choose a reason for hiding this comment

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

This was introduced here c4035e1

Unfortunately there isn't a linked issue to explain when it throws.

info.remotePort = Network.endpointPort(_peerAddr);
}

if (_state == StateNotConnected) // TODO: eliminate all these states
Copy link
Member Author

Choose a reason for hiding this comment

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

See #3186. Once fixed, we'll keep only the first branch.

connectionId = underlying.connectionId;
}

protected ConnectionInfo(bool incoming, string adapterName, string connectionId)
Copy link
Member Author

Choose a reason for hiding this comment

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

Conversely, when underlying is null, we must provide incoming/adapterName/connectionId to the constructor.

}

internal UDPConnectionInfo(bool incoming, string adapterName, string connectionId)
: this(incoming, adapterName, connectionId, "", -1, "", -1, "", -1, 0, 0)
Copy link
Member

Choose a reason for hiding this comment

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

I would use labels for the "" -1, ... parameters

{
_info = _transceiver.getInfo();
}
catch (LocalException)
Copy link
Member

Choose a reason for hiding this comment

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

This was introduced here c4035e1

Unfortunately there isn't a linked issue to explain when it throws.

@bernardnormier bernardnormier merged commit d9f2ba4 into zeroc-ice:main Nov 26, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants