Skip to content

Commit 2f1439f

Browse files
claudeDavidVeksler
authored andcommitted
Fix: Correct Result type instantiation and stream read handling
- Fix ConfigLoader.cs: Use 'new' keyword for Result<T> record instantiation - Fix FileUtilities.cs: Handle partial reads properly to address CA2022 warning
1 parent 6d9a8a9 commit 2f1439f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Services/ConfigLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ private static Result<string> ReadConfigFile(string fileName)
3535
try
3636
{
3737
var json = File.Exists(fileName) ? File.ReadAllText(fileName) : "{}";
38-
return Result<string>.Success(json);
38+
return new Result<string>.Success(json);
3939
}
4040
catch (Exception ex)
4141
{
42-
return Result<string>.Error(ex.Message);
42+
return new Result<string>.Error(ex.Message);
4343
}
4444
}
4545

Utils/FileUtilities.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ private static bool HasUtf8Bom(FileStream stream)
5858
}
5959

6060
var bom = new byte[Utf8Bom.Length];
61-
stream.Read(bom, 0, Utf8Bom.Length);
61+
var bytesRead = stream.Read(bom, 0, Utf8Bom.Length);
6262
stream.Position = 0;
6363

64-
return bom.SequenceEqual(Utf8Bom);
64+
return bytesRead == Utf8Bom.Length && bom.SequenceEqual(Utf8Bom);
6565
}
6666

6767
/// <summary>

0 commit comments

Comments
 (0)