Skip to content

Code Improvements #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/ColumnizerLib/ColumnizerLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LogExpert</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<DocumentationFile>$(SolutionDir)..\bin\Docs\ColumnizerLib.xml</DocumentationFile>
<IsTestProject>false</IsTestProject>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
Expand Down
2 changes: 2 additions & 0 deletions src/CsvColumnizer/CsvColumnizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Versioning;
using System.Windows.Forms;

[assembly: SupportedOSPlatform("windows")]
namespace CsvColumnizer
{
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/CsvColumnizer/CsvColumnizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\plugins</OutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<NoWarn>CA1416;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down
1 change: 0 additions & 1 deletion src/DefaultPlugins/DefaultPlugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\plugins</OutputPath>
<NoWarn>CA1416;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down
2 changes: 2 additions & 0 deletions src/DefaultPlugins/Eminus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
using System.IO;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Runtime.Versioning;

[assembly: SupportedOSPlatform("windows")]
namespace LogExpert
{
public class Eminus : IContextMenuEntry, ILogExpertPluginConfigurator
Expand Down
1 change: 0 additions & 1 deletion src/FlashIconHighlighter/FlashIconHighlighter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\plugins</OutputPath>
<NoWarn>CA1416;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down
2 changes: 2 additions & 0 deletions src/FlashIconHighlighter/FlashIconPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Windows.Forms;

[assembly: SupportedOSPlatform("windows")]
namespace FlashIconHighlighter
{
internal class FlashIconPlugin : IKeywordAction
Expand Down
8 changes: 4 additions & 4 deletions src/Log4jXmlColumnizer/Log4jXmlColumnizer.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Windows.Forms;
using Newtonsoft.Json;


[assembly: SupportedOSPlatform("windows")]
namespace LogExpert
{
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\plugins</OutputPath>
<NoWarn>CA1416;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down
2 changes: 0 additions & 2 deletions src/LogExpert/Controls/LogTabWindow/LogTabWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ public void ChangeTheme(Control.ControlCollection container)

private delegate void LoadMultiFilesDelegate(string[] fileName, EncodingOptions encodingOptions);

private delegate void ProgressBarEventFx(ProgressEventArgs e);

private delegate void SetColumnizerFx(ILogLineColumnizer columnizer);

private delegate void SetTabIconDelegate(LogWindow.LogWindow logWindow, Icon icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private void OnBookmarkRemoved(object sender, EventArgs e)

private void OnProgressBarUpdate(object sender, ProgressEventArgs e)
{
Invoke(new ProgressBarEventFx(ProgressBarUpdateWorker), e);
Invoke(ProgressBarUpdateWorker, e);
}

private void OnStatusLineEvent(object sender, StatusLineEventArgs e)
Expand Down
4 changes: 0 additions & 4 deletions src/LogExpert/Controls/LogWindow/LogWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,6 @@ private void OnButtonSizeChanged(object sender, EventArgs e)

// used for external wait fx WaitForLoadFinished()

private delegate void UpdateProgressCallback(LoadFileEventArgs e);

private delegate void LoadingStartedFx(LoadFileEventArgs e);

private delegate void SelectLineFx(int line, bool triggerSyncCall);

private Action<FilterParams, List<int>, List<int>, List<int>> FilterFxAction;
Expand Down
11 changes: 3 additions & 8 deletions src/LogExpert/Controls/LogWindow/LogWindowEventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void OnLogWindowDisposed(object sender, EventArgs e)

private void OnLogFileReaderLoadingStarted(object sender, LoadFileEventArgs e)
{
Invoke(new LoadingStartedFx(LoadingStarted), e);
Invoke(LoadingStarted, e);
}

private void OnLogFileReaderFinishedLoading(object sender, EventArgs e)
Expand Down Expand Up @@ -211,16 +211,11 @@ private void OnLogFileReaderLoadFile(object sender, LoadFileEventArgs e)
//Thread loadThread = new Thread(new ThreadStart(ReloadNewFile));
//loadThread.Start();
_logger.Debug("Reloading invoked.");
return;
}

if (!_isLoading)
else if (_isLoading)
{
return;
BeginInvoke(UpdateProgress, e);
}

UpdateProgressCallback callback = UpdateProgress;
BeginInvoke(callback, e);
}

private void OnFileSizeChanged(object sender, LogEventArgs e)
Expand Down
3 changes: 1 addition & 2 deletions src/LogExpert/Controls/LogWindow/LogWindowPrivate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,6 @@ private void StatusLineFileSize(long size)

private int Search(SearchParams searchParams)
{
UpdateProgressBarFx progressFx = UpdateProgressBar;
if (searchParams.searchText == null)
{
return -1;
Expand Down Expand Up @@ -1679,7 +1678,7 @@ private int Search(SearchParams searchParams)
{
if (!Disposing)
{
Invoke(progressFx, [count]);
Invoke(UpdateProgressBar, [count]);
}
}
catch (ObjectDisposedException ex) // can occur when closing the app while searching
Expand Down
6 changes: 4 additions & 2 deletions src/LogExpert/Controls/LogWindow/LogWindowsPublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ public void LoadFile(string fileName, EncodingOptions encodingOptions)

try
{
_logFileReader = new LogfileReader(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions);
_logFileReader.UseNewReader = !Preferences.useLegacyReader;
_logFileReader = new LogfileReader(fileName, EncodingOptions, IsMultiFile, Preferences.bufferCount, Preferences.linesPerBuffer, _multiFileOptions)
{
UseNewReader = !Preferences.useLegacyReader
};
}
catch (LogFileException lfe)
{
Expand Down
38 changes: 2 additions & 36 deletions src/LogExpert/Entities/EventArgs/LoadFileEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
//using System.Linq;

namespace LogExpert.Entities.EventArgs
namespace LogExpert.Entities.EventArgs
{
public class LoadFileEventArgs
{
#region Fields

#endregion

#region cTor

public LoadFileEventArgs(string fileName, long pos, bool finished, long fileSize, bool newFile)
{
this.FileName = fileName;
this.ReadPos = pos;
this.Finished = finished;
this.FileSize = fileSize;
this.NewFile = newFile;
}

#endregion

#region Properties

public long ReadPos { get; }

public bool Finished { get; }

public long FileSize { get; }

public bool NewFile { get; }

public string FileName { get; }

#endregion
}
public record LoadFileEventArgs(string FileName, long ReadPos, bool Finished, long FileSize, bool NewFile);
}
4 changes: 2 additions & 2 deletions src/LogExpert/LogExpert.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<OutputPath>$(SolutionDir)..\bin\$(Configuration)</OutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ForceDesignerDPIUnaware>true</ForceDesignerDPIUnaware>
<NoWarn>CS1591;CA1416;</NoWarn>
<ForceDesignerDPIUnaware>true</ForceDesignerDPIUnaware>
<NoWarn>CS1591;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down
4 changes: 2 additions & 2 deletions src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using LogExpert;

using Moq;

using NUnit.Framework;
using System.Runtime.Versioning;

[assembly: SupportedOSPlatform("windows")]
namespace RegexColumnizer.UnitTests
{
[TestFixture]
Expand Down
10 changes: 6 additions & 4 deletions src/RegexColumnizer/RegexColumnizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml.Serialization;

[assembly: SupportedOSPlatform("windows")]
namespace RegexColumnizer
{
public abstract class BaseRegexColumnizer : ILogLineColumnizer, IColumnizerConfigurator
Expand Down Expand Up @@ -122,16 +124,16 @@ public void PushValue(ILogLineColumnizerCallback callback, int column, string va

public void Configure(ILogLineColumnizerCallback callback, string configDir)
{
RegexColumnizerConfigDialog d = new RegexColumnizerConfigDialog {Config = Config};
if (d.ShowDialog() == DialogResult.OK)
RegexColumnizerConfigDialog dialog = new RegexColumnizerConfigDialog {Config = Config};
if (dialog.ShowDialog() == DialogResult.OK)
{
var configFile = GetConfigFile(configDir);
using (var w = new FileStream(configFile, FileMode.Create))
{
xml.Serialize(w, d.Config);
xml.Serialize(w, dialog.Config);
}

Init(d.Config);
Init(dialog.Config);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/RegexColumnizer/RegexColumnizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\plugins</OutputPath>
<NoWarn>CA1416;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down
2 changes: 2 additions & 0 deletions src/SftpFileSystemx64/ConfigDialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Runtime.Versioning;
using System.Windows.Forms;

[assembly: SupportedOSPlatform("windows")]
namespace SftpFileSystem
{
public partial class ConfigDialog : Form
Expand Down
1 change: 0 additions & 1 deletion src/SftpFileSystemx64/SftpFileSystemx64.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\plugins</OutputPath>
<NoWarn>CA1416;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down
1 change: 0 additions & 1 deletion src/SftpFileSystemx86/SftpFileSystemx86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<AssemblyTitle>SftpFileSystemx86</AssemblyTitle>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(SolutionDir)..\bin\$(Configuration)\pluginsx86</OutputPath>
<NoWarn>CA1416;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>False</Optimize>
Expand Down