diff --git a/.editorconfig b/.editorconfig index 3b00d9b..c577452 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,7 +16,7 @@ charset = utf-8-bom # XML project files [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] -indent_size = 2 +indent_size = 4 # XML config files [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] @@ -78,7 +78,7 @@ dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case # Non-private readonly fields are PascalCase dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields -dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_static_field_style dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected @@ -89,7 +89,7 @@ dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_cas # Constants are PascalCase dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants -dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style +dotnet_naming_rule.constants_should_be_pascal_case.style = non_private_static_field_style dotnet_naming_symbols.constants.applicable_kinds = field, local dotnet_naming_symbols.constants.required_modifiers = const @@ -99,7 +99,7 @@ dotnet_naming_style.constant_style.capitalization = pascal_case # Static fields are camelCase and start with _ dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields -dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style +dotnet_naming_rule.static_fields_should_be_camel_case.style = instance_field_style dotnet_naming_symbols.static_fields.applicable_kinds = field dotnet_naming_symbols.static_fields.required_modifiers = static @@ -129,7 +129,7 @@ dotnet_naming_style.camel_case_style.capitalization = camel_case # Local functions are PascalCase dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions -dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style +dotnet_naming_rule.local_functions_should_be_pascal_case.style = non_private_static_field_style dotnet_naming_symbols.local_functions.applicable_kinds = local_function @@ -138,7 +138,7 @@ dotnet_naming_style.local_function_style.capitalization = pascal_case # By default, name items with PascalCase dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members -dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style +dotnet_naming_rule.members_should_be_pascal_case.style = non_private_static_field_style dotnet_naming_symbols.all_members.applicable_kinds = * @@ -175,6 +175,20 @@ dotnet_public_api_analyzer.require_api_files = true # dotnet_style_allow_multiple_blank_lines_experimental dotnet_diagnostic.IDE2000.severity = warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_collection_expression = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +end_of_line = crlf # CSharp code style settings: [*.cs] @@ -256,6 +270,22 @@ csharp_preserve_single_line_statements = true # IDE0060: Remove unused parameter dotnet_diagnostic.IDE0060.severity = warning +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion [src/{Compilers,ExpressionEvaluator,Scripting}/**Test**/*.{cs,vb}] diff --git a/NetSparkle b/NetSparkle index 218ceb4..34b7315 160000 --- a/NetSparkle +++ b/NetSparkle @@ -1 +1 @@ -Subproject commit 218ceb4ea514af68d13f9b41f941871ddee9201e +Subproject commit 34b731554e3cbeadbc327355349571e2e1269dde diff --git a/OotD.Core/Forms/InstanceManager.cs b/OotD.Core/Forms/InstanceManager.cs index 1c5113f..79fb1c6 100644 --- a/OotD.Core/Forms/InstanceManager.cs +++ b/OotD.Core/Forms/InstanceManager.cs @@ -259,13 +259,14 @@ public void LoadInstances() // create our instance and set the context menu to one defined in the form instance. var newlyAdded = false; - if (!_mainFormInstances.ContainsKey(instanceName)) + if (!_mainFormInstances.TryGetValue(instanceName, out var value)) { - _mainFormInstances.Add(instanceName, new MainForm(instanceName)); + value = new MainForm(instanceName); + _mainFormInstances.Add(instanceName, value); newlyAdded = true; } - trayIcon.ContextMenuStrip = _mainFormInstances[instanceName].TrayMenu; + trayIcon.ContextMenuStrip = value.TrayMenu; // remove unnecessary menu items while (trayIcon.ContextMenuStrip.Items.Count > 0 && @@ -277,29 +278,29 @@ public void LoadInstances() trayIcon.ContextMenuStrip.Items["RemoveInstanceMenu"]!.Visible = false; trayIcon.ContextMenuStrip.Items["RenameInstanceMenu"]!.Visible = false; - if (_mainFormInstances[instanceName].TrayMenu.Items.ContainsKey("AddInstanceMenu")) + if (value.TrayMenu.Items.ContainsKey("AddInstanceMenu")) { - _mainFormInstances[instanceName].TrayMenu.Items["AddInstanceMenu"]!.Visible = true; + value.TrayMenu.Items["AddInstanceMenu"]!.Visible = true; } - if (_mainFormInstances[instanceName].TrayMenu.Items.ContainsKey("AboutMenu")) + if (value.TrayMenu.Items.ContainsKey("AboutMenu")) { - _mainFormInstances[instanceName].TrayMenu.Items["AboutMenu"]!.Visible = true; + value.TrayMenu.Items["AboutMenu"]!.Visible = true; } - if (_mainFormInstances[instanceName].TrayMenu.Items.ContainsKey("StartWithWindows")) + if (value.TrayMenu.Items.ContainsKey("StartWithWindows")) { - _mainFormInstances[instanceName].TrayMenu.Items["StartWithWindows"]!.Visible = true; + value.TrayMenu.Items["StartWithWindows"]!.Visible = true; } - if (_mainFormInstances[instanceName].TrayMenu.Items.ContainsKey("LockPositionMenu")) + if (value.TrayMenu.Items.ContainsKey("LockPositionMenu")) { - _mainFormInstances[instanceName].TrayMenu.Items["LockPositionMenu"]!.Visible = true; + value.TrayMenu.Items["LockPositionMenu"]!.Visible = true; } - if (_mainFormInstances[instanceName].TrayMenu.Items.ContainsKey("CheckForUpdatesMenu")) + if (value.TrayMenu.Items.ContainsKey("CheckForUpdatesMenu")) { - _mainFormInstances[instanceName].TrayMenu.Items["CheckForUpdatesMenu"]!.Visible = true; + value.TrayMenu.Items["CheckForUpdatesMenu"]!.Visible = true; } // add global menu items that don't apply to the instance. @@ -338,13 +339,13 @@ public void LoadInstances() new ToolStripMenuItem(Resources.About, null, AboutMenu_Click, "AboutMenu")); } - _mainFormInstances[instanceName].TrayMenu.Items["Separator6"]!.Visible = true; - _mainFormInstances[instanceName].TrayMenu.Items["ExitMenu"]!.Visible = true; + value.TrayMenu.Items["Separator6"]!.Visible = true; + value.TrayMenu.Items["ExitMenu"]!.Visible = true; if (newlyAdded) { - _mainFormInstances[instanceName].Show(); - UnsafeNativeMethods.SendWindowToBack(_mainFormInstances[instanceName]); + value.Show(); + UnsafeNativeMethods.SendWindowToBack(value); } } } diff --git a/OotD.Core/Forms/MainForm.cs b/OotD.Core/Forms/MainForm.cs index a9e40e8..de7c39a 100644 --- a/OotD.Core/Forms/MainForm.cs +++ b/OotD.Core/Forms/MainForm.cs @@ -383,7 +383,7 @@ private void SetMAPIFolder() private void UpdateOutlookViewsList() { OutlookViewsMenu.DropDownItems.Clear(); - OutlookFolderViews = new List(); + OutlookFolderViews = []; if (_outlookFolder == null) { @@ -426,8 +426,8 @@ private static string GetFolderNameFromFullPath(string? fullPath) { if (fullPath != null) { - return fullPath.Substring(fullPath.LastIndexOf("\\", StringComparison.Ordinal) + 1, - fullPath.Length - fullPath.LastIndexOf("\\", StringComparison.Ordinal) - 1); + return fullPath.Substring(fullPath.LastIndexOf('\\') + 1, + fullPath.Length - fullPath.LastIndexOf('\\') - 1); } return string.Empty; @@ -460,7 +460,7 @@ private static string GenerateFolderPathFromObject(MAPIFolder? oFolder) } } - if (fullFolderPath.EndsWith("\\")) + if (fullFolderPath.EndsWith('\\')) { fullFolderPath = fullFolderPath[..^1]; } diff --git a/OotD.Core/Utility/OutlookFolderDefinition.cs b/OotD.Core/Utility/OutlookFolderDefinition.cs index 409aa85..b2a0366 100644 --- a/OotD.Core/Utility/OutlookFolderDefinition.cs +++ b/OotD.Core/Utility/OutlookFolderDefinition.cs @@ -2,17 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.CodeAnalysis; - namespace OotD.Utility; /// /// Structure to hold the currently selected custom folder details /// -[SuppressMessage("ReSharper", "InconsistentNaming")] internal struct OutlookFolderDefinition { - public string? OutlookFolderName; - public string? OutlookFolderStoreId; - public string? OutlookFolderEntryId; -} \ No newline at end of file + public string? OutlookFolderStoreId { get; set; } + public string? OutlookFolderName { get; set; } + public string? OutlookFolderEntryId { get; set; } +}