Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RatEye/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class Config
/// <summary>
/// Log debug data
/// </summary>
public static bool LogDebug = false;
public static bool LogDebug { get; set; } = false;

/// <summary>
/// Path configuration object
Expand Down
4 changes: 2 additions & 2 deletions RatEye/Config/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public static string TesseractLibSearchPath
/// <summary>
/// Path of the debug folder which is used to store debug information
/// </summary>
public static string Debug = Combine(BaseDir, "Debug");
public static string Debug { get; set; } = Combine(BaseDir, "Debug");

/// <summary>
/// Path of the log file
/// </summary>
public static string LogFile = Combine(BaseDir, "Log.txt");
public static string LogFile { get; set; } = Combine(BaseDir, "Log.txt");

/// <summary>
/// Create a new path config instance
Expand Down
5 changes: 3 additions & 2 deletions RatEye/Config/Processing.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using RatStash;

namespace RatEye
Expand Down Expand Up @@ -84,8 +85,8 @@ internal string GetHash()
{
UseCache.ToString(),
Language.ToString(),
Scale.ToString(),
BaseSlotSize.ToString(),
Scale.ToString(CultureInfo.InvariantCulture),
BaseSlotSize.ToString(CultureInfo.InvariantCulture),
IconConfig.GetHash(),
InspectionConfig.GetHash(),
InventoryConfig.GetHash(),
Expand Down
5 changes: 3 additions & 2 deletions RatEye/Config/Processing/Inventory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenCvSharp;
using System.Globalization;
using OpenCvSharp;

namespace RatEye
{
Expand Down Expand Up @@ -57,7 +58,7 @@ internal string GetHash()
var components = new string[]
{
GridColor.ToString(),
BackgroundAlpha.ToString(),
BackgroundAlpha.ToString(CultureInfo.InvariantCulture),
MinGridColor.ToString(),
MaxGridColor.ToString(),
MinHighlightingColor.ToString(),
Expand Down
3 changes: 2 additions & 1 deletion RatEye/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
Expand Down Expand Up @@ -357,7 +358,7 @@ public static string SHA256Hash(this string value)
var buffer = Encoding.UTF8.GetBytes(value);
using var sha256 = SHA256.Create();
var hash = sha256.ComputeHash(buffer);
return string.Concat(hash.Select(x => x.ToString("X2")));
return string.Concat(hash.Select(x => x.ToString("X2", CultureInfo.InvariantCulture)));
}

/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions RatEye/IconManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
Expand Down Expand Up @@ -442,13 +443,13 @@ private static string GetFileContentHash(string path)
FileShare.ReadWrite | FileShare.Delete
);
using SHA256 sha256 = SHA256.Create();
return string.Concat(sha256.ComputeHash(stream).Select(value => value.ToString("X2")));
return string.Concat(sha256.ComputeHash(stream).Select(value => value.ToString("X2", CultureInfo.InvariantCulture)));
}

private static string GetContentHash(byte[] content)
{
using SHA256 sha256 = SHA256.Create();
return string.Concat(sha256.ComputeHash(content).Select(value => value.ToString("X2")));
return string.Concat(sha256.ComputeHash(content).Select(value => value.ToString("X2", CultureInfo.InvariantCulture)));
}

private Dictionary<Vector2, Dictionary<string, Mat>> LoadNewIcons(
Expand Down Expand Up @@ -1011,7 +1012,7 @@ private string GetIconKey(string iconPath) =>
/// <returns>The matching item</returns>
internal Item GetItem(string iconKey)
{
if (iconKey.StartsWith(_config.PathConfig.StaticIcons))
if (iconKey.StartsWith(_config.PathConfig.StaticIcons, StringComparison.Ordinal))
{
_staticCorrelationDataLock.EnterReadLock();
try
Expand Down
4 changes: 2 additions & 2 deletions RatEye/Processing/Icon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void SatisfyState(State targetState)
OCR();
break;
default:
throw new Exception("Cannot satisfy unknown state.");
throw new InvalidOperationException("Cannot satisfy unknown state.");
}

_currentState++;
Expand Down Expand Up @@ -220,7 +220,7 @@ private void TemplateMatch(bool rotated = false)

if (!IconConfig.UseStaticIcons)
{
throw new Exception(
throw new InvalidOperationException(
"No icons for template matching can be used."
+ nameof(IconConfig.UseStaticIcons)
+ " is false."
Expand Down
3 changes: 1 addition & 2 deletions RatEye/Processing/Inspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using RatStash;
Expand Down Expand Up @@ -169,7 +168,7 @@ private void SatisfyState(State targetState)
ScanTitle();
break;
default:
throw new Exception("Cannot satisfy unknown state.");
throw new InvalidOperationException("Cannot satisfy unknown state.");
}

_currentState++;
Expand Down
2 changes: 1 addition & 1 deletion RatEye/Processing/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void SatisfyState(State targetState)
ParseInventoryGrid();
break;
default:
throw new Exception("Cannot satisfy unknown state.");
throw new InvalidOperationException("Cannot satisfy unknown state.");
}

_currentState++;
Expand Down
3 changes: 1 addition & 2 deletions RatEye/Processing/MultiInspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class MultiInspection
private readonly Config _config;
private readonly Bitmap _image;

private Config.Path PathConfig => _config.PathConfig;
private Config.Processing ProcessingConfig => _config.ProcessingConfig;
private Config.Processing.Inspection InspectionConfig => ProcessingConfig.InspectionConfig;

Expand Down Expand Up @@ -75,7 +74,7 @@ private void SatisfyState(State targetState)
SearchMarker();
break;
default:
throw new Exception("Cannot satisfy unknown state.");
throw new InvalidOperationException("Cannot satisfy unknown state.");
}

_currentState++;
Expand Down
1 change: 0 additions & 1 deletion RatEye/ProcessingTimings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
Expand Down
4 changes: 4 additions & 0 deletions RatEye/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using System.Resources;

// CA1824: the embedded resources in this assembly are English (RatEye.Properties).
[assembly: NeutralResourcesLanguage("en")]
15 changes: 12 additions & 3 deletions RatEye/RatEyeEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ private void ThrowIfDisposed()
/// its icon manager, Tesseract engines, and inspection marker. Complete
/// all work on returned processing objects before disposing the engine.
/// </remarks>
public void Dispose() => DisposeCore(throwOnFailure: false);
public void Dispose()
{
GC.SuppressFinalize(this);
DisposeCore(throwOnFailure: false);
}

/// <summary>
/// Releases processing resources and throws if any cleanup operation fails.
Expand All @@ -120,7 +124,13 @@ private void ThrowIfDisposed()
/// Prefer normal <see cref="Dispose"/> for using blocks so a cleanup failure cannot mask
/// an active processing exception. Call this method when explicit teardown must fail fast.
/// </remarks>
public void DisposeStrict() => DisposeCore(throwOnFailure: true);
public void DisposeStrict()
{
// CA1816: SuppressFinalize belongs only in the IDisposable.Dispose
// implementation; the finalizer is harmless after DisposeStrict because
// DisposeCore is idempotent via _disposed.
DisposeCore(throwOnFailure: true);
}

/// <summary>
/// Gets the aggregate failure from the cleanup attempt, if any.
Expand Down Expand Up @@ -194,7 +204,6 @@ private void DisposeCore(bool throwOnFailure)
Config.ProcessingConfig.InspectionConfig.DisposeMarker,
cleanupErrors
);
GC.SuppressFinalize(this);

if (cleanupErrors.Count > 0)
{
Expand Down
4 changes: 1 addition & 3 deletions RatEye/Vector2.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace RatEye
namespace RatEye
{
/// <summary>
/// A 2D <see cref="int"/> vector
Expand Down