-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* now will dispose instances of
ByteArrayContent
& `MultipartFormDa…
…taContent` that inherits `HttpContent` @ `ClientRequester.PostProtoBuf()` * implement `IDisposable` pattern to dispose `System.Timers.Timer` @ ClientRequesterTcs.cs & WithLogTrace.cs * fix `AV1250: Method returns the result of a call to 'Concat', which uses deferred execution` @ `JointRecognizer.RecognizeMatrices()` * suppress some violations of Roslyn analyzer rules * suppress `MA0001` & `MA0002` @ GlobalSuppressions.cs @ c#
- Loading branch information
Showing
8 changed files
with
37 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
namespace tbm.Crawler; | ||
|
||
public abstract class WithLogTrace | ||
#pragma warning disable S3881 // "IDisposable" should be implemented correctly | ||
public abstract class WithLogTrace : IDisposable | ||
#pragma warning restore S3881 // "IDisposable" should be implemented correctly | ||
{ | ||
private readonly IConfigurationSection _config; | ||
private readonly Timer _timerLogTrace = new() {Enabled = true}; | ||
private readonly Timer _timer = new() {Enabled = true}; | ||
|
||
protected WithLogTrace(IConfiguration config, string section) | ||
{ | ||
_config = config.GetSection(section).GetSection("LogTrace"); | ||
_timerLogTrace.Interval = _config.GetValue("LogIntervalMs", 1000); | ||
_timerLogTrace.Elapsed += (_, _) => LogTrace(); | ||
_timer.Interval = _config.GetValue("LogIntervalMs", 1000); | ||
_timer.Elapsed += (_, _) => LogTrace(); | ||
} | ||
|
||
public virtual void Dispose() | ||
{ | ||
GC.SuppressFinalize(this); | ||
_timer.Dispose(); | ||
} | ||
|
||
protected abstract void LogTrace(); | ||
|
||
protected bool ShouldLogTrace() | ||
{ | ||
if (!_config.GetValue("Enabled", false)) return false; | ||
_timerLogTrace.Interval = _config.GetValue("LogIntervalMs", 1000); | ||
_timer.Interval = _config.GetValue("LogIntervalMs", 1000); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ public class JointRecognizer( | |
public async Task InitializePaddleOcr(CancellationToken stoppingToken = default) => | ||
await _paddleOcrRecognizerAndDetector.Initialize(stoppingToken); | ||
|
||
public IEnumerable<Either<ImageId, IRecognitionResult>> RecognizeMatrices | ||
public List<Either<ImageId, IRecognitionResult>> RecognizeMatrices | ||
Check failure on line 37 in c#/imagePipeline/src/Ocr/JointRecognizer.cs GitHub Actions / build (imagePipeline)
Check failure on line 37 in c#/imagePipeline/src/Ocr/JointRecognizer.cs GitHub Actions / build (imagePipeline)
|
||
(Dictionary<ImageKey, Mat> matricesKeyByImageKey, CancellationToken stoppingToken = default) | ||
Check failure on line 38 in c#/imagePipeline/src/Ocr/JointRecognizer.cs GitHub Actions / build (imagePipeline)
|
||
{ | ||
var recognizedEithersViaPaddleOcr = _paddleOcrRecognizerAndDetector | ||
|
@@ -63,7 +63,8 @@ public IEnumerable<Either<ImageId, IRecognitionResult>> RecognizeMatrices | |
.Lefts() | ||
.Concat(detectedEithers.Lefts()) | ||
.Concat(recognizedEithersViaTesseract.Lefts()) | ||
.Select(Either<ImageId, IRecognitionResult>.Left)); | ||
.Select(Either<ImageId, IRecognitionResult>.Left)) | ||
.ToList(); | ||
} | ||
|
||
public Dictionary<ImageKey, string> GetRecognizedTextLines | ||
|