Repository: microsoft/garnet
File: libs/cluster/Server/ClusterConfig.cs (C#)

Code before:
        }

        /// <summary>
        /// Get endpoint of node from node-id.
        /// </summary>
        /// <param name="nodeid">Node-id.</param>
        /// <returns>Pair of (string,integer) representing endpoint.</returns>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IPEndPoint GetEndpointFromNodeId(string nodeid)
        {
            var workerId = GetWorkerIdFromNodeId(nodeid);
            return new(IPAddress.Parse(workers[workerId].Address), workers[workerId].Port);
        }
        #endregion

        /// <summary>
        /// Get formatted (using CLUSTER NODES format) cluster info.
        /// </summary>
        /// <returns>Formatted string.</returns>
        public string GetClusterInfo(ClusterProvider clusterProvider)
        {
            var nodesStringBuilder = new StringBuilder();
            for (ushort i = 1; i <= NumWorkers; i++)
            {
                var info = default(ConnectionInfo);
                _ = clusterProvider?.clusterManager?.GetConnectionInfo(workers[i].Nodeid, out info);
                nodesStringBuilder.Append(GetNodeInfo(i, info));
            }
            return nodesStringBuilder.ToString();
        }

        /// <summary>
        /// Get formatted (using CLUSTER NODES format) worker info.
        /// </summary>
        /// <param name="workerId">Offset of worker in the worker list.</param>
        /// <param name="info">Connection information for the corresponding worker.</param>
        /// <returns>Formatted string.</returns>
        public string GetNodeInfo(ushort workerId, ConnectionInfo info)
        {
            //<id>
            //<ip:port@cport[,hostname[,auxiliary_field=value]*]>
            //<flags>
            //<primary>
            //<ping-sent>
            //<pong-recv>
            //<config-epoch>
            //<link-state>
            //<slot> <slot> ... <slot>
            var nodeInfoStringBuilder = new StringBuilder();
            return nodeInfoStringBuilder
                .Append(workers[workerId].Nodeid).Append(" ")

Review comment (suggestion):
Send this StringBuilder to `private void GetNodeInfo(ushort workerId, ConnectionInfo info, StringBuilder sb)` so it can append to it.

And implement the `public string GetNodeInfo(ushort workerId, ConnectionInfo info)` using the common method, as something like:
```
var sb = new StringBuilder()
GetNodeInfo(..., sb);
return sb.ToString();
```

Code after:
        }

        /// <summary>
        /// Get endpoint of node from node-id.
        /// </summary>
        /// <param name="nodeid">Node-id.</param>
        /// <returns>Pair of (string,integer) representing endpoint.</returns>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public IPEndPoint GetEndpointFromNodeId(string nodeid)
        {
            var workerId = GetWorkerIdFromNodeId(nodeid);
            return new(IPAddress.Parse(workers[workerId].Address), workers[workerId].Port);
        }
        #endregion

        /// <summary>
        /// Get formatted (using CLUSTER NODES format) cluster info.
        /// </summary>
        /// <returns>Formatted string.</returns>
        public string GetClusterInfo(ClusterProvider clusterProvider)
        {
            var nodesStringBuilder = new StringBuilder();
            for (ushort i = 1; i <= NumWorkers; i++)
            {
                var info = default(ConnectionInfo);
                _ = clusterProvider?.clusterManager?.GetConnectionInfo(workers[i].Nodeid, out info);
                GetNodeInfo(i, info, nodesStringBuilder);
            }
            return nodesStringBuilder.ToString();
        }

        /// <summary>
        /// Get formatted (using CLUSTER NODES format) worker info.
        /// </summary>
        /// <param name="workerId">Offset of worker in the worker list.</param>
        /// <param name="info">Connection information for the corresponding worker.</param>
        /// <returns>Formatted string.</returns>
        public string GetNodeInfo(ushort workerId, ConnectionInfo info)
        {
            //<id>
            //<ip:port@cport[,hostname[,auxiliary_field=value]*]>
            //<flags>
            //<primary>
            //<ping-sent>
            //<pong-recv>
            //<config-epoch>
            //<link-state>
            //<slot> <slot> ... <slot>
            var nodeInfoStringBuilder = new StringBuilder();
            GetNodeInfo(workerId, info, nodeInfoStringBuilder);
            return nodeInfoStringBuilder.ToString();