Skip to content

Commit

Permalink
Added useLegacyV2RuntimeActivationPolicy and fixed some Sonar Lint wa…
Browse files Browse the repository at this point in the history
…rnings
  • Loading branch information
snakefoot committed Feb 29, 2024
1 parent ce2be95 commit 04e8a0a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
8 changes: 4 additions & 4 deletions SnakeTail/App.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10-->
<!-- Windows 10 + Windows 11-->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>

</application>
Expand All @@ -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. -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</application>

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
Expand Down
2 changes: 1 addition & 1 deletion SnakeTail/ExternalTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace SnakeTail
class ExternalTool
{
public readonly ExternalToolConfig ToolConfig;
Dictionary<ParameterName, string> _fileParameters;
private readonly Dictionary<ParameterName, string> _fileParameters;

public enum ParameterName
{
Expand Down
6 changes: 2 additions & 4 deletions SnakeTail/ExternalToolConfigForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions SnakeTail/LogFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
23 changes: 11 additions & 12 deletions SnakeTail/TailForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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" };
Expand All @@ -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)
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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, ";
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion SnakeTail/app.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<configuration>
<startup>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
Expand Down

0 comments on commit 04e8a0a

Please sign in to comment.