From c816f81948652148dadb4db1a36b407575656664 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R." Date: Sun, 11 May 2025 08:20:41 +0200 Subject: [PATCH] Initialize issues branch --- .editorconfig | 34 -- .gitignore | 27 -- .idea/.idea.CsvView/.idea/.gitignore | 13 - .idea/.idea.CsvView/.idea/avalonia.xml | 11 - .idea/.idea.CsvView/.idea/encodings.xml | 4 - .idea/.idea.CsvView/.idea/indexLayout.xml | 8 - .idea/.idea.CsvView/.idea/vcs.xml | 6 - CsvLib.Tests/ByteArraySearcherTests.cs | 80 ----- CsvLib.Tests/CsvFieldIndexerTests.cs | 344 -------------------- CsvLib.Tests/CsvLib.Tests.csproj | 29 -- CsvLib.Tests/CsvParserTest.cs | 175 ----------- CsvLib.Tests/Usings.cs | 2 - CsvLib/BufferedTextReader.cs | 52 --- CsvLib/ByteArraySearcher.cs | 38 --- CsvLib/CsvFieldIndexer.cs | 365 ---------------------- CsvLib/CsvLib.csproj | 9 - CsvLib/CsvParser.cs | 104 ------ CsvView.sln | 42 --- CsvView.sln.DotSettings | 5 - CsvView/App.axaml | 10 - CsvView/App.axaml.cs | 23 -- CsvView/CsvView.csproj | 23 -- CsvView/MainWindow.axaml | 42 --- CsvView/MainWindow.axaml.cs | 188 ----------- CsvView/Program.cs | 21 -- CsvView/app.manifest | 18 -- LICENSE.txt | 21 -- README.md | 36 --- issues/.keep | 0 29 files changed, 1730 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .gitignore delete mode 100644 .idea/.idea.CsvView/.idea/.gitignore delete mode 100644 .idea/.idea.CsvView/.idea/avalonia.xml delete mode 100644 .idea/.idea.CsvView/.idea/encodings.xml delete mode 100644 .idea/.idea.CsvView/.idea/indexLayout.xml delete mode 100644 .idea/.idea.CsvView/.idea/vcs.xml delete mode 100644 CsvLib.Tests/ByteArraySearcherTests.cs delete mode 100644 CsvLib.Tests/CsvFieldIndexerTests.cs delete mode 100644 CsvLib.Tests/CsvLib.Tests.csproj delete mode 100644 CsvLib.Tests/CsvParserTest.cs delete mode 100644 CsvLib.Tests/Usings.cs delete mode 100644 CsvLib/BufferedTextReader.cs delete mode 100644 CsvLib/ByteArraySearcher.cs delete mode 100644 CsvLib/CsvFieldIndexer.cs delete mode 100644 CsvLib/CsvLib.csproj delete mode 100644 CsvLib/CsvParser.cs delete mode 100644 CsvView.sln delete mode 100644 CsvView.sln.DotSettings delete mode 100644 CsvView/App.axaml delete mode 100644 CsvView/App.axaml.cs delete mode 100644 CsvView/CsvView.csproj delete mode 100644 CsvView/MainWindow.axaml delete mode 100644 CsvView/MainWindow.axaml.cs delete mode 100644 CsvView/Program.cs delete mode 100644 CsvView/app.manifest delete mode 100644 LICENSE.txt delete mode 100644 README.md create mode 100644 issues/.keep diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 6e09127..0000000 --- a/.editorconfig +++ /dev/null @@ -1,34 +0,0 @@ - -[*] - -# 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/.gitignore b/.gitignore deleted file mode 100644 index 9b2de5b..0000000 --- a/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -#ignorar miniaturas creadas por windows -Thumbs.db -#Ignorar archivos construidos por Visual Studio -*.obj -*.exe -*.pdb -*.user -*.aps -*.pch -*.vspscc -*_i.c -*_p.c -*.ncb -*.suo -*.tlb -*.tlh -*.bak -*.cache -*.ilk -*.log -[Bb]in -[Dd]ebug*/ -*.lib -*.sbr -obj/ -[Rr]elease*/ -_ReSharper*/ diff --git a/.idea/.idea.CsvView/.idea/.gitignore b/.idea/.idea.CsvView/.idea/.gitignore deleted file mode 100644 index d363ae6..0000000 --- a/.idea/.idea.CsvView/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/projectSettingsUpdater.xml -/.idea.CsvView.iml -/contentModel.xml -/modules.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.idea.CsvView/.idea/avalonia.xml b/.idea/.idea.CsvView/.idea/avalonia.xml deleted file mode 100644 index 07fc4bd..0000000 --- a/.idea/.idea.CsvView/.idea/avalonia.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/.idea.CsvView/.idea/encodings.xml b/.idea/.idea.CsvView/.idea/encodings.xml deleted file mode 100644 index df87cf9..0000000 --- a/.idea/.idea.CsvView/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.CsvView/.idea/indexLayout.xml b/.idea/.idea.CsvView/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/.idea/.idea.CsvView/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.CsvView/.idea/vcs.xml b/.idea/.idea.CsvView/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/.idea.CsvView/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/CsvLib.Tests/ByteArraySearcherTests.cs b/CsvLib.Tests/ByteArraySearcherTests.cs deleted file mode 100644 index 0eea1ed..0000000 --- a/CsvLib.Tests/ByteArraySearcherTests.cs +++ /dev/null @@ -1,80 +0,0 @@ - -namespace CvsLib.Tests; - -public class ByteArraySearcherTests -{ - [Fact] - public void Contains__EmptyNeedle_ReturnsTrue() - { - // --- Arrange - byte[] haystack = [1, 2, 3, 4, 5,]; - byte[] needle = []; - ByteArraySearcher searcher = new(needle); - - // --- Act - bool result = searcher.Contains(haystack); - - // --- Assert - Assert.True(result); - } - - [Fact] - public void Contains__NeedleAtBeginning_ReturnsTrue() - { - // --- Arrange - byte[] haystack = [1, 2, 3, 4, 5,]; - byte[] needle = [1, 2, 3,]; - ByteArraySearcher searcher = new(needle); - - // --- Act - bool result = searcher.Contains(haystack); - - // --- Assert - Assert.True(result); - } - - [Fact] - public void Contains__NeedleInMiddle_ReturnsTrue() - { - // --- Arrange - byte[] haystack = [1, 2, 3, 4, 5,]; - byte[] needle = [3, 4,]; - ByteArraySearcher searcher = new(needle); - - // --- Act - bool result = searcher.Contains(haystack); - - // --- Assert - Assert.True(result); - } - - [Fact] - public void Contains__NeedleAtEnd_ReturnsTrue() - { - // --- Arrange - byte[] haystack = [1, 2, 3, 4, 5,]; - byte[] needle = [4, 5,]; - ByteArraySearcher searcher = new(needle); - - // --- Act - bool result = searcher.Contains(haystack); - - // --- Assert - Assert.True(result); - } - - [Fact] - public void Contains__NeedleNotPresent_ReturnsFalse() - { - // --- Arrange - byte[] haystack = [1, 2, 3, 4, 5,]; - byte[] needle = [5, 6, 7,]; - ByteArraySearcher searcher = new(needle); - - // --- Act - bool result = searcher.Contains(haystack); - - // --- Assert - Assert.False(result); - } -} diff --git a/CsvLib.Tests/CsvFieldIndexerTests.cs b/CsvLib.Tests/CsvFieldIndexerTests.cs deleted file mode 100644 index ae84539..0000000 --- a/CsvLib.Tests/CsvFieldIndexerTests.cs +++ /dev/null @@ -1,344 +0,0 @@ -using System.Text; - -namespace CvsLib.Tests; - -public class CsvFieldIndexerTests -{ - #region GenerateIndex - - [Fact] - public void GenerateIndex__Empty() - { - // --- Arrange - StringReader sr = new(string.Empty); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Single(indexer.Index); - - Assert.Equal(0, indexer.Index[0]); - Assert.Empty(indexer.FieldIndex); - } - - [Fact] - public void GenerateIndex__PlainText__OneRow() - { - // --- Arrange - StringReader sr = new("Hello World"); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Equal(2, indexer.Index.Count); - Assert.Equal(0, indexer.Index[0]); - Assert.Equal(12, indexer.Index[1]); - - Assert.Single(indexer.FieldIndex); - Assert.Equal(0, indexer.FieldIndex[0][0]); - Assert.Equal(10, indexer.FieldIndex[0][1]); - } - - [Fact] - public void GenerateIndex__TwoLinesOfPainText__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - Hello World - Hello World - """); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Equal(3, indexer.Index.Count); - Assert.Equal(0, indexer.Index[0]); - Assert.Equal(12, indexer.Index[1]); - Assert.Equal(24, indexer.Index[2]); - - Assert.Equal(2, indexer.FieldIndex.Count); - Assert.Equal(2, indexer.FieldIndex[0].Count); - Assert.Equal(0, indexer.FieldIndex[0][0]); - Assert.Equal(10, indexer.FieldIndex[0][1]); - Assert.Equal(2, indexer.FieldIndex[1].Count); - Assert.Equal(12, indexer.FieldIndex[1][0]); - Assert.Equal(22, indexer.FieldIndex[1][1]); - } - - [Fact] - public void GenerateIndex__TwoLinesOfQuotedText__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - "Hello World" - "Hello World" - """); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Equal(3, indexer.Index.Count); - Assert.Equal(0, indexer.Index[0]); - Assert.Equal(14, indexer.Index[1]); - Assert.Equal(28, indexer.Index[2]); - - Assert.Equal(2, indexer.FieldIndex.Count); - Assert.Equal(2, indexer.FieldIndex[0].Count); - Assert.Equal(1, indexer.FieldIndex[0][0]); - Assert.Equal(11, indexer.FieldIndex[0][1]); - Assert.Equal(2, indexer.FieldIndex[1].Count); - Assert.Equal(15, indexer.FieldIndex[1][0]); - Assert.Equal(25, indexer.FieldIndex[1][1]); - } - - [Fact] - public void GenerateIndex__TwoLinesWithTwoQuotedColumns__TwoRowsTwoFields() - { - // --- Arrange - StringReader sr = new( - """ - "Hello","World" - "Hello","World" - """); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Equal(3, indexer.Index.Count); - Assert.Equal(0, indexer.Index[0]); - Assert.Equal(16, indexer.Index[1]); - Assert.Equal(32, indexer.Index[2]); - - Assert.Equal(2, indexer.FieldIndex.Count); - Assert.Equal(4, indexer.FieldIndex[0].Count); - Assert.Equal(1, indexer.FieldIndex[0][0]); - Assert.Equal(5, indexer.FieldIndex[0][1]); - Assert.Equal(9, indexer.FieldIndex[0][2]); - Assert.Equal(13, indexer.FieldIndex[0][3]); - Assert.Equal(4, indexer.FieldIndex[1].Count); - Assert.Equal(17, indexer.FieldIndex[1][0]); - Assert.Equal(21, indexer.FieldIndex[1][1]); - Assert.Equal(25, indexer.FieldIndex[1][2]); - Assert.Equal(29, indexer.FieldIndex[1][3]); - } - - [Fact] - public void GenerateIndex__TwoLinesWithOneQuotedColumnsWithEscapedQuotes__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - "Hello \"World\"" - "Hello \"World\"" - """); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Equal(3, indexer.Index.Count); - Assert.Equal(0, indexer.Index[0]); - Assert.Equal(18, indexer.Index[1]); - Assert.Equal(36, indexer.Index[2]); - - Assert.Equal(2, indexer.FieldIndex.Count); - Assert.Equal(2, indexer.FieldIndex[0].Count); - Assert.Equal(1, indexer.FieldIndex[0][0]); - Assert.Equal(15, indexer.FieldIndex[0][1]); - Assert.Equal(2, indexer.FieldIndex[1].Count); - Assert.Equal(19, indexer.FieldIndex[1][0]); - Assert.Equal(33, indexer.FieldIndex[1][1]); - } - - [Fact] - public void GenerateIndex__TwoLinesWithOneQuotedColumnsWithManyEscapedQuotes__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - "Hello \"World\"" - "Hello \"World\"\"\"" - """); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Equal(3, indexer.Index.Count); - Assert.Equal(0, indexer.Index[0]); - Assert.Equal(18, indexer.Index[1]); - Assert.Equal(40, indexer.Index[2]); - - Assert.Equal(2, indexer.FieldIndex.Count); - Assert.Equal(2, indexer.FieldIndex[0].Count); - Assert.Equal(1, indexer.FieldIndex[0][0]); - Assert.Equal(15, indexer.FieldIndex[0][1]); - Assert.Equal(2, indexer.FieldIndex[1].Count); - Assert.Equal(19, indexer.FieldIndex[1][0]); - Assert.Equal(37, indexer.FieldIndex[1][1]); - } - - [Fact] - public void GenerateIndex__TwoLinesWithTwoQuotedColumnsWithUnicode__TwoRowsTwoFields() - { - // --- Arrange - StringReader sr = new( - """ - "Hélló","Wórld" - "Hélló","Wórld" - """); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Assert - - Assert.Equal(3, indexer.Index.Count); - Assert.Equal(0, indexer.Index[0]); - Assert.Equal(19, indexer.Index[1]); - Assert.Equal(38, indexer.Index[2]); - - Assert.Equal(2, indexer.FieldIndex.Count); - Assert.Equal(4, indexer.FieldIndex[0].Count); - Assert.Equal(1, indexer.FieldIndex[0][0]); - Assert.Equal(7, indexer.FieldIndex[0][1]); - Assert.Equal(11, indexer.FieldIndex[0][2]); - Assert.Equal(16, indexer.FieldIndex[0][3]); - Assert.Equal(4, indexer.FieldIndex[1].Count); - Assert.Equal(20, indexer.FieldIndex[1][0]); - Assert.Equal(26, indexer.FieldIndex[1][1]); - Assert.Equal(30, indexer.FieldIndex[1][2]); - Assert.Equal(35, indexer.FieldIndex[1][3]); - } - - #endregion GenerateIndex - - #region Search - - [Fact] - public void Search__TwoLinesWithTwoQuotedColumns__OneIndexFirstRow() - { - // --- Arrange - const string strText = - """ - "Hello","test" - "Hello","World" - """; - StringReader sr = new(strText); - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Act - byte[] bText = Encoding.UTF8.GetBytes(strText); - MemoryStream ms = new(bText); - List indexes = indexer.Search(ms, "test"); - - // --- Assert - - Assert.Single(indexes); - Assert.Equal(0, indexes[0]); - } - - [Fact] - public void Search__TwoLinesWithTwoQuotedColumns__OneIndexSecondRow() - { - // --- Arrange - const string strText = - """ - "Hello","World" - "Hello","test" - """; - StringReader sr = new(strText); - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Act - byte[] bText = Encoding.UTF8.GetBytes(strText); - MemoryStream ms = new(bText); - List indexes = indexer.Search(ms, "test"); - - // --- Assert - - Assert.Single(indexes); - Assert.Equal(16, indexes[0]); - } - - [Fact] - public void Search__TwoLinesWithTwoQuotedColumnsTwoMatches__OneIndexSecondRow() - { - // --- Arrange - const string strText = - """ - "Hello","World" - "test","test" - """; - StringReader sr = new(strText); - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - - // --- Act - byte[] bText = Encoding.UTF8.GetBytes(strText); - MemoryStream ms = new(bText); - List indexes = indexer.Search(ms, "test"); - - // --- Assert - - Assert.Single(indexes); - Assert.Equal(16, indexes[0]); - } - - #endregion Search - - #region Save & Load - - [Fact] - public void Save__TwoLinesWithTwoQuotedColumnsTwoMatchesSave__LoadsCorrectly() - { - // --- Arrange - StringReader sr = new( - """ - "Hélló","Wórld" - "Hélló","Wórld" - """); - - // --- Act - CsvFieldIndexer indexer = new(); - indexer.GenerateIndex(sr); - MemoryStream stream = new(); - indexer.Save(stream); - byte[] savedData = stream.ToArray(); - CsvFieldIndexer indexer2 = new(); - MemoryStream stream2 = new(savedData); - bool loadResult = indexer2.Load(stream2); - - // --- Assert - Assert.True(loadResult); - Assert.Equal(indexer.Index, indexer2.Index); - Assert.Equal(indexer.FieldIndex, indexer2.FieldIndex); - } - - #endregion Save & Load - -} diff --git a/CsvLib.Tests/CsvLib.Tests.csproj b/CsvLib.Tests/CsvLib.Tests.csproj deleted file mode 100644 index 12ab80d..0000000 --- a/CsvLib.Tests/CsvLib.Tests.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - net8.0 - enable - enable - CvsLib.Tests - - false - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/CsvLib.Tests/CsvParserTest.cs b/CsvLib.Tests/CsvParserTest.cs deleted file mode 100644 index b63358b..0000000 --- a/CsvLib.Tests/CsvParserTest.cs +++ /dev/null @@ -1,175 +0,0 @@ - -namespace CvsLib.Tests; - -public class CsvParserTest -{ - #region Parse - - [Fact] - public void Parse__Empty__Empty() - { - // --- Arrange - StringReader sr = new(string.Empty); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Empty(parser.Data); - } - - [Fact] - public void Parse__PlainText__OneRowOneColumn() - { - // --- Arrange - StringReader sr = new("Hello World"); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Single(parser.Data); - Assert.Single(parser.Data[0]); - Assert.Equal("Hello World", parser.Data[0][0]); - } - - [Fact] - public void Parse__TwoLinesOfPainText__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - Hello World - Hello World - """); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Equal(2, parser.Data.Count); - Assert.Single(parser.Data[0]); - Assert.Equal("Hello World", parser.Data[0][0]); - Assert.Single(parser.Data[1]); - Assert.Equal("Hello World", parser.Data[1][0]); - } - - [Fact] - public void Parse__TwoLinesOfQuotedText__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - "Hello World" - "Hello World" - """); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Equal(2, parser.Data.Count); - Assert.Single(parser.Data[0]); - Assert.Equal("Hello World", parser.Data[0][0]); - Assert.Single(parser.Data[1]); - Assert.Equal("Hello World", parser.Data[1][0]); - } - - [Fact] - public void Parse__TwoLinesWithTwoQuotedColumns__TwoRowsTwoFields() - { - // --- Arrange - StringReader sr = new( - """ - "Hello","World" - "Hello","World" - """); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Equal(2, parser.Data.Count); - Assert.Equal(2, parser.Data[0].Count); - Assert.Equal("Hello", parser.Data[0][0]); - Assert.Equal("World", parser.Data[0][1]); - Assert.Equal(2, parser.Data[1].Count); - Assert.Equal("Hello", parser.Data[1][0]); - Assert.Equal("World", parser.Data[1][1]); - } - - [Fact] - public void Parse__TwoLinesWithOneQuotedColumnsWithEscapedQuotes__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - "Hello \"World\"" - "Hello \"World\"" - """); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Equal(2, parser.Data.Count); - Assert.Single(parser.Data[0]); - Assert.Equal("Hello \"World\"", parser.Data[0][0]); - Assert.Single(parser.Data[1]); - Assert.Equal("Hello \"World\"", parser.Data[1][0]); - } - - [Fact] - public void Parse__TwoLinesWithOneQuotedColumnsWithManyEscapedQuotes__TwoRows() - { - // --- Arrange - StringReader sr = new( - """ - "Hello \"World\"" - "Hello \"World\"\"\"" - """); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Equal(2, parser.Data.Count); - Assert.Single(parser.Data[0]); - Assert.Equal("Hello \"World\"", parser.Data[0][0]); - Assert.Single(parser.Data[1]); - Assert.Equal("Hello \"World\"\"\"", parser.Data[1][0]); - } - - [Fact] - public void GenerateIndex__TwoLinesWithTwoQuotedColumnsWithUnicode__TwoRowsTwoFields() - { - // --- Arrange - StringReader sr = new( - """ - "Hélló","Wórld" - "Hélló","Wórld" - """); - - // --- Act - CsvParser parser = new(); - parser.Parse(sr); - - // --- Assert - Assert.Equal(2, parser.Data.Count); - Assert.Equal(2, parser.Data[0].Count); - Assert.Equal("Hélló", parser.Data[0][0]); - Assert.Equal("Wórld", parser.Data[0][1]); - Assert.Equal(2, parser.Data[1].Count); - Assert.Equal("Hélló", parser.Data[1][0]); - Assert.Equal("Wórld", parser.Data[1][1]); - } - - #endregion Parse -} diff --git a/CsvLib.Tests/Usings.cs b/CsvLib.Tests/Usings.cs deleted file mode 100644 index 7df6756..0000000 --- a/CsvLib.Tests/Usings.cs +++ /dev/null @@ -1,2 +0,0 @@ -global using Xunit; -global using CsvLib; \ No newline at end of file diff --git a/CsvLib/BufferedTextReader.cs b/CsvLib/BufferedTextReader.cs deleted file mode 100644 index f7f1e5a..0000000 --- a/CsvLib/BufferedTextReader.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.IO; -using System.Text; - -namespace CsvLib; - -public class BufferedTextReader : TextReader -{ - private readonly TextReader _baseReader; - private readonly StringBuilder _sbBuffer = new(); - - private readonly Encoding _currentEncoding = Encoding.Default; - - public BufferedTextReader(TextReader baseReader) - { - _baseReader = baseReader; - if (baseReader is StreamReader streamReader) - { - _currentEncoding = streamReader.CurrentEncoding; - } - } - - public override int Read() - { - int read = _baseReader.Read(); - if (read > 127) - { - int count = _currentEncoding.GetByteCount(((char)read).ToString()); - Position += count; - } - else - { - Position++; - } - if (read != -1) - { - _sbBuffer.Append((char)read); - } - return read; - } - - public int Position { get; private set; } - - public string GetBuffer() - { - return _sbBuffer.ToString(); - } - - public void CleanBuffer() - { - _sbBuffer.Clear(); - } -} \ No newline at end of file diff --git a/CsvLib/ByteArraySearcher.cs b/CsvLib/ByteArraySearcher.cs deleted file mode 100644 index 5b12aaa..0000000 --- a/CsvLib/ByteArraySearcher.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace CsvLib; - -public class ByteArraySearcher -{ - private readonly byte[] _needle; - - public ByteArraySearcher(byte[] needle) - { - _needle = needle; - } - - public bool Contains(byte[] haystack) - { - return Contains(haystack, haystack.Length); - } - - public bool Contains(byte[] haystack, int length) - { - // TODO: Implement the Boyer-Moore algorithm - for (int i = 0; i <= length - _needle.Length; i++) - { - bool found = true; - - for (int j = 0; j < _needle.Length; j++) - { - if (haystack[i + j] != _needle[j]) - { - found = false; - break; - } - } - - if (found) { return true; } - } - - return false; - } -} diff --git a/CsvLib/CsvFieldIndexer.cs b/CsvLib/CsvFieldIndexer.cs deleted file mode 100644 index b7e1e03..0000000 --- a/CsvLib/CsvFieldIndexer.cs +++ /dev/null @@ -1,365 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace CsvLib; - -public class CsvFieldIndexer -{ - #region Declarations - - private const byte FileFormatVersion = 1; - - private bool _insideString; - - private Encoding _currentEncoding = Encoding.Default; - - private readonly char _separator; - private readonly char _quoteChar; - private readonly char _escapeChar; - - #endregion Declarations - - #region Life cycle - - public CsvFieldIndexer(char separator = ',', char quoteChar = '"', char escapeChar = '\\') - { - _separator = separator; - _quoteChar = quoteChar; - _escapeChar = escapeChar; - } - - #endregion Life cycle - - #region Properties - - private List _index = new(); - - public List Index { get { return _index; } } - - private List> _fieldIndex = new(); - - public List> FieldIndex { get { return _fieldIndex; } } - - #endregion Properties - - #region Parsing - - private void DummyParser(string line) - { - for (int i = 0; i < line.Length; i++) - { - char c = line[i]; - if (c == _separator && _insideString == false) - { - continue; - } - if (c == _quoteChar && _insideString == false) - { - _insideString = true; - continue; - } - if (c == _quoteChar && _insideString) - { - _insideString = false; - continue; - } - if (c == _escapeChar && _insideString) - { - i++; - } - } - } - - private List ParseLineIndex(string line, long lineOffset) - { - List fieldPositions = new(); - long? fieldStartPosition = null; - long? fieldEndPosition = null; - int unicodeDelta = 0; - for (int i = 0; i < line.Length; i++) - { - char c = line[i]; - if (c == _separator && _insideString == false) - { - if (fieldStartPosition != null && fieldEndPosition != null) - { - fieldPositions.Add((long)fieldStartPosition); - fieldPositions.Add((long)fieldEndPosition); - } - fieldStartPosition = null; - fieldEndPosition = null; - } - else if (c == _quoteChar && _insideString == false) - { - _insideString = true; - } - else if (c == _quoteChar && _insideString) - { - _insideString = false; - } - else if (c == _escapeChar && _insideString) - { - i++; - long absolutePosition = lineOffset + i + unicodeDelta; - fieldStartPosition ??= absolutePosition; - fieldEndPosition = absolutePosition; - } - else if ((c == '\n' || c == '\r') && _insideString == false) - { - break; - } - else - { - if (c > 127) - { - unicodeDelta += _currentEncoding.GetByteCount(c.ToString()) - 1; - } - - long absolutePosition = lineOffset + i + unicodeDelta; - fieldStartPosition ??= absolutePosition; - fieldEndPosition = absolutePosition; - } - } - if (_insideString == false) - { - if (fieldStartPosition != null && fieldEndPosition != null) - { - fieldPositions.Add((long)fieldStartPosition); - fieldPositions.Add((long)fieldEndPosition); - } - } - return fieldPositions; - } - - #endregion Parsing - - #region GenerateIndex - - private void GenerateIndex(string file) - { - using FileStream stream = new(file, FileMode.Open); - using StreamReader streamReader = new(stream, Encoding.Default, true, 4096); - GenerateIndex(streamReader); - stream.Close(); - } - - public void GenerateIndex(TextReader textReader) - { - _insideString = false; - _index.Clear(); - _index.Add(0); - int idxRow = 0; - if (textReader is StreamReader streamReader) - { - _currentEncoding = streamReader.CurrentEncoding; - } - using BufferedTextReader reader = new(textReader); - while (reader.ReadLine() is { } currentLine) - { - DummyParser(currentLine); - if (_insideString) { continue; } - - string fullLine = reader.GetBuffer(); - reader.CleanBuffer(); - List fieldIndexes = ParseLineIndex(fullLine, _index[idxRow]); - _fieldIndex.Add(fieldIndexes); - - _index.Add(reader.Position); - - idxRow++; - } - } - - #endregion GenerateIndex - - #region Save - - public void Save(Stream streamOut) - { - using BinaryWriter binWriter = new(streamOut); - - binWriter.Write((byte)'C'); - binWriter.Write((byte)'S'); - binWriter.Write((byte)'V'); - - binWriter.Write(FileFormatVersion); - - binWriter.Write(_index.Count); - foreach (long currentIndex in _index) - { - binWriter.Write(currentIndex); - } - - binWriter.Write(_fieldIndex.Count); - foreach (List currentFieldIndex in _fieldIndex) - { - binWriter.Write(currentFieldIndex.Count); - foreach (long fieldIndex in currentFieldIndex) - { - binWriter.Write(fieldIndex); - } - } - } - - private void SaveFile(string indexFile) - { - if (File.Exists(indexFile)) - { - File.Delete(indexFile); - } - Stream streamOut = File.Open(indexFile, FileMode.Create); - Save(streamOut); - streamOut.Close(); - } - - #endregion Save - - #region Load - - public bool Load(Stream streamIn) - { - using BinaryReader binReader = new(streamIn); - - byte magik0 = binReader.ReadByte(); - byte magik1 = binReader.ReadByte(); - byte magik2 = binReader.ReadByte(); - if (magik0 != (byte)'C' || magik1 != (byte)'S' || magik2 != (byte)'V') { return false; } - - byte fileVersion = binReader.ReadByte(); - if (fileVersion != FileFormatVersion) { return false; } - - int numIndexes = binReader.ReadInt32(); - List tempIndex = new(numIndexes); - for (int i = 0; i < numIndexes; i++) - { - long value = binReader.ReadInt64(); - tempIndex.Add(value); - } - - int numFieldIndexes = binReader.ReadInt32(); - List> tempFieldIndex = new(numFieldIndexes); - for (int j = 0; j < numFieldIndexes; j++) - { - int numCurrentFieldIndexes = binReader.ReadInt32(); - List currentFieldIndex = new(numCurrentFieldIndexes); - for (int i = 0; i < numCurrentFieldIndexes; i++) - { - long value = binReader.ReadInt64(); - currentFieldIndex.Add(value); - } - tempFieldIndex.Add(currentFieldIndex); - } - - _index = tempIndex; - _fieldIndex = tempFieldIndex; - return true; - } - - private bool LoadFile(string indexFile) - { - if (File.Exists(indexFile) == false) - { - return false; - } - Stream streamIn = File.Open(indexFile, FileMode.Open); - try - { - if (Load(streamIn) == false) return false; - } - catch (Exception) - { - // NON NON NOM - return false; - } - finally - { - streamIn.Close(); - } - return true; - } - - public void LoadIndexOfFile(string file) - { - DateTime dtFile = File.GetCreationTime(file); - string indexFile = $"{file}.idx"; - if (File.Exists(indexFile) && File.GetCreationTime(indexFile) > dtFile) - { - if (LoadFile(indexFile)) { return; } - } - - // Generate index - DateTime dtNow = DateTime.UtcNow; - GenerateIndex(file); - TimeSpan tsGenIndex = DateTime.UtcNow - dtNow; - - // Save Index if expensive generation - if (tsGenIndex.TotalSeconds > 2) - { - SaveFile(indexFile); - } - } - - #endregion Load - - #region Search - - public List Search(Stream streamIn, string textToSearch, Action? notifyProgress = null) - { - // TODO: Use MemoryMappedFile for better IO performance - DateTime datePrevious = DateTime.UtcNow; - List newIndexes = new(); - byte[] bText = Encoding.UTF8.GetBytes(textToSearch); - ByteArraySearcher searcher = new(bText); - byte[] buffer = new byte[1024]; - for (int j = 0; j < _fieldIndex.Count; j++) - { - for (int i = 0; i < _fieldIndex[j].Count; i += 2) - { - TimeSpan tsElapsed = DateTime.UtcNow - datePrevious; - if (tsElapsed.TotalMilliseconds > 200) - { - datePrevious = DateTime.UtcNow; - notifyProgress?.Invoke(j / (float)_fieldIndex.Count); - } - - long offset = _fieldIndex[j][i]; - int length = (int)(_fieldIndex[j][i + 1] - offset) + 1; - - if (buffer.Length < length) - { - buffer = new byte[length]; - } - streamIn.Seek(offset, SeekOrigin.Begin); - int read = streamIn.Read(buffer, 0, length); - if (read != length) { throw new Exception($"Search: Expected {length} bytes, but read {read}"); } - - bool matches = searcher.Contains(buffer, length); - if (matches == false) { continue; } - - newIndexes.Add(_index[j]); - break; - } - } - - return newIndexes; - } - - public List SearchFile(string fileName, string textToSearch, Action? notifyProgress = null) - { - List index; - using FileStream streamIn = new(fileName, FileMode.Open); - try - { - index = Search(streamIn, textToSearch, notifyProgress); - } - finally - { - streamIn.Close(); - } - return index; - } - - #endregion Search -} diff --git a/CsvLib/CsvLib.csproj b/CsvLib/CsvLib.csproj deleted file mode 100644 index 53bbed1..0000000 --- a/CsvLib/CsvLib.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net8.0 - 11 - enable - - - diff --git a/CsvLib/CsvParser.cs b/CsvLib/CsvParser.cs deleted file mode 100644 index 6ed5415..0000000 --- a/CsvLib/CsvParser.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace CsvLib; - -public class CsvParser -{ - private bool _insideString; - - private readonly char _separator; - private readonly char _quoteChar; - private readonly char _escapeChar; - - public CsvParser(char separator = ',', char quoteChar = '"', char escapeChar = '\\') - { - _separator = separator; - _quoteChar = quoteChar; - _escapeChar = escapeChar; - } - - private List> _data = new(); - - private List? _currentReg; - private StringBuilder? _currentCell; - - public List> Data - { - get { return _data; } - } - - private void ParseLine(string line) - { - _currentReg ??= new List(); - _currentCell ??= new StringBuilder(); - - for (int i = 0; i < line.Length; i++) - { - char c = line[i]; - if (c == _separator && _insideString == false) - { - _currentReg.Add(_currentCell.ToString()); - _currentCell.Clear(); - continue; - } - if (c == _quoteChar && _insideString == false) - { - _insideString = true; - continue; - } - if (c == _quoteChar && _insideString) - { - _insideString = false; - continue; - } - if (c == _escapeChar && _insideString) - { - i++; - if (i == line.Length) { break; } - c = line[i]; - } - - _currentCell.Append(c); - } - - - if (_insideString) - { - _currentCell.Append('\n'); - } - else - { - _currentReg.Add(_currentCell.ToString()); - _currentCell.Clear(); - _data.Add(_currentReg); - _currentReg = null; - } - } - - public void Parse(TextReader reader, int count = 0) - { - _insideString = false; - _data = new List>(); - _currentReg = null; - while (reader.ReadLine() is { } currentLine) - { - ParseLine(currentLine); - if (count > 0 && _data.Count == count) - { - break; - } - } - } - - public void ParseFile(string file, long offset = 0, int count = 0) - { - FileStream stream = new(file, FileMode.Open); - stream.Seek(offset, SeekOrigin.Begin); - using StreamReader reader = new(stream, Encoding.Default, true, 4096); - Parse(reader, count); - stream.Close(); - } - -} \ No newline at end of file diff --git a/CsvView.sln b/CsvView.sln deleted file mode 100644 index 7e87715..0000000 --- a/CsvView.sln +++ /dev/null @@ -1,42 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvLib", "CsvLib\CsvLib.csproj", "{EB0FDB60-8B9D-401C-85A8-4CF4105D5063}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvLib.Tests", "CsvLib.Tests\CsvLib.Tests.csproj", "{EC5C84D8-1CDE-4AED-9C16-6C4086A20893}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CsvView", "CsvView\CsvView.csproj", "{65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{94D4A247-9453-45F4-8552-0D106801C9F0}" - ProjectSection(SolutionItems) = preProject - README.md = README.md - LICENSE.txt = LICENSE.txt - .editorconfig = .editorconfig - .gitignore = .gitignore - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EB0FDB60-8B9D-401C-85A8-4CF4105D5063}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EB0FDB60-8B9D-401C-85A8-4CF4105D5063}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EB0FDB60-8B9D-401C-85A8-4CF4105D5063}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EB0FDB60-8B9D-401C-85A8-4CF4105D5063}.Release|Any CPU.Build.0 = Release|Any CPU - {EC5C84D8-1CDE-4AED-9C16-6C4086A20893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EC5C84D8-1CDE-4AED-9C16-6C4086A20893}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EC5C84D8-1CDE-4AED-9C16-6C4086A20893}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EC5C84D8-1CDE-4AED-9C16-6C4086A20893}.Release|Any CPU.Build.0 = Release|Any CPU - {65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {65A0A7DA-5884-4DFE-8223-C8F5DBD881A8}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/CsvView.sln.DotSettings b/CsvView.sln.DotSettings deleted file mode 100644 index 0033532..0000000 --- a/CsvView.sln.DotSettings +++ /dev/null @@ -1,5 +0,0 @@ - - True - /usr/share/dotnet/sdk/7.0.107/MSBuild.dll - 4294967293 - True \ No newline at end of file diff --git a/CsvView/App.axaml b/CsvView/App.axaml deleted file mode 100644 index 8cce478..0000000 --- a/CsvView/App.axaml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/CsvView/App.axaml.cs b/CsvView/App.axaml.cs deleted file mode 100644 index cb309aa..0000000 --- a/CsvView/App.axaml.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Markup.Xaml; - -namespace CsvView; - -public class App : Application -{ - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - - public override void OnFrameworkInitializationCompleted() - { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { - desktop.MainWindow = new MainWindow(); - } - - base.OnFrameworkInitializationCompleted(); - } -} diff --git a/CsvView/CsvView.csproj b/CsvView/CsvView.csproj deleted file mode 100644 index 4890001..0000000 --- a/CsvView/CsvView.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - WinExe - net8.0 - enable - true - app.manifest - true - - - - - - - - - - - - - - - diff --git a/CsvView/MainWindow.axaml b/CsvView/MainWindow.axaml deleted file mode 100644 index 9f43c5b..0000000 --- a/CsvView/MainWindow.axaml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - / - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CsvView/MainWindow.axaml.cs b/CsvView/MainWindow.axaml.cs deleted file mode 100644 index 580fb49..0000000 --- a/CsvView/MainWindow.axaml.cs +++ /dev/null @@ -1,188 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.Platform.Storage; -using CsvLib; - -// ReSharper disable UnusedParameter.Local - -namespace CsvView; - -public partial class MainWindow : Window -{ - public MainWindow() - { - InitializeComponent(); - RenderReg(0); - } - - private async void BtnLoad_OnClick(object? sender, RoutedEventArgs e) - { - try - { - TopLevel? topLevel = GetTopLevel(this); - if (topLevel == null) { return; } - - IReadOnlyList files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions - { - Title = "Open CSV File", - AllowMultiple = false, - FileTypeFilter = new List - { - new("CSV Files") { Patterns = ["*.csv",], }, - new("Any File") { Patterns = ["*",], }, - }, - }); - - if (files.Count <= 0) { return; } - - LoadFile(files[0].Path.LocalPath); - } - catch (Exception) - { - // ignored - } - } - - private void BtnSearch_OnClick(object? sender, RoutedEventArgs e) - { - Search(TxtSearch.Text); - } - - private void BtnFirst_OnClick(object? sender, RoutedEventArgs e) - { - RenderReg(0); - } - - private void BtnPrevious_OnClick(object? sender, RoutedEventArgs e) - { - RenderReg(_currentReg - 1); - } - - private void TxtIndex_OnTextChanged(object? sender, TextChangedEventArgs e) - { - RenderReg(int.TryParse(TxtIndex.Text, out int newReg) ? newReg : _currentReg); - } - - private void BtnNext_OnClick(object? sender, RoutedEventArgs e) - { - RenderReg(_currentReg + 1); - } - - private void BtnLast_OnClick(object? sender, RoutedEventArgs e) - { - RenderReg(_totalRegs - 1); - } - - private string _loadedFile = string.Empty; - private long _currentReg; - private int _totalRegs; - private List _index = []; - - private void LoadFile(string fileName) - { - // TODO: Loading animation - _loadedFile = fileName; - TxtFileName.Text = fileName; - - CsvFieldIndexer csvIndexer = new(); - csvIndexer.LoadIndexOfFile(_loadedFile); - _index = csvIndexer.Index; - _totalRegs = _index.Count - 1; - - RenderReg(0); - } - - private void Search(string? textToSearch) - { - if (textToSearch == null) { return; } - - // TODO: Loading animation - CsvFieldIndexer csvIndexer = new(); - csvIndexer.LoadIndexOfFile(_loadedFile); - - List newIndexes = csvIndexer.SearchFile(_loadedFile, textToSearch); - _index = newIndexes; - _totalRegs = _index.Count - 1; - - RenderReg(0, forceLoad: true); - } - - private bool _rendering; - - private void RenderReg(long currentReg, bool forceLoad = false) - { - if (_rendering) { return; } - _rendering = true; - - if (_index.Count <= 0) - { - _currentReg = -1; - BtnFirst.IsEnabled = false; - BtnPrevious.IsEnabled = false; - TxtIndex.IsReadOnly = true; - BtnNext.IsEnabled = false; - BtnLast.IsEnabled = false; - - DataContext = new MainWindowViewModel { Index = 0, Fields = [], }; - _rendering = false; - return; - } - - bool first = false; - bool last = false; - if (currentReg <= 0) - { - currentReg = 0; - first = true; - } - if (currentReg >= (_totalRegs - 1)) - { - currentReg = _totalRegs - 1; - last = true; - } - - BtnFirst.IsEnabled = (first == false); - BtnPrevious.IsEnabled = (first == false); - TxtIndex.IsReadOnly = false; - BtnNext.IsEnabled = (last == false); - BtnLast.IsEnabled = (last == false); - - if (_currentReg == currentReg && forceLoad == false) - { - _rendering = false; - return; - } - - _currentReg = currentReg; - - CsvParser csvParser = new(); - csvParser.ParseFile(_loadedFile, _index[(int)currentReg], 1); - MainWindowViewModel viewModel = new() - { - Index = (int)currentReg, - MaxIndex = _totalRegs, - Fields = csvParser.Data[0].Select(f => new FieldViewModel { Text = f, }).ToList(), - }; - - DataContext = viewModel; - - _rendering = false; - } -} - -public class FieldViewModel -{ - public string Text { get; set; } = string.Empty; -} - -public class MainWindowViewModel -{ - public int? Index { get; set; } - - public int? MaxIndex { get; set; } - - public List? Fields { get; set; } -} diff --git a/CsvView/Program.cs b/CsvView/Program.cs deleted file mode 100644 index b4b1f5d..0000000 --- a/CsvView/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Avalonia; -using System; - -namespace CsvView; - -static class Program -{ - // Initialization code. Don't use any Avalonia, third-party APIs or any - // SynchronizationContext-reliant code before AppMain is called: things aren't initialized - // yet and stuff might break. - [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); - - // Avalonia configuration, don't remove; also used by visual designer. - private static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure() - .UsePlatformDetect() - .WithInterFont() - .LogToTrace(); -} diff --git a/CsvView/app.manifest b/CsvView/app.manifest deleted file mode 100644 index 07df98d..0000000 --- a/CsvView/app.manifest +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 900b551..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2023 Valeriano Alfonso Rodriguez - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index e354028..0000000 --- a/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# CsvView -CSV file viewer, for use with large files. - -## Contributing -1. Fork it! -2. Create your feature branch: `git checkout -b my-new-feature` -3. Commit your changes: `git commit -am 'Add some feature'` -4. Push to the branch: `git push origin my-new-feature` -5. Submit a pull request :D - -## Credits -* Valeriano Alfonso Rodriguez. - -## License - - The MIT License (MIT) - - Copyright (c) 2014-2023 Valeriano Alfonso Rodriguez - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. \ No newline at end of file diff --git a/issues/.keep b/issues/.keep new file mode 100644 index 0000000..e69de29