-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User/lemccomb/fileread #94
Conversation
lemccomb
commented
Jul 11, 2024
•
edited
Loading
edited
- Makes CoseSignTool and CoseHandler more resilient to sign and validate requests on files that may not have been fully written yet or fully disposed.
- Forces full dispose of streams at the end of sign and validate operations.
- Implements a simple logger to write to console, trace, or other target.
// Act | ||
// Start the file writes then start the loading tasks before the writes complete. | ||
// Both tasks should wait for the writes to complete before loading the content. | ||
Task t1 = Task.Run(() => WriteTextFileSlowly(outPath1, text)); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning test
byte[] bytes = f1.GetBytesResilient(); | ||
bytes.Length.Should().BeGreaterThan(38); | ||
|
||
var t2 = Task.Run(() => WriteTextFileSlowly(outPath2, text)); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning test
|
||
// Act | ||
// Start the file write. The loading task should time out before the first character is written. | ||
var writeTask1 = Task.Run(() => WriteTextFileWithDelay(outPath, text, 10)); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning test
catch (Exception ex) | ||
{ | ||
// Assert | ||
ex.Should().BeOfType<IOException>("The file was still empty."); | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause Note test
{ | ||
// Arrange | ||
string text = "This is some text being written slowly."; // 39 chars | ||
byte[] textBytes = Encoding.UTF8.GetBytes(text); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning test
(DateTime.Now - startTime).TotalSeconds >= maxWaitTimeInSeconds; | ||
|
||
private static double SecondsSince(DateTime startTime) | ||
=> Math.Round((double)(DateTime.Now - startTime).TotalSeconds, 2); |
Check warning
Code scanning / CodeQL
Cast to same type Warning
byte[] bytes = Encoding.UTF8.GetBytes("This is some text that will be written to a file eventually."); | ||
FileInfo f = new(Path.GetTempFileName()); | ||
f.Refresh(); | ||
var cts = new CancellationTokenSource(); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning test
…/CoseSignTool into user/lemccomb/fileread