lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] NightOwl888 commented on a change in pull request #385: Adding overloads to Document for GetValues and Get
Date Tue, 01 Dec 2020 15:14:50 GMT

NightOwl888 commented on a change in pull request #385:
URL: https://github.com/apache/lucenenet/pull/385#discussion_r533460795



##########
File path: src/Lucene.Net/Document/Document.cs
##########
@@ -273,13 +442,37 @@ public string Get(string name)
         /// <summary>
         /// Prints the fields of a document for human consumption. </summary>
         public override string ToString()
+        {
+            return (this as IFormattable).ToString(null, J2N.Text.StringFormatter.CurrentCulture);
+        }
+
+        /// <summary>
+        /// Prints the fields of a document for human consumption. 
+        /// </summary>
+        /// <param name="provider">An object that supplies culture-specific formatting
information. This parameter has no effect if this field is non-numeric.</param>
+        // LUCENENET specific - method added for better .NET compatibility
+        public string ToString(IFormatProvider provider)
+        {
+            return (this as IFormattable).ToString(null, provider);
+        }
+
+        /// <summary>
+        /// Prints the fields of a document for human consumption. 
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. This parameter
has no effect if this field is non-numeric.</param>
+        /// <param name="provider">An object that supplies culture-specific formatting
information. This parameter has no effect if this field is non-numeric.</param>
+        // LUCENENET specific - method added for better .NET compatibility
+        string IFormattable.ToString(string format, IFormatProvider provider)

Review comment:
       Please add a `private ToString(string format, IFormatProvider provider)` overload and
cascade the call from this method to the private one. This will allow the other overloads
to call the private method directly with no cast.
   
   ```c#
   private ToString(string format, IFormatProvider provider)
   {
      // implementation...
   }
   
   string IFormattable.ToString(string format, IFormatProvider provider)
   {
       return ToString(format, provider);
   }
   ```

##########
File path: src/Lucene.Net/Document/Document.cs
##########
@@ -273,13 +442,37 @@ public string Get(string name)
         /// <summary>
         /// Prints the fields of a document for human consumption. </summary>
         public override string ToString()
+        {
+            return (this as IFormattable).ToString(null, J2N.Text.StringFormatter.CurrentCulture);

Review comment:
       Please call the private `ToString(string format, IFormatProvider provider)` overload
I mentioned in another comment by removing the cast (`(this as IFormattable).`)

##########
File path: src/Lucene.Net/Document/Field.cs
##########
@@ -819,6 +819,37 @@ public virtual float Boost
         /// <summary>
         /// Prints a <see cref="Field"/> for human consumption. </summary>
         public override string ToString()
+        {
+            return ToString(null, J2N.Text.StringFormatter.CurrentCulture);
+        }
+
+        /// <summary>
+        /// Prints a <see cref="Field"/> for human consumption. 
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. This parameter
has no effect if this field is non-numeric.</param>
+        // LUCENENET specific - method added for better .NET compatibility
+        public virtual string ToString(string format)
+        {
+            return ToString(null, J2N.Text.StringFormatter.CurrentCulture);
+        }
+
+        /// <summary>
+        /// Prints a <see cref="Field"/> for human consumption.
+        /// </summary>
+        /// <param name="provider">An object that supplies culture-specific formatting
information. This parameter has no effect if this field is non-numeric.</param>
+        // LUCENENET specific - method added for better .NET compatibility
+        public virtual string ToString(IFormatProvider provider)
+        {
+            return ToString(null, J2N.Text.StringFormatter.CurrentCulture);

Review comment:
       Please pass the `provider` parameter through.

##########
File path: src/Lucene.Net/Document/Document.cs
##########
@@ -273,13 +442,37 @@ public string Get(string name)
         /// <summary>
         /// Prints the fields of a document for human consumption. </summary>
         public override string ToString()
+        {
+            return (this as IFormattable).ToString(null, J2N.Text.StringFormatter.CurrentCulture);
+        }
+
+        /// <summary>
+        /// Prints the fields of a document for human consumption. 
+        /// </summary>
+        /// <param name="provider">An object that supplies culture-specific formatting
information. This parameter has no effect if this field is non-numeric.</param>
+        // LUCENENET specific - method added for better .NET compatibility
+        public string ToString(IFormatProvider provider)
+        {
+            return (this as IFormattable).ToString(null, provider);

Review comment:
       Please call the private `ToString(string format, IFormatProvider provider)` overload
I mentioned in another comment by removing the cast (`(this as IFormattable).`)

##########
File path: src/Lucene.Net/Document/Field.cs
##########
@@ -819,6 +819,37 @@ public virtual float Boost
         /// <summary>
         /// Prints a <see cref="Field"/> for human consumption. </summary>
         public override string ToString()
+        {
+            return ToString(null, J2N.Text.StringFormatter.CurrentCulture);
+        }
+
+        /// <summary>
+        /// Prints a <see cref="Field"/> for human consumption. 
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. This parameter
has no effect if this field is non-numeric.</param>
+        // LUCENENET specific - method added for better .NET compatibility
+        public virtual string ToString(string format)
+        {
+            return ToString(null, J2N.Text.StringFormatter.CurrentCulture);

Review comment:
       Please pass the `format` parameter through.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message