5 Commits 7cf7cd687b ... 3fa0f30593

Author SHA1 Message Date
  Piotr Czajkowski 3fa0f30593 Using .NET 8 1 week ago
  Piotr Czajkowski a92e2a9033 Correction 1 week ago
  Piotr Czajkowski 247588e628 Nicer 1 week ago
  Piotr Czajkowski 59054e46f8 Cosmetics 1 week ago
  Piotr Czajkowski 03fc0e2b88 Using .NET 8 and updated dependencies 1 week ago

+ 1 - 1
.github/workflows/dotnet.yml

@@ -16,7 +16,7 @@ jobs:
     - name: Setup .NET
       uses: actions/setup-dotnet@v1
       with:
-        dotnet-version: 6.0.x
+        dotnet-version: 8.x
     - name: Restore dependencies
       run: dotnet restore
     - name: Build

+ 6 - 3
analyzeJSON/AnalyzeJSON.cs

@@ -10,7 +10,7 @@ namespace analyzeJSON
 {
     public record Status(bool Success = false, string Message = "");
 
-    public class AnalyzeJSON
+    public partial class AnalyzeJSON
     {
         private readonly JObject json;
 
@@ -35,10 +35,10 @@ namespace analyzeJSON
                 return string.Empty;
 
             var name = tokenPath.Split(".").LastOrDefault();
-            return Regex.Replace(name, @"\[\d+?\]$", "");
+            return string.IsNullOrWhiteSpace(name) ? string.Empty : NameRegex().Replace(name, "");
         }
 
-        private void TraverseWithActions(IJEnumerable<JToken> tokens, List<Action<JToken>> actions)
+        private static void TraverseWithActions(IJEnumerable<JToken> tokens, List<Action<JToken>> actions)
         {
             foreach (var token in tokens)
             {
@@ -73,5 +73,8 @@ namespace analyzeJSON
             TraverseWithActions(json.Children(), actions);
             return new(true, string.Empty);
         }
+
+        [GeneratedRegex(@"\[\d+?\]$")]
+        private static partial Regex NameRegex();
     }
 }

+ 2 - 2
analyzeJSON/Statistics.cs

@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
 using Newtonsoft.Json.Linq;
 using System.Linq;
 
@@ -12,7 +12,7 @@ namespace analyzeJSON
 
         private static int CountWords(string text)
         {
-            var words = text.Split(new char[] { ' ', '\t', '\n' });
+            var words = text.Split([' ', '\t', '\n']);
             return words.Count(x => !string.IsNullOrWhiteSpace(x));
         }
 

+ 5 - 2
analyzeJSON/analyzeJSON.csproj

@@ -1,7 +1,10 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>net6.0</TargetFramework>
+    <TargetFramework>net8.0</TargetFramework>
+    <Version>1.0.0</Version>
+    <Authors>Piotr Czajkowski</Authors>
+    <PackageProjectUrl>https://github.com/pczajkowski/analyzeJSON</PackageProjectUrl>
   </PropertyGroup>
 
   <ItemGroup>
@@ -9,6 +12,6 @@
     <None Remove="Newtonsoft.Json" />
   </ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
+    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
   </ItemGroup>
 </Project>

+ 5 - 5
analyzeJSONTests/analyzeJSONTests.csproj

@@ -1,19 +1,19 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>net6.0</TargetFramework>
+    <TargetFramework>net8.0</TargetFramework>
 
     <IsPackable>false</IsPackable>
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
-    <PackageReference Include="xunit" Version="2.4.1" />
-    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
+    <PackageReference Include="xunit" Version="2.9.3" />
+    <PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       <PrivateAssets>all</PrivateAssets>
     </PackageReference>
-    <PackageReference Include="coverlet.collector" Version="3.1.2">
+    <PackageReference Include="coverlet.collector" Version="6.0.4">
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
       <PrivateAssets>all</PrivateAssets>
     </PackageReference>