public string FormatMessage()

in TeamCity.ServiceMessages/Write/ServiceMessageFormatter.cs [102:141]


        public string FormatMessage(string messageName, IEnumerable<ServiceMessageProperty> properties)
        {
            if (messageName == null) throw new ArgumentNullException(nameof(messageName));
            if (properties == null) throw new ArgumentNullException(nameof(properties));
            if (messageName == null) throw new ArgumentNullException(nameof(messageName));
            if (string.IsNullOrEmpty(messageName)) throw new ArgumentException("The message name must not be empty", nameof(messageName));
            if (properties == null) throw new ArgumentNullException(nameof(properties));

            if (ServiceMessageReplacements.Encode(messageName) != messageName)
            {
                throw new ArgumentException("The message name contains illegal characters", nameof(messageName));
            }

            if (ServiceMessageReplacements.Encode(messageName) != messageName)
            {
                throw new ArgumentException("Message name contains illegal characters", nameof(messageName));
            }

            var sb = new StringBuilder();
            sb.Append(ServiceMessageConstants.ServiceMessageOpen);
            sb.Append(messageName);

            foreach (var property in properties)
            {
                if (string.IsNullOrEmpty(property.Key))
                {
                    throw new InvalidOperationException("The property name must not be empty");
                }

                if (ServiceMessageReplacements.Encode(property.Key) != property.Key)
                {
                    throw new InvalidOperationException($"The property name �{property.Key}� contains illegal characters");
                }

                sb.AppendFormat(" {0}='{1}'", property.Key, ServiceMessageReplacements.Encode(property.Value));
            }

            sb.Append(ServiceMessageConstants.ServiceMessageClose);
            return sb.ToString();
        }