Skip to content

Commit

Permalink
code tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonyCorbett committed Jun 7, 2021
1 parent 6d0897b commit 9060bec
Show file tree
Hide file tree
Showing 25 changed files with 495 additions and 362 deletions.
210 changes: 209 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,206 @@
[*.cs]
root = true

# To learn more about .editorconfig see https://aka.ms/editorconfigdocs

###############################
# Core EditorConfig Options #
###############################
# All files
[*]
#use soft tabs (spaces) for indentation
indent_style = space

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom

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

[*.{cs,vb}]
# Organize usings
#----------------
dotnet_sort_system_directives_first = true

# this. preferences
#------------------
#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = false:suggestion
#prefer methods not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Language keywords vs BCL types preferences
#-------------------------------------------
#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion

# Parentheses preferences
#------------------------
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent

# Modifier preferences
#---------------------
#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
dotnet_style_readonly_field = true:suggestion

# Expression-level preferences
#-----------------------------
#prefer objects to be initialized using object initializers when possible
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent

###############################
# Naming Conventions #
###############################

# Style Definitions
#------------------
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const

###############################
# C# Coding Conventions #
###############################

[*.cs]
# var preferences
#----------------
#prefer var is used to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = true:suggestion
#prefer var when the type is already mentioned on the right-hand side of a declaration expression
csharp_style_var_when_type_is_apparent = true:suggestion
#prefer var over explicit type in all cases, unless overridden by another code style rule
csharp_style_var_elsewhere = true:suggestion

# Expression-bodied members
#--------------------------
#prefer block bodies for methods
csharp_style_expression_bodied_methods = false:silent
#prefer block bodies for constructors
csharp_style_expression_bodied_constructors = false:suggestion
#prefer expression-bodied members for properties
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent

# Pattern matching preferences
#-----------------------------
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# Null-checking preferences
#--------------------------
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Modifier preferences
#---------------------
#when this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion

# Expression-level preferences
#-----------------------------
#prefer curly braces even for one line of code
csharp_prefer_braces = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
#prefer local functions over anonymous functions
csharp_style_pattern_local_over_anonymous_function = true:suggestion
#prefer out variables to be declared inline in the argument list of a method call when possible
csharp_style_inlined_variable_declaration = true:suggestion
# IDE0063: Use simple 'using' statement
csharp_prefer_simple_using_statement = true:silent

###############################
# C# Formatting Rules #
###############################

# New line preferences
#---------------------
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
#require members of object intializers to be on separate lines
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
#------------------------
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# Space preferences
#------------------
#require NO space between a cast and the value
csharp_space_after_cast = false
#require a space after a keyword in a control flow statement such as a for loop
csharp_space_after_keywords_in_control_flow_statements = true
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
csharp_space_between_method_call_parameter_list_parentheses = false
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_before_colon_in_inheritance_clause = true
#require a space after the colon for bases or interfaces in a type declaration
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
#remove space within empty parameter list parentheses for a method declaration
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
#remove space between method call name and opening parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
#remove space within empty argument list parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false

# Wrapping preferences
#---------------------
#leave statements and member declarations on the same line
csharp_preserve_single_line_statements = true
#leave code block on single line
csharp_preserve_single_line_blocks = true

###############################
# Resharper Rules #
###############################

# Resharper automatically uses the most common editorconfig Rules
# but we can also add resharper-specific rules here if needed.
# https://www.jetbrains.com/help/resharper/Reference__Code_Inspections_CSHARP.html
resharper_convert_to_using_declaration_highlighting = silent

###############################
# C# Analyzer Rules #
###############################

# CA1416: Validate platform compatibility
dotnet_diagnostic.CA1416.severity = silent
Expand All @@ -14,3 +216,9 @@ dotnet_diagnostic.U2U1103.severity = silent

# U2U1009: Async or iterator methods should avoid state machine generation for early exits (throws or synchronous returns)
dotnet_diagnostic.U2U1009.severity = silent

# S112: General exceptions should never be thrown
dotnet_diagnostic.S112.severity = silent

# S1168: Empty arrays and collections should be returned instead of null
dotnet_diagnostic.S1168.severity = silent
4 changes: 2 additions & 2 deletions CreateDeliverables.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ xcopy OnlyMSlideManager\bin\Release\net5.0-windows\publish\*.* OnlyM\bin\Release
xcopy VCRTL\*.* OnlyM\bin\Release\net5.0-windows\publish /q

REM Remove unwanted language files
del OnlyM\bin\Release\net5.0-windows\publish\no-NO\*.dll
del OnlyM\bin\Release\net5.0-windows\publish\pap-PAP\*.dll
rd OnlyM\bin\Release\net5.0-windows\publish\no-NO /q /s
rd OnlyM\bin\Release\net5.0-windows\publish\pap-PAP /q /s

REM Create installer
"C:\Program Files (x86)\Inno Setup 6\iscc" Installer\onlymsetup.iss
Expand Down
11 changes: 7 additions & 4 deletions IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.4" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.4" />
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions OnlyM.Core/OnlyM.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FFME.Windows" Version="4.3.340" />
<PackageReference Include="FFME.Windows" Version="4.4.350" />
<PackageReference Include="FluentCommandLineParser-netstandard" Version="1.4.3.13" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.34" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.0.2" />
Expand Down
4 changes: 0 additions & 4 deletions OnlyM.CoreSys/WindowsPositioning/WindowsPlacement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public static string GetPlacement(this Window window)
return GetPlacement(new WindowInteropHelper(window).Handle);
}

#pragma warning disable SA1008 // Opening parenthesis must be spaced correctly
public static (int x, int y) GetDpiSettings()
{
var dpiXProperty = typeof(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic | BindingFlags.Static);
Expand All @@ -74,7 +73,6 @@ public static (int x, int y) GetDpiSettings()

return ((int)dpiXProperty.GetValue(null, null), (int)dpiYProperty.GetValue(null, null));
}
#pragma warning restore SA1008 // Opening parenthesis must be spaced correctly

private static string GetPlacement(IntPtr windowHandle)
{
Expand All @@ -93,7 +91,6 @@ private static string GetPlacement(IntPtr windowHandle)
// RECT structure required by WINDOWPLACEMENT structure
[Serializable]
[StructLayout(LayoutKind.Sequential)]
#pragma warning disable SA1201 // Elements must appear in the correct order
public struct RECT
{
public int Left;
Expand All @@ -109,7 +106,6 @@ public RECT(int left, int top, int right, int bottom)
Bottom = bottom;
}
}
#pragma warning restore SA1201 // Elements must appear in the correct order

// POINT structure required by WINDOWPLACEMENT structure
[Serializable]
Expand Down
2 changes: 1 addition & 1 deletion OnlyM/OnlyM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

<ItemGroup>
<PackageReference Include="CefSharp.Wpf.NETCore" Version="90.6.70" />
<PackageReference Include="FFME.Windows" Version="4.3.340" />
<PackageReference Include="FFME.Windows" Version="4.4.350" />
<PackageReference Include="MaterialDesignThemes" Version="4.1.0" />
<PackageReference Include="NAudio" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
Expand Down
4 changes: 2 additions & 2 deletions OnlyM/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
Expand Down Expand Up @@ -416,4 +416,4 @@ private static bool IsInDesignMode()
#endif
}
}
}
}
27 changes: 11 additions & 16 deletions OnlyMSlideManager/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
using Microsoft.Extensions.DependencyInjection;
using System.IO;
using System.Threading;
using System.Windows;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Toolkit.Mvvm.DependencyInjection;
using OnlyM.CoreSys.Services.Snackbar;
using OnlyM.CoreSys.Services.UI;
using OnlyMSlideManager.Helpers;
using OnlyMSlideManager.Services;
using OnlyMSlideManager.Services.DragAndDrop;
using OnlyMSlideManager.Services.Options;
using OnlyMSlideManager.ViewModel;
using Serilog;

namespace OnlyMSlideManager
{
using System.IO;
using System.Threading;
using System.Windows;
using OnlyMSlideManager.Helpers;
using Serilog;

public partial class App : Application
{
private readonly string _appString = "OnlyMSlideManagerTool";
private Mutex _appMutex;

public App()
{
}


protected override void OnExit(ExitEventArgs e)
{
_appMutex?.Dispose();
Expand All @@ -41,7 +36,7 @@ protected override void OnStartup(StartupEventArgs e)
ConfigureServices();
}

private void ConfigureServices()
private static void ConfigureServices()
{
var serviceCollection = new ServiceCollection();

Expand All @@ -64,9 +59,9 @@ private bool AnotherInstanceRunning()
return !newInstance;
}

private void ConfigureLogger()
private static void ConfigureLogger()
{
string logsDirectory = FileUtils.GetLogFolder();
var logsDirectory = FileUtils.GetLogFolder();

#if DEBUG
Log.Logger = new LoggerConfiguration()
Expand All @@ -83,4 +78,4 @@ private void ConfigureLogger()
Log.Logger.Information("==== Launched ====");
}
}
}
}
12 changes: 6 additions & 6 deletions OnlyMSlideManager/Behaviours/WindowClosingBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace OnlyMSlideManager.Behaviours
{
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;

namespace OnlyMSlideManager.Behaviours
{
public class WindowClosingBehaviour
{
public static readonly DependencyProperty ClosedProperty
Expand Down
Loading

0 comments on commit 9060bec

Please sign in to comment.