From e59bc38221d3ee973fc4b991234d959182f6e502 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 4 Oct 2023 17:34:37 +0100 Subject: [PATCH] Redo Reformat and cleanup. Rider EAP was having a bug interpreting .editorconfig that didn't generate the code style as we wanted. This is now done with Rider-stable. --- .editorconfig | 6 +++++- ArrayFill.cs | 5 ++++- DateHandlers.cs | 16 +++++++--------- Marshal.cs | 25 ++++++++++++------------- StringHandlers.cs | 6 ++---- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.editorconfig b/.editorconfig index 71a05170a..103a5d927 100644 --- a/.editorconfig +++ b/.editorconfig @@ -83,7 +83,7 @@ resharper_braces_for_ifelse resharper_braces_for_while = required_for_multiline resharper_builtin_type_apply_to_native_integer = false resharper_constructor_or_destructor_body = expression_body -resharper_csharp_align_first_arg_by_paren = false +resharper_csharp_align_first_arg_by_paren = true resharper_csharp_empty_block_style = together_same_line resharper_csharp_place_comments_at_first_column = true resharper_csharp_prefer_qualified_reference = false @@ -108,6 +108,7 @@ resharper_int_align_enum_initializers resharper_int_align_eq = true resharper_keep_existing_embedded_arrangement = false resharper_keep_existing_initializer_arrangement = false +resharper_keep_existing_linebreaks = false resharper_keep_existing_list_patterns_arrangement = false resharper_keep_existing_property_patterns_arrangement = false resharper_keep_existing_switch_expression_arrangement = false @@ -125,6 +126,7 @@ resharper_outdent_statement_labels resharper_parentheses_redundancy_style = remove resharper_place_attribute_on_same_line = false resharper_place_simple_embedded_statement_on_same_line = false +resharper_place_simple_initializer_on_single_line = false resharper_qualified_using_at_nested_scope = true resharper_show_autodetect_configure_formatting_tip = false resharper_simple_block_style = on_single_line @@ -146,6 +148,8 @@ resharper_use_indent_from_vs resharper_wrap_after_dot_in_method_calls = true resharper_wrap_base_clause_style = chop_if_long resharper_wrap_braced_init_list_style = chop_if_long +resharper_wrap_chained_binary_expressions = chop_if_long +resharper_wrap_chained_method_calls = chop_if_long resharper_wrap_ctor_initializer_style = chop_if_long resharper_wrap_lines = true resharper_xmldoc_attribute_indent = align_by_first_attribute diff --git a/ArrayFill.cs b/ArrayFill.cs index ee3e9e1f0..cbac721e8 100644 --- a/ArrayFill.cs +++ b/ArrayFill.cs @@ -35,7 +35,10 @@ public static partial class ArrayHelpers /// Array /// Value /// Array type - public static void ArrayFill(T[] destinationArray, T value) => ArrayFill(destinationArray, new[] { value }); + public static void ArrayFill(T[] destinationArray, T value) => ArrayFill(destinationArray, new[] + { + value + }); /// Fills an array with the contents of the specified array /// Array diff --git a/DateHandlers.cs b/DateHandlers.cs index fc9073346..ba80926df 100644 --- a/DateHandlers.cs +++ b/DateHandlers.cs @@ -215,9 +215,8 @@ public static class DateHandlers int day = (dateRecord & 0x01F0) >> 4; int month = dateRecord & 0x000F; - AaruConsole.DebugWriteLine(PASCAL_MODULE_NAME, - "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", dateRecord, year, month, - day); + AaruConsole.DebugWriteLine(PASCAL_MODULE_NAME, "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", + dateRecord, year, month, day); return new DateTime(year, month, day); } @@ -235,11 +234,11 @@ public static class DateHandlers int minute = (time & 0x7E0) >> 5; int second = (time & 0x1F) * 2; - AaruConsole.DebugWriteLine(DOS_MODULE_NAME, "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", date, - year, month, day); + AaruConsole.DebugWriteLine(DOS_MODULE_NAME, "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", date, year, + month, day); - AaruConsole.DebugWriteLine(DOS_MODULE_NAME, "time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", - time, hour, minute, second); + AaruConsole.DebugWriteLine(DOS_MODULE_NAME, "time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", time, + hour, minute, second); DateTime dosDate; @@ -326,8 +325,7 @@ public static class DateHandlers /// .NET DateTime public static DateTime Os9ToDateTime(byte[] date) { - if(date == null || - date.Length != 3 && date.Length != 5) + if(date == null || date.Length != 3 && date.Length != 5) return DateTime.MinValue; DateTime os9Date; diff --git a/Marshal.cs b/Marshal.cs index 682451675..7791e2332 100644 --- a/Marshal.cs +++ b/Marshal.cs @@ -326,20 +326,22 @@ public static class Marshal var flt = (float)(fi.GetValue(str) ?? default(float)); byte[] flt_b = BitConverter.GetBytes(flt); - fi.SetValue(str, BitConverter.ToSingle(new[] { flt_b[3], flt_b[2], flt_b[1], flt_b[0] }, 0)); + fi.SetValue(str, BitConverter.ToSingle(new[] + { + flt_b[3], flt_b[2], flt_b[1], flt_b[0] + }, 0)); } else if(fi.FieldType == typeof(double)) { var dbl = (double)(fi.GetValue(str) ?? default(double)); byte[] dbl_b = BitConverter.GetBytes(dbl); - fi.SetValue( - str, - BitConverter.ToDouble( - new[] { dbl_b[7], dbl_b[6], dbl_b[5], dbl_b[4], dbl_b[3], dbl_b[2], dbl_b[1], dbl_b[0] }, 0)); + fi.SetValue(str, BitConverter.ToDouble(new[] + { + dbl_b[7], dbl_b[6], dbl_b[5], dbl_b[4], dbl_b[3], dbl_b[2], dbl_b[1], dbl_b[0] + }, 0)); } - else if(fi.FieldType == typeof(byte) || - fi.FieldType == typeof(sbyte)) + else if(fi.FieldType == typeof(byte) || fi.FieldType == typeof(sbyte)) { // Do nothing, can't byteswap them! } @@ -349,8 +351,7 @@ public static class Marshal } // TODO: Swap arrays - else if(fi.FieldType.IsValueType && - fi.FieldType is { IsEnum: false, IsArray: false }) + else if(fi.FieldType.IsValueType && fi.FieldType is { IsEnum: false, IsArray: false }) { object obj = fi.GetValue(str); object strc = SwapStructureMembersEndian(obj); @@ -398,8 +399,7 @@ public static class Marshal } // TODO: Swap arrays - else if(fi.FieldType.IsValueType && - fi.FieldType is { IsEnum: false, IsArray: false }) + else if(fi.FieldType.IsValueType && fi.FieldType is { IsEnum: false, IsArray: false }) { object obj = fi.GetValue(str); object strc = SwapStructureMembersEndianPdp(obj); @@ -446,8 +446,7 @@ public static class Marshal var off = 0; - if(hex[0] == '0' && - (hex[1] == 'x' || hex[1] == 'X')) + if(hex[0] == '0' && (hex[1] == 'x' || hex[1] == 'X')) off = 2; outBuf = new byte[(hex.Length - off) / 2]; diff --git a/StringHandlers.cs b/StringHandlers.cs index b7077a833..aa9bc4c24 100644 --- a/StringHandlers.cs +++ b/StringHandlers.cs @@ -62,8 +62,7 @@ public static class StringHandlers { if(twoBytes) { - if(i + 1 < cString.Length && - cString[i + 1] == 0) + if(i + 1 < cString.Length && cString[i + 1] == 0) { len++; @@ -160,8 +159,7 @@ public static class StringHandlers byte compId = dstring[0]; var temp = ""; - if(compId != 8 && - compId != 16) + if(compId != 8 && compId != 16) return null; for(var byteIndex = 1; byteIndex < dstring.Length;)