lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [lucenenet] 06/11: Lucene.Net.Store.Directory: Added ListAllFormatter struct used to defer building a string.Format() parameter when using Debugging.Assert<T0>(bool, string, T0) overloads
Date Tue, 03 Nov 2020 21:24:18 GMT
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit db10a7d7ce43302b54387532ef83e2e73d8bad29
Author: Shad Storhaug <shad@shadstorhaug.com>
AuthorDate: Tue Nov 3 10:14:06 2020 +0700

    Lucene.Net.Store.Directory: Added ListAllFormatter struct used to defer building a string.Format()
parameter when using Debugging.Assert<T0>(bool, string, T0) overloads
---
 src/Lucene.Net/Store/Directory.cs | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/Lucene.Net/Store/Directory.cs b/src/Lucene.Net/Store/Directory.cs
index 40ea2c7..b243381 100644
--- a/src/Lucene.Net/Store/Directory.cs
+++ b/src/Lucene.Net/Store/Directory.cs
@@ -1,3 +1,4 @@
+using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -392,5 +393,23 @@ namespace Lucene.Net.Store
 
             public override long Length => length;
         }
+
+        // LUCENENET specific - formatter to defer building the string of directory contents
in string.Format().
+        // This struct is meant to wrap a directory parameter when passed as a string.Format()
argument.
+        internal struct ListAllFormatter // For assert/test/debug
+        {
+#pragma warning disable IDE0044 // Add readonly modifier
+            private Directory directory;
+#pragma warning restore IDE0044 // Add readonly modifier
+            public ListAllFormatter(Directory directory)
+            {
+                this.directory = directory ?? throw new ArgumentNullException(nameof(directory));
+            }
+
+            public override string ToString()
+            {
+                return Arrays.ToString(directory.ListAll());
+            }
+        }
     }
 }
\ No newline at end of file


Mime
View raw message