Skip to content

Commit

Permalink
Merge pull request #496 from TheJoeFin/dev
Browse files Browse the repository at this point in the history
4.6.0 from dev
  • Loading branch information
TheJoeFin authored Nov 12, 2024
2 parents 8020978 + 7a1e6f1 commit d5840e9
Show file tree
Hide file tree
Showing 72 changed files with 757 additions and 497 deletions.
101 changes: 76 additions & 25 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
# EditorConfig is awesome: https://EditorConfig.org

# Remove the line below if you want to inherit '.editorconfig' settings from higher directories
root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
end_of_line = crlf
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion

[*.{yml,yaml,appxmanifest,manifest,config}]
indent_style = space
indent_size = 2

# Files that require CRLF line endings
[*.{bat,cmd,wapproj}]
end_of_line = crlf
indent_style = space
indent_size = 4

[*.{sln,props}]
indent_style = tab
indent_size = 8

# C# files
[*.cs]

Expand All @@ -13,7 +43,6 @@ tab_width = 4

# New line preferences
end_of_line = crlf
insert_final_newline = false

#### .NET Coding Conventions ####

Expand Down Expand Up @@ -82,14 +111,14 @@ csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = false:suggestion

# Expression-bodied members
csharp_style_expression_bodied_accessors = true
csharp_style_expression_bodied_constructors = false
csharp_style_expression_bodied_indexers = true
csharp_style_expression_bodied_lambdas = true
csharp_style_expression_bodied_local_functions = false
csharp_style_expression_bodied_methods = false
csharp_style_expression_bodied_operators = false
csharp_style_expression_bodied_properties = true
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent

# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true
Expand All @@ -109,12 +138,12 @@ csharp_style_prefer_readonly_struct = true
csharp_style_prefer_readonly_struct_member = true

# Code-block preferences
csharp_prefer_braces = when_multiline
csharp_prefer_simple_using_statement = true
csharp_style_namespace_declarations = file_scoped
csharp_style_prefer_method_group_conversion = true
csharp_style_prefer_primary_constructors = true
csharp_style_prefer_top_level_statements = true
csharp_prefer_braces = when_multiline:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_top_level_statements = true:silent

# Expression-level preferences
csharp_prefer_simple_default_expression = true
Expand All @@ -132,7 +161,7 @@ csharp_style_unused_value_assignment_preference = discard_variable
csharp_style_unused_value_expression_statement_preference = discard_variable

# 'using' directive preferences
csharp_using_directive_placement = outside_namespace
csharp_using_directive_placement = outside_namespace:silent

# New line preferences
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
Expand Down Expand Up @@ -208,24 +237,46 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_diagnostic.CA1069.severity = none # CA1069: Enums values should not be duplicated
dotnet_diagnostic.CA2211.severity = none
dotnet_diagnostic.CA1806.severity = none
dotnet_diagnostic.CA1016.severity = none
dotnet_diagnostic.CA1806.severity = none
dotnet_diagnostic.CA1822.severity = none
dotnet_diagnostic.CA1845.severity = none
dotnet_diagnostic.CA1513.severity = none
dotnet_diagnostic.CA1859.severity = none
dotnet_diagnostic.CA1854.severity = none
dotnet_diagnostic.NU1503.severity = none
dotnet_diagnostic.CA1869.severity = none
dotnet_diagnostic.CA1067.severity = none
dotnet_diagnostic.IDE0011.severity = none
dotnet_diagnostic.IDE0060.severity = none
dotnet_diagnostic.IDE0059.severity = none
dotnet_diagnostic.IDE0055.severity = none
dotnet_diagnostic.CA2263.severity = none
dotnet_diagnostic.IDE0051.severity = none
dotnet_diagnostic.IDE0052.severity = none
dotnet_diagnostic.CS1591.severity = none
9 changes: 2 additions & 7 deletions Tests/FilesIoTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using Text_Grab;
using Text_Grab.Utilities;

Expand All @@ -16,7 +11,7 @@ public class FilesIoTests
[WpfFact]
public async Task CanSaveImagesWithHistory()
{
Bitmap fontSampleBitmap = new Bitmap(FileUtilities.GetPathToLocalFile(fontSamplePath));
Bitmap fontSampleBitmap = new(FileUtilities.GetPathToLocalFile(fontSamplePath));

bool couldSave = await FileUtilities.SaveImageFile(fontSampleBitmap, "newTest.png", FileStorageKind.WithHistory);

Expand Down
Binary file added Tests/Images/GUIDs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Tests/OcrTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ public async Task GetTessLanguages()
Assert.Contains(tag, actualStrings);
}
}
[WpfFact(Skip ="fails GitHub actions")]

[WpfFact(Skip = "fails GitHub actions")]
public async Task GetTesseractStrongLanguages()
{
List<ILanguage> expectedList = new()
Expand Down
2 changes: 1 addition & 1 deletion Tests/QrCodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class QrCodeTests
public void generateSvgImage()
{
string testString = "This is only a test";
var svg = BarcodeUtilities.GetSvgQrCodeForText(testString, ErrorCorrectionLevel.L);
ZXing.Rendering.SvgRenderer.SvgImage svg = BarcodeUtilities.GetSvgQrCodeForText(testString, ErrorCorrectionLevel.L);

Assert.NotNull(svg);
}
Expand Down
38 changes: 35 additions & 3 deletions Tests/StringMethodTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Text;
using Text_Grab;
using System.Linq;
using Text_Grab.Utilities;

namespace Tests;
Expand Down Expand Up @@ -95,7 +94,7 @@ public void TryFixToLetters_ReplacesDigitsWithLetters_AsExpected(string input, s
}

[Theory]
[InlineData("","")]
[InlineData("", "")]
[InlineData("he11o there", "hello there")]
[InlineData("my number is l23456789o", "my number is 1234567890")]
public void TryFixNumOrLetters(string input, string expected)
Expand Down Expand Up @@ -412,4 +411,37 @@ public void TestLimitEachLine(string inputString, string expected, int charLimit
{
Assert.Equal(expected, inputString.LimitCharactersPerLine(charLimit, spotInLine));
}
}

private string actualGuids = """

Check warning on line 415 in Tests/StringMethodTests.cs

View workflow job for this annotation

GitHub Actions / build

The field 'StringMethodTests.actualGuids' is assigned but its value is never used

Check warning on line 415 in Tests/StringMethodTests.cs

View workflow job for this annotation

GitHub Actions / build

The field 'StringMethodTests.actualGuids' is assigned but its value is never used
97a56312-d8e8-4ca5-87fa-18e35266d31e
bdc5a5f2-d6ff-403d-a632-f9006387e149
aeef14aa-9aff-4f0d-8ca5-e5df1b399c20
c702f24c-e51b-4ebd-bb45-56df08266e80
a87f9201-a046-425d-b92b-b488667a5d92
bc656414-4f2a-4219-b763-810632a535e2
11c5ecc4-0c0a-4606-a54f-16df976637d1
5cec5cc9-782d-47aa-bff3-c84e13a81604
8501db7b-ee04-4fb2-8516-f5e2f0bc71bf
8da03c16-6d3f-4750-831b-c3866af85551
03d82c33-489c-41b2-8222-cc489d00b1bf
edf3b5ee-658e-41ea-8f7a-494a07beb322
4418874a-30c7-4a16-aba5-0f2a0c49b4f9
d4144186-4fad-40a0-bda9-7e3a2ea58a48
486d81d0-0d56-466b-856c-0bc37e897b7b
935155d5-1a96-4901-8b7d-23854fceb32d
ff826fac-d166-441e-8040-05218989e805
0a4ed755-f236-4e10-8b0b-592a527bb560
9be83ad8-5e2d-4e37-a9f5-9b728cd9b934
926ef504-264d-4762-b781-8813156eaa86
""";


[Theory]
[InlineData("g7a56312-d8e8-4ca5-87fa-18e3S266d3le", "97a56312-d8e8-4ca5-87fa-18e35266d31e")]
[InlineData("g7a56312-d8e 8-4ca5-87fa-18e3S2 66d3le", "97a56312-d8e8-4ca5-87fa-18e35266d31e")]
[InlineData("g7a56312-\r\nd8e8\r\n-4ca5-87fa-18e3S266d3le", "97a56312-d8e8-4ca5-87fa-18e35266d31e")]
public void TestGuidCorrections(string input, string expected)
{
Assert.Equal(expected, input.CorrectCommonGuidErrors());
}
}
6 changes: 3 additions & 3 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.24">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.42">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion Text-Grab-Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="40087JoeFinApps.TextGrab"
Publisher="CN=153F3B0F-BA3D-4964-8098-71AC78A1DF6A"
Version="4.5.1.0" />
Version="4.6.0.0" />

<Properties>
<DisplayName>Text Grab</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion Text-Grab-Package/Text-Grab-Package.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
Expand Down
4 changes: 2 additions & 2 deletions Text-Grab/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class App : System.Windows.Application
{
#region Fields

readonly static Settings _defaultSettings = AppUtilities.TextGrabSettings;
private static readonly Settings _defaultSettings = AppUtilities.TextGrabSettings;

#endregion Fields

Expand Down Expand Up @@ -232,7 +232,7 @@ private void appExit(object sender, ExitEventArgs e)
Singleton<HistoryService>.Instance.WriteHistory();
}

async void appStartup(object sender, StartupEventArgs e)
private async void appStartup(object sender, StartupEventArgs e)
{
NumberOfRunningInstances = Process.GetProcessesByName("Text-Grab").Length;
Current.DispatcherUnhandledException += CurrentDispatcherUnhandledException;
Expand Down
1 change: 0 additions & 1 deletion Text-Grab/Controls/AddOrRemoveWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Windows.Graphics.Printing.Workflow;

namespace Text_Grab.Controls;

Expand Down
1 change: 0 additions & 1 deletion Text-Grab/Controls/CollapsibleButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using Text_Grab.Models;
using Wpf.Ui.Controls;

Expand Down
7 changes: 3 additions & 4 deletions Text-Grab/Controls/FindAndReplaceWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
Expand All @@ -28,7 +27,7 @@ public partial class FindAndReplaceWindow : FluentWindow
public static RoutedCommand ReplaceAllCmd = new();
public static RoutedCommand ReplaceOneCmd = new();
public static RoutedCommand TextSearchCmd = new();
DispatcherTimer ChangeFindTextTimer = new();
private DispatcherTimer ChangeFindTextTimer = new();
private MatchCollection? Matches;
private string stringFromWindow = "";
private EditTextWindow? textEditWindow;
Expand Down Expand Up @@ -171,11 +170,11 @@ private void CopyMatchesCmd_Executed(object sender, ExecutedRoutedEventArgs e)

StringBuilder stringBuilder = new();

var selection = ResultsListView.SelectedItems;
IList selection = ResultsListView.SelectedItems;
if (selection.Count < 2)
selection = ResultsListView.Items;

foreach (var item in selection)
foreach (object? item in selection)
if (item is FindResult findResult)
stringBuilder.AppendLine(findResult.Text);

Expand Down
2 changes: 1 addition & 1 deletion Text-Grab/Controls/PreviousGrabWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public PreviousGrabWindow(Rect rect)
Left = rect.Left - borderThickness;
Top = rect.Top - borderThickness;

DispatcherTimer timer = new DispatcherTimer();
DispatcherTimer timer = new();
timer.Interval = TimeSpan.FromMilliseconds(500);
timer.Tick += (s, e) => { timer.Stop(); Close(); };
timer.Start();
Expand Down
Loading

0 comments on commit d5840e9

Please sign in to comment.