Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Dec 25, 2024
1 parent 86e18f0 commit a450c37
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static class ConnectionCostsBuilder // LUCENENET specific: CA1052 Static
public static ConnectionCostsWriter Build(string filename)
{
using Stream inputStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
using StreamReader streamReader = new StreamReader(inputStream, Encoding.ASCII); // LUCENENET: CA2000: Use using statement
using StreamReader streamReader = new StreamReader(inputStream, Encoding.ASCII, detectEncodingFromByteOrderMarks: true, bufferSize: 1024, leaveOpen: true); // LUCENENET: CA2000: Use using statement

string line = streamReader.ReadLine();
string[] dimensions = whiteSpaceRegex.Split(line).TrimEnd();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public virtual TokenInfoDictionaryWriter BuildDictionary(IList<string> csvFiles)
{
using Stream inputStream = new FileStream(file, FileMode.Open, FileAccess.Read);
Encoding decoder = Encoding.GetEncoding(encoding);
using TextReader reader = new StreamReader(inputStream, decoder); // LUCENENET: CA2000: Use using statement
using TextReader reader = new StreamReader(inputStream, decoder, detectEncodingFromByteOrderMarks: true, bufferSize: 1024, leaveOpen: true); // LUCENENET: CA2000: Use using statement

string line = null;
while ((line = reader.ReadLine()) != null)
Expand Down Expand Up @@ -159,10 +159,10 @@ public virtual TokenInfoDictionaryWriter BuildDictionary(IList<string> csvFiles)

return dictionary;
}

/// <summary>
/// IPADIC features
///
///
/// 0 - surface
/// 1 - left cost
/// 2 - right cost
Expand All @@ -171,9 +171,9 @@ public virtual TokenInfoDictionaryWriter BuildDictionary(IList<string> csvFiles)
/// 10 - base form
/// 11 - reading
/// 12 - pronounciation
///
///
/// UniDic features
///
///
/// 0 - surface
/// 1 - left cost
/// 2 - right cost
Expand Down
14 changes: 7 additions & 7 deletions src/Lucene.Net.TestFramework/Util/TestUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static ISet<FileSystemInfo> Rm(ISet<FileSystemInfo> unremoved, params Fi

/// <summary>
/// Convenience method unzipping <paramref name="zipFileStream"/> into <paramref name="destDir"/>, cleaning up
/// <paramref name="destDir"/> first.
/// <paramref name="destDir"/> first.
/// </summary>
public static void Unzip(Stream zipFileStream, DirectoryInfo destDir)
{
Expand Down Expand Up @@ -180,7 +180,7 @@ public static CheckIndex.Status CheckIndex(Directory dir, bool crossCheckTermVec
{
if (LuceneTestCase.UseInfoStream)
{
checker.FlushInfoStream();
checker.FlushInfoStream();
Console.WriteLine(bos.ToString());
}
return indexStatus;
Expand All @@ -203,7 +203,7 @@ public static void CheckReader(AtomicReader reader, bool crossCheckTermVectors)
{
// LUCENENET: dispose the StreamWriter and ByteArrayOutputStream when done
using ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
using StreamWriter infoStream = new StreamWriter(bos, Encoding.UTF8);
using StreamWriter infoStream = new StreamWriter(bos, Encoding.UTF8, leaveOpen: true, bufferSize: 1024);

reader.CheckIntegrity();
CheckIndex.Status.FieldNormStatus fieldNormStatus = Index.CheckIndex.TestFieldNorms(reader, infoStream);
Expand Down Expand Up @@ -592,8 +592,8 @@ public static string GetDocValuesFormat(Codec codec, string field)
public static bool FieldSupportsHugeBinaryDocValues(string field)
{
string dvFormat = GetDocValuesFormat(field);
if (dvFormat.Equals("Lucene40", StringComparison.Ordinal)
|| dvFormat.Equals("Lucene42", StringComparison.Ordinal)
if (dvFormat.Equals("Lucene40", StringComparison.Ordinal)
|| dvFormat.Equals("Lucene42", StringComparison.Ordinal)
|| dvFormat.Equals("Memory", StringComparison.Ordinal))
{
return false;
Expand Down Expand Up @@ -869,7 +869,7 @@ public static ICharSequence BytesToCharSequence(BytesRef @ref, Random random)
/// Returns a valid (compiling) <see cref="Regex"/> instance with random stuff inside. Be careful
/// when applying random patterns to longer strings as certain types of patterns
/// may explode into exponential times in backtracking implementations (such as Java's).
/// </summary>
/// </summary>
public static Regex RandomRegex(Random random) // LUCENENET specific - renamed from RandomPattern()
{
return RandomizedTesting.Generators.RandomExtensions.NextRegex(random); // LUCENENET: Moved general random data generation to RandomizedTesting.Generators
Expand Down Expand Up @@ -1060,4 +1060,4 @@ public static string RandomSubString(Random random, int wordLength, bool simple)
'\u3000'
};
}
}
}
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests.Suggest/Suggest/Fst/LargeInputFST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void Main2(string[] args)

// LUCENENET specific - dispose of fileStream and reader when done
using (FileStream fileStream = new FileStream(input.FullName, FileMode.Open))
using (TextReader reader = new StreamReader(fileStream, Encoding.UTF8))
using (TextReader reader = new StreamReader(fileStream, Encoding.UTF8, leaveOpen: true))

Check failure on line 47 in src/Lucene.Net.Tests.Suggest/Suggest/Fst/LargeInputFST.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

There is no argument given that corresponds to the required parameter 'detectEncodingFromByteOrderMarks' of 'StreamReader.StreamReader(Stream, Encoding, bool, int, bool)'

Check failure on line 47 in src/Lucene.Net.Tests.Suggest/Suggest/Fst/LargeInputFST.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

There is no argument given that corresponds to the required parameter 'detectEncodingFromByteOrderMarks' of 'StreamReader.StreamReader(Stream, Encoding, bool, int, bool)'

Check failure on line 47 in src/Lucene.Net.Tests.Suggest/Suggest/Fst/LargeInputFST.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

There is no argument given that corresponds to the required parameter 'detectEncodingFromByteOrderMarks' of 'StreamReader.StreamReader(Stream, Encoding, bool, int, bool)'

Check failure on line 47 in src/Lucene.Net.Tests.Suggest/Suggest/Fst/LargeInputFST.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

There is no argument given that corresponds to the required parameter 'detectEncodingFromByteOrderMarks' of 'StreamReader.StreamReader(Stream, Encoding, bool, int, bool)'
{
BytesRef scratch = new BytesRef();
string line;
Expand Down
5 changes: 3 additions & 2 deletions src/Lucene.Net/Store/LockStressTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Console = Lucene.Net.Util.SystemConsole;

Expand Down Expand Up @@ -144,8 +145,8 @@ public static void Main(string[] args)
socket.Connect(verifierHost, verifierPort);

using Stream stream = new NetworkStream(socket);
using BinaryReader intReader = new BinaryReader(stream);
using BinaryWriter intWriter = new BinaryWriter(stream);
using BinaryReader intReader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true);
using BinaryWriter intWriter = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true);

intWriter.Write(myID);
stream.Flush();
Expand Down
5 changes: 3 additions & 2 deletions src/Lucene.Net/Store/LockVerifyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Console = Lucene.Net.Util.SystemConsole;

Expand Down Expand Up @@ -134,8 +135,8 @@ public ThreadAnonymousClass(object localLock, int[] lockedID, CountdownEvent sta
public override void Run()
{
using Stream stream = new NetworkStream(cs);
using BinaryReader intReader = new BinaryReader(stream);
using BinaryWriter intWriter = new BinaryWriter(stream);
using BinaryReader intReader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true);
using BinaryWriter intWriter = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true);
try
{
int id = intReader.ReadInt32();
Expand Down

0 comments on commit a450c37

Please sign in to comment.