Skip to content

Commit

Permalink
NET8
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Nov 16, 2023
1 parent e8b4dc3 commit be11bb3
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 107 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ dotnet_diagnostic.SA1122.severity = suggestion
dotnet_diagnostic.SA1108.severity = silent
dotnet_diagnostic.SA1012.severity = error
dotnet_diagnostic.SA1500.severity = error
dotnet_diagnostic.SA1316.severity = error

[*.{cs,vb}]
dotnet_style_operator_placement_when_wrapping = beginning_of_line
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dotnet-core-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:

# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v3.0.3
uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.1.3
uses: microsoft/setup-msbuild@v1.3.1

# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Analogy.LogViewer.Interfaces">
<Version>5.0.3</Version>
<Version>6.0.0.1</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>3.1.1</Version>
Expand Down
1 change: 0 additions & 1 deletion Analogy.LogViewer.JsonParser.UnitTests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public async Task TestMethod1()
MessageHandlerForTesting handler = new MessageHandlerForTesting();
var msgs = await fp.Process("test.json", ts.Token, handler);
Assert.IsTrue(msgs.Count() == 4);

}
[TestMethod]
public async Task TestMethod2()
Expand Down
47 changes: 8 additions & 39 deletions Analogy.LogViewer.JsonParser/Analogy.LogViewer.JsonParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,25 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net7.0-windows;net6.0-windows;net48;net471</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<TargetFrameworks>net8.0-windows;net7.0-windows;net6.0-windows;net48;net471</TargetFrameworks>
<VersionPrefix>6.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>Lior Banai</Authors>
<Company>Analogy.LogViewer</Company>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Analogy-LogViewer/Analogy.LogViewer.JsonParser</PackageProjectUrl>
<PackageIcon>AnalogyJson.png</PackageIcon>
<RepositoryUrl>https://github.com/Analogy-LogViewer/Analogy.LogViewer.JsonParser</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Analogy.LogViewer, Json</PackageTags>
<Copyright>Lior Banai @ 2020-2023</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
<VersionPrefix>5.0.3.1</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Copyright>Lior Banai @ 2020-2024</Copyright>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="5.0.3" />
<PackageReference Include="Analogy.CommonUtilities" Version="5.0.3" />
<PackageReference Include="Analogy.LogViewer.Template" Version="5.0.3" />
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="6.0.0.1" />
<PackageReference Include="Analogy.CommonUtilities" Version="6.0.0" />
<PackageReference Include="Analogy.LogViewer.Template" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="PolySharp" Version="1.13.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Resources.Extensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Build.Tasks.Git" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Resources.Extensions" Version="8.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' or '$(TargetFramework)' == 'net471' ">
<PackageReference Include="PolySharp" Version="1.12.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
6 changes: 3 additions & 3 deletions Analogy.LogViewer.JsonParser/ChangeLog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Analogy.Interfaces;
using System;
using System.Collections.Generic;
using Analogy.Interfaces;

namespace Analogy.LogViewer.JsonParser
{
Expand All @@ -12,4 +12,4 @@ public static IEnumerable<AnalogyChangeLog> GetChangeLog()
yield return new AnalogyChangeLog("Initial version", AnalogChangeLogType.None, "Lior Banai", new DateTime(2019, 12, 23), "");
}
}
}
}
4 changes: 2 additions & 2 deletions Analogy.LogViewer.JsonParser/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public enum FileFormat
public enum FileFormatDetection
{
Automatic,
Manual
Manual,
}
}
}
8 changes: 2 additions & 6 deletions Analogy.LogViewer.JsonParser/IAnalogy/AnalogyJsonFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class JsonFactory : Template.PrimaryFactory
public override Image? SmallImage { get; set; } = Resources.jsonfile16x16;
public override IEnumerable<string> Contributors { get; set; } = new List<string> { "Lior Banai" };
public override string About { get; set; } = "Json Log Parser";

}

public class AnalogyJsonDataProviderFactory : Template.DataProvidersFactory
Expand All @@ -26,7 +25,7 @@ public class AnalogyJsonDataProviderFactory : Template.DataProvidersFactory
public override string Title { get; set; } = "Json Data Provider";
public override IEnumerable<IAnalogyDataProvider> DataProviders { get; set; } = new List<IAnalogyDataProvider>()
{
new JsonDataProvider()
new JsonDataProvider(),
};
}

Expand All @@ -35,8 +34,5 @@ public class AnalogyJsonCustomActionFactory : IAnalogyCustomActionsFactory
public Guid FactoryId { get; set; } = JsonFactory.Id;
public string Title { get; set; } = "Json tools";
public IEnumerable<IAnalogyCustomAction> Actions { get; } = new List<IAnalogyCustomAction>(0);

}


}
}
6 changes: 3 additions & 3 deletions Analogy.LogViewer.JsonParser/IAnalogy/DownloadInformation.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using Analogy.LogViewer.Template;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using Analogy.LogViewer.Template;

namespace Analogy.LogViewer.JsonParser.IAnalogy
{
Expand Down Expand Up @@ -34,4 +34,4 @@ public override string InstalledVersionNumber
}
}
}
}
}
12 changes: 3 additions & 9 deletions Analogy.LogViewer.JsonParser/IAnalogy/JsonDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class JsonDataProvider : Template.OfflineDataProvider
public JsonFileLoader JsonParser { get; set; }

public override bool UseCustomColors { get; set; }
public override IEnumerable<(string originalHeader, string replacementHeader)> GetReplacementHeaders()
public override IEnumerable<(string OriginalHeader, string ReplacementHeader)> GetReplacementHeaders()
=> Array.Empty<(string, string)>();

public override (Color backgroundColor, Color foregroundColor) GetColorForMessage(IAnalogyLogMessage logMessage)
public override (Color BackgroundColor, Color ForegroundColor) GetColorForMessage(IAnalogyLogMessage logMessage)
=> (Color.Empty, Color.Empty);
public JsonDataProvider()
{
Expand All @@ -59,15 +59,12 @@ public override async Task<IEnumerable<IAnalogyLogMessage>> Process(string fileN
UserSettingsManager.UserSettings.Settings.Format = TryDetectFormat(fileName);
}


return await JsonParser.Process(fileName, token, messagesHandler);
}

return new List<AnalogyLogMessage>(0);

}


private static FileFormat TryDetectFormat(string fileName)
{
string jsonData = string.Empty;
Expand Down Expand Up @@ -102,7 +99,6 @@ private static FileFormat TryParsePerLine(string fileName)
{
try
{

var lines = File.ReadAllLines(fileName);
foreach (var line in lines)
{
Expand Down Expand Up @@ -147,7 +143,6 @@ private static string SafeReadAllLines(string path)
}
}


public override Task SaveAsync(List<IAnalogyLogMessage> messages, string fileName)
{
return Task.CompletedTask;
Expand All @@ -160,7 +155,6 @@ public override bool CanOpenFile(string fileName) => Path.GetExtension(fileName)

protected override List<FileInfo> GetSupportedFilesInternal(DirectoryInfo dirInfo, bool recursive)
{

List<FileInfo> files = dirInfo.GetFiles("*.json")
.Where(f => CanOpenFile(f.FullName)).ToList();
if (!recursive)
Expand All @@ -183,4 +177,4 @@ protected override List<FileInfo> GetSupportedFilesInternal(DirectoryInfo dirInf
return files;
}
}
}
}
10 changes: 4 additions & 6 deletions Analogy.LogViewer.JsonParser/IAnalogy/JsonUserSettingsFactory.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Analogy.LogViewer.JsonParser.Properties;
using Analogy.Interfaces;
using Analogy.LogViewer.JsonParser.Properties;
using Microsoft.Extensions.Logging;
using System;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using Analogy.Interfaces;
using Microsoft.Extensions.Logging;

namespace Analogy.LogViewer.JsonParser.IAnalogy
{
Expand All @@ -28,6 +28,4 @@ public override Task SaveSettingsAsync()
return Task.CompletedTask;
}
}


}
}
29 changes: 12 additions & 17 deletions Analogy.LogViewer.JsonParser/JsonFileLoader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Analogy.Interfaces;
using Analogy.Interfaces.DataTypes;
using Analogy.LogViewer.JsonParser.Managers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand All @@ -8,7 +9,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analogy.Interfaces.DataTypes;

namespace Analogy.LogViewer.JsonParser
{
Expand All @@ -20,7 +20,7 @@ public JsonFileLoader(JsonSettings jsonSettings)
JsonSettings = jsonSettings;
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
DateParseHandling = jsonSettings.DateParseHandling
DateParseHandling = jsonSettings.DateParseHandling,
};
}

Expand All @@ -33,7 +33,7 @@ public async Task<IEnumerable<IAnalogyLogMessage>> Process(string fileName, Canc
AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None")
{
Source = "Analogy",
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
};
messagesHandler.AppendMessage(empty, Utils.GetFileNameAsDataSource(fileName));
return new List<AnalogyLogMessage> { empty };
Expand All @@ -46,7 +46,7 @@ public async Task<IEnumerable<IAnalogyLogMessage>> Process(string fileName, Canc
AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None")
{
Source = "Analogy",
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
};
messagesHandler.AppendMessage(empty, Utils.GetFileNameAsDataSource(fileName));
return new List<AnalogyLogMessage> { empty };
Expand All @@ -61,7 +61,7 @@ public async Task<IEnumerable<IAnalogyLogMessage>> Process(string fileName, Canc
AnalogyLogMessage none = new AnalogyLogMessage($"Unknown file format", AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None")
{
Source = "Analogy",
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
};
messagesHandler.AppendMessage(none, Utils.GetFileNameAsDataSource(fileName));
return new List<AnalogyLogMessage> { none };
Expand All @@ -71,8 +71,7 @@ public async Task<IEnumerable<IAnalogyLogMessage>> Process(string fileName, Canc
private List<IAnalogyLogMessage> ProcessJsonFile(string fileName, CancellationToken token, ILogMessageCreatedHandler messagesHandler)
{
string json = File.ReadAllText(fileName);
return ProcessJsonData(json, fileName, messagesHandler,true);

return ProcessJsonData(json, fileName, messagesHandler, true);
}

private List<IAnalogyLogMessage> ProcessJsonData(string json, string fileName, ILogMessageCreatedHandler messagesHandler, bool reportProgress)
Expand Down Expand Up @@ -112,7 +111,7 @@ private List<IAnalogyLogMessage> ProcessJsonData(string json, string fileName, I
messages.Add(m);
if (reportProgress)
{
messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1,i, jArray.Count));
messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1, i, jArray.Count));
}
}
}
Expand All @@ -127,13 +126,11 @@ private List<IAnalogyLogMessage> ProcessJsonData(string json, string fileName, I
if (UserSettingsManager.UserSettings.Settings.TryGetAnalogyValue(jprop.Name, out var prop))
{
tuples.Add((prop.ToString(), jprop.Value.ToString()));

}
else
{
nonAnalogyTuples.Add((jprop.Name, jprop.Value.ToString()));
}

}

var m = AnalogyLogMessage.Parse(tuples);
Expand All @@ -146,7 +143,7 @@ private List<IAnalogyLogMessage> ProcessJsonData(string json, string fileName, I
messages.Add(m);
if (reportProgress)
{
messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage,1, 1, 1));
messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1, 1, 1));
}
}
messagesHandler.AppendMessages(messages, fileName);
Expand All @@ -158,11 +155,10 @@ private List<IAnalogyLogMessage> ProcessJsonData(string json, string fileName, I
AnalogyLogLevel.Critical, AnalogyLogClass.General, "Analogy", "None")
{
Source = "Analogy",
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName
Module = System.Diagnostics.Process.GetCurrentProcess().ProcessName,
};
messagesHandler.AppendMessage(empty, Utils.GetFileNameAsDataSource(fileName));
return new List<IAnalogyLogMessage> { empty
};
return new List<IAnalogyLogMessage> { empty, };
}
}

Expand All @@ -177,11 +173,10 @@ private List<IAnalogyLogMessage> ProcessJsonPerLine(string fileName, Cancellatio
var json = jsons[i];
var msgs = ProcessJsonData(json, fileName, messagesHandler, false);
messages.AddRange(msgs);
messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1,i, jsons.Length));

messagesHandler.ReportFileReadProgress(new AnalogyFileReadProgress(AnalogyFileReadProgressType.Percentage, 1, i, jsons.Length));
}

return messages;
}
}
}
}
Loading

0 comments on commit be11bb3

Please sign in to comment.