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 6719130 commit a5cdde2
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 129 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 @@ -29,13 +29,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
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Analogy.LogViewer.WindowsEventLogs.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public void TestMethod1()
{
}
}
}
}
14 changes: 11 additions & 3 deletions Analogy.LogViewer.WindowsEventLogs.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29926.136
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.WindowsEventLogs", "Analogy.LogViewer.WindowsEventLogs\Analogy.LogViewer.WindowsEventLogs.csproj", "{29D49402-7126-4A52-A1A4-4CF7A7B93A4B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analogy.LogViewer.WindowsEventLogs.Tests", "Analogy.LogViewer.WindowsEventLogs.Tests\Analogy.LogViewer.WindowsEventLogs.Tests.csproj", "{08B20A42-E736-4D64-B911-B25822D8AC69}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.WindowsEventLogs.Tests", "Analogy.LogViewer.WindowsEventLogs.Tests\Analogy.LogViewer.WindowsEventLogs.Tests.csproj", "{08B20A42-E736-4D64-B911-B25822D8AC69}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0F153D81-714E-4FFC-BF08-EF3AE64CCDFB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.props = Directory.Build.props
.github\workflows\dotnet-core-desktop.yml = .github\workflows\dotnet-core-desktop.yml
nuget.config = nuget.config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,22 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net7.0-windows;net6.0-windows;net48;net471</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<TargetFrameworks>net8.0-windows;net7.0-windows;net6.0-windows;net48;net471</TargetFrameworks>
<Authors>Lior Banai</Authors>
<Description>Extension for Analogy Log Viewer that shows Windows Event logs and read local *.Evtx files</Description>
<Copyright>Lior Banai @ 2020-2023</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Lior Banai @ 2020-2024</Copyright>
<PackageProjectUrl>https://github.com/Analogy-LogViewer/Analogy.LogViewer.WindowsEventLogs</PackageProjectUrl>
<RepositoryUrl>https://github.com/Analogy-LogViewer/Analogy.LogViewer.WindowsEventLogs</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>update API</PackageReleaseNotes>
<PackageIcon>AnalogyWindows.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<VersionPrefix>5.0.3</VersionPrefix>
<VersionPrefix>6.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Company>Analogy.LogViewer</Company>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="5.0.3" />
<PackageReference Include="Analogy.LogViewer.Template" Version="5.0.3" />
<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="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' or '$(TargetFramework)' == 'net471' ">
<PackageReference Include="PolySharp" Version="1.13.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<ItemGroup>
<PackageReference Include="Analogy.LogViewer.Interfaces" Version="6.0.0.1" />
<PackageReference Include="Analogy.LogViewer.Template" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
Expand Down
6 changes: 3 additions & 3 deletions Analogy.LogViewer.WindowsEventLogs/EventLogsSettings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using Analogy.LogViewer.WindowsEventLogs.Managers;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Analogy.LogViewer.WindowsEventLogs.Managers;

namespace Analogy.LogViewer.WindowsEventLogs
{
Expand Down Expand Up @@ -56,4 +56,4 @@ private void EventLogsSettings_Load(object sender, EventArgs e)
}
}
}
}
}
29 changes: 13 additions & 16 deletions Analogy.LogViewer.WindowsEventLogs/EventViewerLogLoader.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System;
using Analogy.Interfaces;
using Analogy.Interfaces.DataTypes;
using Analogy.LogViewer.Template.Managers;
using Analogy.LogViewer.WindowsEventLogs.Managers;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Analogy.Interfaces;
using Analogy.Interfaces.DataTypes;
using Analogy.LogViewer.Template.Managers;
using Analogy.LogViewer.WindowsEventLogs.Managers;
using Microsoft.Extensions.Logging;

namespace Analogy.LogViewer.WindowsEventLogs
{
public class EventViewerLogLoader
{
private readonly string[] _separators = {"Severity: ", ", Category: ", ", MessageID: ", ", Message: "};
private readonly string[] _separators = { "Severity: ", ", Category: ", ", MessageID: ", ", Message: " };
private CancellationToken Token { get; }

public EventViewerLogLoader(CancellationToken token)
Expand Down Expand Up @@ -58,10 +58,10 @@ public async Task<IEnumerable<IAnalogyLogMessage>> ReadFromFile(string fileName,
Level = AnalogyLogLevel.Information,
Id = record.ActivityId ?? Guid.Empty,
ProcessId = record.ProcessId ?? 0,
MachineName= record.MachineName,
ThreadId =record.ThreadId??0,
MachineName = record.MachineName,
ThreadId = record.ThreadId ?? 0,
FileName = fileName,
User = record.UserId?.Value
User = record.UserId?.Value,
};
string properties = string.Join(Environment.NewLine,
record.Properties.Select(p => p.Value));
Expand Down Expand Up @@ -148,7 +148,6 @@ public async Task<IEnumerable<IAnalogyLogMessage>> ReadFromFile(string fileName,
break;
}
}

}
}

Expand All @@ -159,7 +158,6 @@ public async Task<IEnumerable<IAnalogyLogMessage>> ReadFromFile(string fileName,
}
}
}

}
catch (Exception e)
{
Expand All @@ -169,9 +167,9 @@ public async Task<IEnumerable<IAnalogyLogMessage>> ReadFromFile(string fileName,
Text = fail,
Level = AnalogyLogLevel.Critical,
Class = AnalogyLogClass.General,
Source = "Analogy"
Source = "Analogy",
};
LogManager.Instance.LogError(e, $"Error reading file:{e.Message}",e, nameof(ReadFromFile));
LogManager.Instance.LogError(e, $"Error reading file:{e.Message}", e, nameof(ReadFromFile));
messages.Add(m);
messagesHandler.AppendMessages(messages, GetFileNameAsDataSource(fileName));
}
Expand All @@ -192,7 +190,6 @@ private static string GetFileNameAsDataSource(string fileName)
{
string file = Path.GetFileName(fileName);
return fileName != null && fileName.Equals(file) ? fileName : $"{file} ({fileName})";

}
}
}
}
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.WindowsEventLogs.IAnalogy
{
Expand Down Expand Up @@ -34,4 +34,4 @@ public override string InstalledVersionNumber
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Analogy.Interfaces;
using Analogy.Interfaces.DataTypes;
using Analogy.Interfaces.Factories;
using Analogy.LogViewer.Template;
using Analogy.LogViewer.Template.Managers;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Analogy.Interfaces;
using Analogy.Interfaces.DataTypes;
using Analogy.Interfaces.Factories;
using Analogy.LogViewer.Template;
using Analogy.LogViewer.Template.Managers;
using Microsoft.Extensions.Logging;

namespace Analogy.LogViewer.WindowsEventLogs.IAnalogy
{
Expand All @@ -26,11 +26,10 @@ public EventLogDataProvidersFactory()
{
new RealTimeEventLogs(),
new OfflineEventLogDataProvider(),
new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "System.evtx"),new Guid("17C93A69-2D7D-4620-9289-6889DE4EFC79")),
new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "Application.evtx"),new Guid("27C93A69-2D7D-4620-9289-6889DE4EFC80")),
new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "Security.evtx"),new Guid("37C93A69-2D7D-4620-9289-6889DE4EFC80")),
new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "Setup.evtx"),new Guid("47C93A69-2D7D-4620-9289-6889DE4EFC80")),

new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "System.evtx"), new Guid("17C93A69-2D7D-4620-9289-6889DE4EFC79")),
new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "Application.evtx"), new Guid("27C93A69-2D7D-4620-9289-6889DE4EFC80")),
new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "Security.evtx"), new Guid("37C93A69-2D7D-4620-9289-6889DE4EFC80")),
new WindowsEventLogFile(Path.Combine(Environment.ExpandEnvironmentVariables("%SystemRoot%"), "System32", "Winevt", "Logs", "Setup.evtx"), new Guid("47C93A69-2D7D-4620-9289-6889DE4EFC80")),
};
}
}
Expand All @@ -53,14 +52,13 @@ public class WindowsEventLogFile : IAnalogySingleFileDataProvider
public bool UseCustomColors { get; set; }
public AnalogyToolTip? ToolTip { get; set; }

public IEnumerable<(string originalHeader, string replacementHeader)> GetReplacementHeaders()
public IEnumerable<(string OriginalHeader, string ReplacementHeader)> GetReplacementHeaders()
=> Array.Empty<(string, string)>();

public (Color backgroundColor, Color foregroundColor) GetColorForMessage(IAnalogyLogMessage logMessage)
public (Color BackgroundColor, Color ForegroundColor) GetColorForMessage(IAnalogyLogMessage logMessage)
=> (Color.Empty, Color.Empty);
public WindowsEventLogFile(string fileNamePath, Guid id)
{

FileNamePath = fileNamePath;
Id = id;
OptionalTitle = Path.GetFileName(FileNamePath);
Expand All @@ -79,12 +77,11 @@ public void MessageOpened(IAnalogyLogMessage message)
public async Task<IEnumerable<IAnalogyLogMessage>> Process(CancellationToken token, ILogMessageCreatedHandler messagesHandler)
{
DateTime now = DateTime.Now;
ProcessingStarted?.Invoke(this,new AnalogyStartedProcessingArgs());
ProcessingStarted?.Invoke(this, new AnalogyStartedProcessingArgs());
EventViewerLogLoader logLoader = new EventViewerLogLoader(token);
var messages = await logLoader.ReadFromFile(FileNamePath, messagesHandler).ConfigureAwait(false);
ProcessingFinished?.Invoke(this, new AnalogyEndProcessingArgs(now,DateTime.Now,"",messages.Count()));
ProcessingFinished?.Invoke(this, new AnalogyEndProcessingArgs(now, DateTime.Now, "", messages.Count()));
return messages;
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using Analogy.Interfaces;
using Analogy.Interfaces;
using Analogy.Interfaces.Factories;
using Analogy.LogViewer.Template;
using Analogy.LogViewer.WindowsEventLogs.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;

namespace Analogy.LogViewer.WindowsEventLogs.IAnalogy
{
Expand All @@ -19,6 +19,5 @@ public class EventLogPrimaryFactory : PrimaryFactory
public override string About { get; set; } = "Windows Event Log Data Provider";
public override Image LargeImage { get; set; } = Resources.OperatingSystem_32x32;

Check warning on line 20 in Analogy.LogViewer.WindowsEventLogs/IAnalogy/EventLogPrimaryFactory.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 20 in Analogy.LogViewer.WindowsEventLogs/IAnalogy/EventLogPrimaryFactory.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).
public override Image SmallImage { get; set; } = Resources.OperatingSystem_16x16;

Check warning on line 21 in Analogy.LogViewer.WindowsEventLogs/IAnalogy/EventLogPrimaryFactory.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 21 in Analogy.LogViewer.WindowsEventLogs/IAnalogy/EventLogPrimaryFactory.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).

}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using Analogy.Interfaces;
using Analogy.Interfaces;
using Analogy.LogViewer.Template;
using Analogy.LogViewer.WindowsEventLogs.Managers;
using Microsoft.Extensions.Logging;
using System;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Analogy.LogViewer.WindowsEventLogs.IAnalogy
{
public class EventLogsDataProviderSettings : TemplateUserSettingsFactory
{

public override string Title { get; set; } = "Windows Event Logs settings";
public override UserControl DataProviderSettings { get; set; }

Expand All @@ -29,4 +28,4 @@ public override Task SaveSettingsAsync()
return Task.CompletedTask;
}
}
}
}
Loading

0 comments on commit a5cdde2

Please sign in to comment.