diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml index 338c29c..fa8e2f4 100644 --- a/.gitea/workflows/main.yml +++ b/.gitea/workflows/main.yml @@ -17,23 +17,7 @@ on: workflow_dispatch: jobs: - linter: - strategy: - fail-fast: false - matrix: - dotnet-version: [9.0.X] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ matrix.dotnet-version }} - - name: Run linter - run: make lint - tests_linux: - needs: linter strategy: fail-fast: false matrix: diff --git a/TextParser.Tests/TextParserTests.cs b/TextParser.Tests/TextParserTests.cs index dffaa96..34f45ae 100644 --- a/TextParser.Tests/TextParserTests.cs +++ b/TextParser.Tests/TextParserTests.cs @@ -18,7 +18,7 @@ public class TextParserTests private const string testInput5 = @"asdfnums(2,5,3)ght cv strs(test) jh 4,3,2 - + 34,54,2nums(2,8) strs(aa,ab,ba,bb)aa,bb"; [Fact] @@ -230,7 +230,7 @@ public class TextParserTests .EndOptions() .Build(); - var parser = new TextParser(schema); + var parser = TextParser.Create(schema); var fragmentData = parser .SetInputText(testInput5) .Parse() diff --git a/TextParser/Schema/BuildingBlocks/FixedRepetitionBlock.cs b/TextParser/Schema/BuildingBlocks/FixedRepetitionBlock.cs index ec5478a..27e40a0 100644 --- a/TextParser/Schema/BuildingBlocks/FixedRepetitionBlock.cs +++ b/TextParser/Schema/BuildingBlocks/FixedRepetitionBlock.cs @@ -31,7 +31,7 @@ class FixedRepetitionBlock : BuildingBlockBase this.context = this.inputSchema.CreateContext(); } } - return result.SingleOrDefault(); + return result.Single(); } public override bool CanParseWord(InputProvider inputs) diff --git a/TextParser/Schema/BuildingBlocks/GreedyRepetitionBlock.cs b/TextParser/Schema/BuildingBlocks/GreedyRepetitionBlock.cs index 9de0639..773c1c6 100644 --- a/TextParser/Schema/BuildingBlocks/GreedyRepetitionBlock.cs +++ b/TextParser/Schema/BuildingBlocks/GreedyRepetitionBlock.cs @@ -22,7 +22,7 @@ class GreedyRepetitionBlock : BuildingBlockBase { this.context = this.inputSchema.CreateContext(); } - return result.SingleOrDefault(); + return result.Single(); } public override bool CanParseWord(InputProvider inputs) diff --git a/TextParser/Schema/FragmentSchemaBuilder.cs b/TextParser/Schema/FragmentSchemaBuilder.cs index 464d601..99c374b 100644 --- a/TextParser/Schema/FragmentSchemaBuilder.cs +++ b/TextParser/Schema/FragmentSchemaBuilder.cs @@ -100,6 +100,10 @@ public class FragmentSchemaBuilder : RepetitionSchemaBuilder Create(ISchema schema, string[]? delimiters = null, bool removeEmptyEntries = true) where TContext : ISchemaContext + { + return new TextParser(schema, delimiters, removeEmptyEntries); + } +} + public class TextParser : TokenConverter where T : ISchemaContext { private LineParser lineParser; diff --git a/TextParser/TokenConverter.cs b/TextParser/TokenConverter.cs index 79202be..71588b5 100644 --- a/TextParser/TokenConverter.cs +++ b/TextParser/TokenConverter.cs @@ -56,7 +56,7 @@ public static class DataManipulationHelpers { if (data.Count < 2) { - return data[0] ?? default(TType); + return data[0]; } TType result = data[0]; for (int i = 1; i < data.Count; i++)