From 4c2303ff255836fe8e7665ec859925229df84188 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 25 Jan 2026 16:32:02 -0500 Subject: [PATCH] Add editorconfig, fix issues --- .editorconfig | 167 ++++++++++++++++++++ RedumpTool/Program.cs | 2 +- SabreTools.RedumpLib/Builder.cs | 6 +- SabreTools.RedumpLib/Data/Extensions.cs | 4 + SabreTools.RedumpLib/Downloader.cs | 1 + SabreTools.RedumpLib/Formatter.cs | 4 +- SabreTools.RedumpLib/Validator.cs | 10 +- SabreTools.RedumpLib/Web/CookieWebClient.cs | 1 - SabreTools.RedumpLib/Web/RedumpClient.cs | 2 +- 9 files changed, 188 insertions(+), 9 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..94343d5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,167 @@ +# top-most EditorConfig file +root = true + +# C# files +[*.cs] + +# Indentation and spacing +charset = utf-8 +indent_size = 4 +indent_style = space +tab_width = 4 +trim_trailing_whitespace = true + +# New line preferences +end_of_line = lf +insert_final_newline = true +max_line_length = unset + +# using directive preferences +csharp_using_directive_placement = outside_namespace +dotnet_diagnostic.IDE0005.severity = error + +# Code-block preferences +csharp_style_namespace_declarations = block_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_top_level_statements = false + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_inlined_variable_declaration = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable +dotnet_diagnostic.IDE0001.severity = warning +dotnet_diagnostic.IDE0002.severity = warning +dotnet_diagnostic.IDE0004.severity = warning +dotnet_diagnostic.IDE0010.severity = error +dotnet_diagnostic.IDE0051.severity = warning +dotnet_diagnostic.IDE0052.severity = warning +dotnet_diagnostic.IDE0072.severity = warning +dotnet_diagnostic.IDE0080.severity = warning +dotnet_diagnostic.IDE0100.severity = error +dotnet_diagnostic.IDE0110.severity = error +dotnet_diagnostic.IDE0120.severity = warning +dotnet_diagnostic.IDE0121.severity = warning +dotnet_diagnostic.IDE0240.severity = error +dotnet_diagnostic.IDE0241.severity = error +dotnet_style_coalesce_expression = true +dotnet_style_namespace_match_folder = false +dotnet_style_null_propagation = true +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_collection_expression = when_types_loosely_match +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_compound_assignment = true +csharp_style_prefer_simple_property_accessors = true +dotnet_style_prefer_simplified_interpolation = true +dotnet_style_prefer_simplified_boolean_expressions = true +csharp_style_prefer_unbound_generic_type_in_nameof = true + +# Field preferences +dotnet_diagnostic.IDE0044.severity = warning +dotnet_style_readonly_field = true + +# Language keyword vs. framework types preferences +dotnet_diagnostic.IDE0049.severity = error +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_style_prefer_readonly_struct = true +dotnet_diagnostic.IDE0036.severity = warning +dotnet_diagnostic.IDE0040.severity = error +dotnet_diagnostic.IDE0380.severity = error +dotnet_style_require_accessibility_modifiers = always + +# New-line preferences +dotnet_diagnostic.IDE2000.severity = warning +dotnet_diagnostic.IDE2002.severity = warning +dotnet_diagnostic.IDE2003.severity = warning +dotnet_diagnostic.IDE2004.severity = warning +dotnet_diagnostic.IDE2005.severity = warning +dotnet_diagnostic.IDE2006.severity = warning +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false +dotnet_style_allow_multiple_blank_lines_experimental = false +dotnet_style_allow_statement_immediately_after_block_experimental = false + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all +dotnet_diagnostic.IDE0280.severity = error + +# Parentheses preferences +dotnet_diagnostic.IDE0047.severity = warning +dotnet_diagnostic.IDE0048.severity = warning +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = always_for_clarity +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Pattern-matching preferences +dotnet_diagnostic.IDE0019.severity = warning +dotnet_diagnostic.IDE0020.severity = warning +dotnet_diagnostic.IDE0038.severity = warning +dotnet_diagnostic.IDE0066.severity = none +dotnet_diagnostic.IDE0083.severity = warning +dotnet_diagnostic.IDE0260.severity = warning +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# var preferences +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = true + +# .NET formatting options +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true + +# C# formatting options +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false diff --git a/RedumpTool/Program.cs b/RedumpTool/Program.cs index 207b682..51799ba 100644 --- a/RedumpTool/Program.cs +++ b/RedumpTool/Program.cs @@ -7,7 +7,7 @@ namespace RedumpTool { public class Program { - static void Main(string[] args) + public static void Main(string[] args) { // Show help if nothing is input if (args == null || args.Length == 0) diff --git a/SabreTools.RedumpLib/Builder.cs b/SabreTools.RedumpLib/Builder.cs index c0f6146..94ae8e5 100644 --- a/SabreTools.RedumpLib/Builder.cs +++ b/SabreTools.RedumpLib/Builder.cs @@ -54,6 +54,7 @@ namespace SabreTools.RedumpLib /// String containing the HTML disc data /// Filled SubmissionInfo object on success, null on error /// Not currently working +#pragma warning disable IDE0051 private static SubmissionInfo? CreateFromID(string discData) { var info = new SubmissionInfo() @@ -244,6 +245,7 @@ namespace SabreTools.RedumpLib return info; } +#pragma warning restore IDE0051 /// /// Fill out an existing SubmissionInfo object based on a disc page @@ -252,7 +254,7 @@ namespace SabreTools.RedumpLib /// Existing SubmissionInfo object to fill /// Redump disc ID to retrieve /// True to include all pullable information, false to do bare minimum - public async static Task FillFromId(RedumpClient rc, SubmissionInfo info, int id, bool includeAllData) + public static async Task FillFromId(RedumpClient rc, SubmissionInfo info, int id, bool includeAllData) { var discData = await rc.DownloadSingleSiteID(id); if (string.IsNullOrEmpty(discData)) @@ -678,6 +680,7 @@ namespace SabreTools.RedumpLib /// private static bool ShouldSkipSiteCode(SiteCode? siteCode) { +#pragma warning disable IDE0072 return siteCode switch { // Multiple @@ -711,6 +714,7 @@ namespace SabreTools.RedumpLib _ => false, }; +#pragma warning restore IDE0072 } #endregion diff --git a/SabreTools.RedumpLib/Data/Extensions.cs b/SabreTools.RedumpLib/Data/Extensions.cs index 35daa28..9904c18 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -7,6 +7,8 @@ namespace SabreTools.RedumpLib.Data /// /// Information pertaining to Redump systems /// +#pragma warning disable IDE0010 +#pragma warning disable IDE0072 public static class Extensions { #region Cross-Enumeration @@ -1839,4 +1841,6 @@ namespace SabreTools.RedumpLib.Data #endregion } +#pragma warning restore IDE0010 +#pragma warning restore IDE0072 } diff --git a/SabreTools.RedumpLib/Downloader.cs b/SabreTools.RedumpLib/Downloader.cs index 64a0a25..81cd703 100644 --- a/SabreTools.RedumpLib/Downloader.cs +++ b/SabreTools.RedumpLib/Downloader.cs @@ -131,6 +131,7 @@ namespace SabreTools.RedumpLib case Feature.WIP: processedIds = await ProcessWIP(); break; + case Feature.NONE: default: return []; } diff --git a/SabreTools.RedumpLib/Formatter.cs b/SabreTools.RedumpLib/Formatter.cs index 76736e0..5a764fa 100644 --- a/SabreTools.RedumpLib/Formatter.cs +++ b/SabreTools.RedumpLib/Formatter.cs @@ -504,7 +504,7 @@ namespace SabreTools.RedumpLib // Gross hack because of automatic layerbreaks in Redump if (!enableRedumpCompatibility - || (mediaType != MediaType.BluRay && system.IsXGD() == false)) + || (mediaType != MediaType.BluRay && !system.IsXGD())) { AddIfExists(output, Template.LayerbreakField, section?.Layerbreak, 1); } @@ -691,6 +691,7 @@ namespace SabreTools.RedumpLib /// String representation of the media, including layer specification internal static string? GetFixedMediaType(MediaType? mediaType, string? picIdentifier, long? size, long? layerbreak, long? layerbreak2, long? layerbreak3) { +#pragma warning disable IDE0010 switch (mediaType) { case MediaType.DVD: @@ -732,6 +733,7 @@ namespace SabreTools.RedumpLib default: return mediaType.LongName(); } +#pragma warning restore IDE0010 } /// diff --git a/SabreTools.RedumpLib/Validator.cs b/SabreTools.RedumpLib/Validator.cs index cec2fd3..376fe73 100644 --- a/SabreTools.RedumpLib/Validator.cs +++ b/SabreTools.RedumpLib/Validator.cs @@ -19,6 +19,7 @@ namespace SabreTools.RedumpLib if (info.CommonDiscInfo.Media == null || info.SizeAndChecksums == default) return; +#pragma warning disable IDE0010 switch (info.CommonDiscInfo.Media) { case DiscType.DVD5: @@ -73,6 +74,7 @@ namespace SabreTools.RedumpLib default: break; } +#pragma warning restore IDE0010 } /// @@ -82,7 +84,7 @@ namespace SabreTools.RedumpLib /// Query string to attempt to search for /// True to filter forward slashes, false otherwise /// All disc IDs for the given query, null on error - public async static Task?> ListSearchResults(RedumpClient rc, string? query, bool filterForwardSlashes = true) + public static async Task?> ListSearchResults(RedumpClient rc, string? query, bool filterForwardSlashes = true) { // If there is an invalid query if (string.IsNullOrEmpty(query)) @@ -130,7 +132,7 @@ namespace SabreTools.RedumpLib /// Existing SubmissionInfo object to fill /// SHA-1 hash to check against /// List of found values, if possible - public async static Task?> ValidateSingleTrack(RedumpClient rc, SubmissionInfo info, string? sha1) + public static async Task?> ValidateSingleTrack(RedumpClient rc, SubmissionInfo info, string? sha1) { // Get all matching IDs for the track var newIds = await ListSearchResults(rc, sha1); @@ -158,7 +160,7 @@ namespace SabreTools.RedumpLib /// RedumpClient for making the connection /// Existing SubmissionInfo object to fill /// List of found values, if possible - public async static Task?> ValidateUniversalHash(RedumpClient rc, SubmissionInfo info) + public static async Task?> ValidateUniversalHash(RedumpClient rc, SubmissionInfo info) { // If we don't have special fields if (info.CommonDiscInfo.CommentsSpecialFields == null) @@ -203,7 +205,7 @@ namespace SabreTools.RedumpLib /// Redump disc ID to retrieve /// Local count of tracks for the current disc /// True if the track count matches, false otherwise - public async static Task ValidateTrackCount(RedumpClient rc, int id, int localCount) + public static async Task ValidateTrackCount(RedumpClient rc, int id, int localCount) { // If we can't pull the remote data, we can't match string? discData = await rc.DownloadSingleSiteID(id); diff --git a/SabreTools.RedumpLib/Web/CookieWebClient.cs b/SabreTools.RedumpLib/Web/CookieWebClient.cs index bd51443..2c27d27 100644 --- a/SabreTools.RedumpLib/Web/CookieWebClient.cs +++ b/SabreTools.RedumpLib/Web/CookieWebClient.cs @@ -1,7 +1,6 @@ using System; using System.Net; -#pragma warning disable SYSLIB0014 // 'WebClient.WebClient()' is obsolete namespace SabreTools.RedumpLib.Web { internal class CookieWebClient : WebClient diff --git a/SabreTools.RedumpLib/Web/RedumpClient.cs b/SabreTools.RedumpLib/Web/RedumpClient.cs index b80175a..9126b5c 100644 --- a/SabreTools.RedumpLib/Web/RedumpClient.cs +++ b/SabreTools.RedumpLib/Web/RedumpClient.cs @@ -77,7 +77,7 @@ namespace SabreTools.RedumpLib.Web /// /// Validate supplied credentials /// - public async static Task ValidateCredentials(string username, string password) + public static async Task ValidateCredentials(string username, string password) { // If options are invalid or we're missing something key, just return if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))