From 04e8a0afcbfe4dcc779b249b7337a060fe4fa66b Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Thu, 29 Feb 2024 18:55:23 +0100 Subject: [PATCH] Added useLegacyV2RuntimeActivationPolicy and fixed some Sonar Lint warnings --- SnakeTail/App.manifest | 8 ++++---- SnakeTail/ExternalTool.cs | 2 +- SnakeTail/ExternalToolConfigForm.cs | 6 ++---- SnakeTail/LogFileCache.cs | 8 ++++---- SnakeTail/TailForm.cs | 23 +++++++++++------------ SnakeTail/app.config | 3 ++- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/SnakeTail/App.manifest b/SnakeTail/App.manifest index 7e66afc..ee8fd23 100644 --- a/SnakeTail/App.manifest +++ b/SnakeTail/App.manifest @@ -27,7 +27,7 @@ - + @@ -38,9 +38,9 @@ to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> - - true - + + true + diff --git a/SnakeTail/ExternalTool.cs b/SnakeTail/ExternalTool.cs index ad38b3f..81f435b 100644 --- a/SnakeTail/ExternalTool.cs +++ b/SnakeTail/ExternalTool.cs @@ -22,7 +22,7 @@ namespace SnakeTail class ExternalTool { public readonly ExternalToolConfig ToolConfig; - Dictionary _fileParameters; + private readonly Dictionary _fileParameters; public enum ParameterName { diff --git a/SnakeTail/ExternalToolConfigForm.cs b/SnakeTail/ExternalToolConfigForm.cs index 21ecbe7..daeed83 100644 --- a/SnakeTail/ExternalToolConfigForm.cs +++ b/SnakeTail/ExternalToolConfigForm.cs @@ -114,11 +114,9 @@ private void _shortcutEdt_KeyDown(object sender, KeyEventArgs e) // Ignore initial Shift + Control + Alt keys if (e.KeyCode == Keys.ShiftKey) e.Handled = true; - else - if (e.KeyCode == Keys.ControlKey) + else if (e.KeyCode == Keys.ControlKey) e.Handled = true; - else - if (e.KeyCode == Keys.Menu) + else if (e.KeyCode == Keys.Menu) e.Handled = true; else { diff --git a/SnakeTail/LogFileCache.cs b/SnakeTail/LogFileCache.cs index 1dab004..48c21c2 100644 --- a/SnakeTail/LogFileCache.cs +++ b/SnakeTail/LogFileCache.cs @@ -87,12 +87,12 @@ public int FillTailCache(LogFileStream logFileStream) lineCount = logFileStream.SkipLines(Items.Count); readLines = lineCount - readLines; if (LoadingFileEvent != null) - LoadingFileEvent(logFileStream, null); + LoadingFileEvent(logFileStream, EventArgs.Empty); } while (readLines == Items.Count); // We are almost finished with loading the file if (LoadingFileEvent != null) - LoadingFileEvent(null, null); + LoadingFileEvent(null, EventArgs.Empty); if (lineCount <= 0) return 0; @@ -146,7 +146,7 @@ public int FillCache(LogFileStream logFileStream, int endindex) { // We are filling the cache if (FillCacheEvent != null) - FillCacheEvent(this, null); + FillCacheEvent(this, EventArgs.Empty); } string line = logFileStream.ReadLine(FirstIndex + i + 1); @@ -162,7 +162,7 @@ public int FillCache(LogFileStream logFileStream, int endindex) // We are done filling the cache if (FillCacheEvent != null) - FillCacheEvent(null, null); + FillCacheEvent(null, EventArgs.Empty); if (lastItem != Items.Count - 1) return lastItem; diff --git a/SnakeTail/TailForm.cs b/SnakeTail/TailForm.cs index 414defc..fd8094d 100644 --- a/SnakeTail/TailForm.cs +++ b/SnakeTail/TailForm.cs @@ -276,8 +276,7 @@ public void LoadConfig(TailFileConfig tailConfig, string configPath) _formTitleMatchFilename = tailConfig.TitleMatchFilename; if (_formTitleMatchFilename) _formTitle = Path.GetFileName(_logTailStream.Name); - else - if (tailConfig.Title != null) + else if (tailConfig.Title != null) _formTitle = tailConfig.Title; else _formTitle = Path.GetFileName(tailConfig.FilePath); @@ -419,11 +418,6 @@ void UpdateFormTitle(bool force) SetStatusBar(null); } - public void SetStatusBar(string text) - { - SetStatusBar(text, 0, 0); - } - private static string ConvertFileSize(long fileSize) { string[] sizes = { "B", "KB", "MB", "GB" }; @@ -450,6 +444,11 @@ private string GetFileSizeStatusText() return string.Empty; } + public void SetStatusBar(string text) + { + SetStatusBar(text, 0, 0); + } + public void SetStatusBar(string text, int progressValue, int progressMax) { if (_statusStrip.Visible) @@ -587,8 +586,7 @@ private bool MatchTextSearch(int lineNumber, string lineText, string searchText, return false; } - else - if (matchCase) + else if (matchCase) { if (lineText.Contains(searchText)) { @@ -664,7 +662,7 @@ private int SearchForTextForward(string searchText, bool matchCase, bool lineHig if (_logFileCache != null) { exceptionDetails += "LogFileCache = "; - if (searchFileCache.Items != null) + if (searchFileCache != null && searchFileCache.Items != null) exceptionDetails += "Items = " + searchFileCache.Items.Count.ToString() + ", "; else exceptionDetails = "Items = null, "; @@ -1157,9 +1155,10 @@ private void _tailTimer_Tick(object sender, EventArgs e) if (_tailListView.Items[0].Text == _logTailStream.ReadLine(1)) return; } - else - if (_logTailStream.ValidLineCount(lineCount)) + else if (_logTailStream.ValidLineCount(lineCount)) + { return; + } lineCount = 0; } diff --git a/SnakeTail/app.config b/SnakeTail/app.config index 3a94478..acd0aee 100644 --- a/SnakeTail/app.config +++ b/SnakeTail/app.config @@ -1,6 +1,7 @@ - + +