This is an automated email from the ASF dual-hosted git repository.

aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git

commit 4c135bb2e6b1617c17b580c7efdff3e22019674e
Author: Aaron Ai <[email protected]>
AuthorDate: Thu Mar 2 18:56:39 2023 +0800

    Override message ToString method
---
 csharp/rocketmq-client-csharp/Message.cs     | 15 +++++++++++++--
 csharp/rocketmq-client-csharp/MessageView.cs |  9 ++++-----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/csharp/rocketmq-client-csharp/Message.cs 
b/csharp/rocketmq-client-csharp/Message.cs
index 2430bbbd..32c4352c 100644
--- a/csharp/rocketmq-client-csharp/Message.cs
+++ b/csharp/rocketmq-client-csharp/Message.cs
@@ -17,13 +17,15 @@
 
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text.RegularExpressions;
 
 namespace Org.Apache.Rocketmq
 {
     public class Message
     {
-        internal static readonly Regex TopicRegex = new("^[%a-zA-Z0-9_-]+$"); 
+        internal static readonly Regex TopicRegex = new("^[%a-zA-Z0-9_-]+$");
+
         private Message(string topic, byte[] body, string tag, List<string> 
keys,
             Dictionary<string, string> properties, DateTime? 
deliveryTimestamp, string messageGroup)
         {
@@ -60,6 +62,14 @@ namespace Org.Apache.Rocketmq
 
         public string MessageGroup { get; }
 
+        public override string ToString()
+        {
+            return
+                $"{nameof(Topic)}: {Topic}, {nameof(Tag)}: {Tag}, 
{nameof(Keys)}: {string.Join(", ", Keys)}, {nameof(Properties)}: " +
+                $"{string.Join(", ", Properties.Select(kvp => 
kvp.ToString()))}, {nameof(DeliveryTimestamp)}: {DeliveryTimestamp}, 
{nameof(MessageGroup)}: " +
+                $"{MessageGroup}";
+        }
+
         public class Builder
         {
             private string _topic;
@@ -73,7 +83,8 @@ namespace Org.Apache.Rocketmq
             public Builder SetTopic(string topic)
             {
                 Preconditions.CheckArgument(null != topic, "topic should not 
be null");
-                Preconditions.CheckArgument(topic != null && 
TopicRegex.Match(topic).Success, $"topic does not match the regex 
{TopicRegex}");
+                Preconditions.CheckArgument(topic != null && 
TopicRegex.Match(topic).Success,
+                    $"topic does not match the regex {TopicRegex}");
                 _topic = topic;
                 return this;
             }
diff --git a/csharp/rocketmq-client-csharp/MessageView.cs 
b/csharp/rocketmq-client-csharp/MessageView.cs
index 2b5529ea..57a10619 100644
--- a/csharp/rocketmq-client-csharp/MessageView.cs
+++ b/csharp/rocketmq-client-csharp/MessageView.cs
@@ -179,11 +179,10 @@ namespace Org.Apache.Rocketmq
 
         public override string ToString()
         {
-            return
-                $"{nameof(MessageId)}: {MessageId}, {nameof(Topic)}: {Topic}, 
{nameof(Tag)}: {Tag}," +
-                $" {nameof(MessageGroup)}: {MessageGroup}, 
{nameof(DeliveryTimestamp)}: {DeliveryTimestamp}," +
-                $" {nameof(Keys)}: {Keys}, {nameof(Properties)}: {Properties}, 
{nameof(BornHost)}: {BornHost}, " +
-                $"{nameof(BornTime)}: {BornTime}, {nameof(DeliveryAttempt)}: 
{DeliveryAttempt}";
+            return $"{nameof(MessageId)}: {MessageId}, {nameof(Topic)}: 
{Topic}, {nameof(Tag)}: {Tag}," +
+                   $" {nameof(MessageGroup)}: {MessageGroup}, 
{nameof(DeliveryTimestamp)}: {DeliveryTimestamp}," +
+                   $" {nameof(Keys)}: {string.Join(", ", Keys)}, 
{nameof(Properties)}: {string.Join(", ", Properties.Select(kvp => 
kvp.ToString()))}, {nameof(BornHost)}: {BornHost}, " +
+                   $"{nameof(BornTime)}: {BornTime}, 
{nameof(DeliveryAttempt)}: {DeliveryAttempt}";
         }
     }
 }
\ No newline at end of file

Reply via email to