You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2020/12/01 15:14:50 UTC

[GitHub] [lucenenet] NightOwl888 commented on a change in pull request #385: Adding overloads to Document for GetValues and Get

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