From a66baca33da8aa7acac4bd61cfef5a4da8756878 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Tue, 1 Aug 2023 14:55:22 +0200 Subject: [PATCH] Code cleanup --- .editorconfig | 34 ++++++++++++++++++++++++++++++++++ Code/CsvIndexer.cs | 12 ++++++------ Code/CsvParser.cs | 14 +++++++------- Program.cs | 6 +++--- UI/FrmCsvViewer.cs | 8 ++++---- 5 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6e09127 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,34 @@ + +[*] + +# Microsoft .NET properties +csharp_new_line_before_members_in_object_initializers = false +csharp_preferred_modifier_order = private, protected, public, internal, file, new, override, abstract, virtual, sealed, readonly, static, extern, unsafe, volatile, async, required:suggestion +csharp_preserve_single_line_blocks = true +csharp_style_var_elsewhere = false:suggestion +csharp_style_var_for_built_in_types = false:suggestion +csharp_style_var_when_type_is_apparent = false:suggestion + +# ReSharper properties +resharper_accessor_owner_body = accessors_with_block_body +resharper_align_multiline_argument = true +resharper_align_multiline_binary_expressions_chain = false +resharper_blank_lines_after_block_statements = 0 +resharper_blank_lines_around_single_line_property = 1 +resharper_braces_for_for = required +resharper_braces_for_ifelse = not_required +resharper_braces_for_using = not_required +resharper_braces_redundant = false +resharper_csharp_blank_lines_around_invocable = 0 +resharper_csharp_insert_final_newline = true +resharper_csharp_max_line_length = 198 +resharper_csharp_remove_blank_lines_near_braces_in_declarations = false +resharper_default_internal_modifier = implicit +resharper_instance_members_qualify_declared_in = +resharper_keep_existing_enum_arrangement = false +resharper_parentheses_non_obvious_operations = none, multiplicative, additive, arithmetic, shift, bitwise_and, bitwise_exclusive_or, bitwise_inclusive_or, bitwise +resharper_parentheses_redundancy_style = remove +resharper_place_accessorholder_attribute_on_same_line = false +resharper_trailing_comma_in_multiline_lists = true +resharper_wrap_chained_binary_expressions = chop_if_long +resharper_wrap_object_and_collection_initializer_style = chop_always diff --git a/Code/CsvIndexer.cs b/Code/CsvIndexer.cs index 9423f7d..9606e39 100644 --- a/Code/CsvIndexer.cs +++ b/Code/CsvIndexer.cs @@ -7,11 +7,11 @@ namespace CsvView.Code { public class CsvIndexer { - private bool _insideString = false; + private bool _insideString; - private char _separator = ','; - private char _quoteChar = '"'; - private char _escapeChar = '\\'; + private readonly char _separator; + private readonly char _quoteChar; + private readonly char _escapeChar; public CsvIndexer(char separator = ',', char quoteChar = '"', char escapeChar = '\\') { @@ -38,7 +38,7 @@ namespace CsvView.Code _insideString = true; continue; } - if (c == _quoteChar && _insideString == true) + if (c == _quoteChar && _insideString) { _insideString = false; continue; @@ -53,7 +53,7 @@ namespace CsvView.Code private class TrackingTextReader : TextReader { - private TextReader _baseReader; + private readonly TextReader _baseReader; private int _position; public TrackingTextReader(TextReader baseReader) diff --git a/Code/CsvParser.cs b/Code/CsvParser.cs index 763d98d..d6c3274 100644 --- a/Code/CsvParser.cs +++ b/Code/CsvParser.cs @@ -6,11 +6,11 @@ namespace CsvView.Code { public class CsvParser { - private bool _insideString = false; + private bool _insideString; - private char _separator = ','; - private char _quoteChar = '"'; - private char _escapeChar = '\\'; + private readonly char _separator; + private readonly char _quoteChar; + private readonly char _escapeChar; public CsvParser(char separator = ',', char quoteChar = '"', char escapeChar = '\\') { @@ -21,8 +21,8 @@ namespace CsvView.Code private List> _data = new List>(); - private List _currentReg = null; - StringBuilder _currentCell = null; + private List _currentReg; + StringBuilder _currentCell; public List> Data { @@ -54,7 +54,7 @@ namespace CsvView.Code _insideString = true; continue; } - if (c == _quoteChar && _insideString == true) + if (c == _quoteChar && _insideString) { _insideString = false; continue; diff --git a/Program.cs b/Program.cs index 4f02bb8..5169956 100644 --- a/Program.cs +++ b/Program.cs @@ -1,8 +1,8 @@ -using CsvView.UI; -using System; +using System; using System.Windows.Forms; +using CsvView.UI; -namespace CsvView.Net +namespace CsvView { static class Program { diff --git a/UI/FrmCsvViewer.cs b/UI/FrmCsvViewer.cs index 3e126c7..a09b059 100644 --- a/UI/FrmCsvViewer.cs +++ b/UI/FrmCsvViewer.cs @@ -27,9 +27,9 @@ namespace CsvView.UI } private string _loadedFile = string.Empty; - private long _currentReg = 0; - private long _totalRegs = 0; - private List _index = null; + private long _currentReg; + private long _totalRegs; + private List _index; private void btnLoad_Click(object sender, EventArgs e) { @@ -66,7 +66,7 @@ namespace CsvView.UI return csvParser.Data[0]; } - bool _rendering = false; + bool _rendering; private void RenderReg(long currentReg) { if (_index == null || _index.Count <= 0)