Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<PackageReference Include="GitVersion.Core" Version="6.5.0" />
<PackageReference Include="Microsoft.Build" Version="18.0.2" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="18.0.2" />
<PackageReference Include="NuGet.CommandLine" Version="7.0.0">
<PackageReference Include="NuGet.CommandLine" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="NuGet.Versioning" Version="7.0.0" />
<PackageReference Include="Nuke.Common" Version="9.0.4" />
<PackageReference Include="NuGet.Versioning" Version="7.0.1" />
<PackageReference Include="Nuke.Common" Version="10.0.0" />
<PackageReference Include="Nuke.GitHub" Version="7.0.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.20.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AutoColumnizer/AutoColumnizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LogExpert;
using ColumnizerLib;

namespace AutoColumnizer;

Expand Down
59 changes: 30 additions & 29 deletions src/ColumnizerLib.UnitTests/ColumnTests.cs
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
using LogExpert;
using System.Text;

using NUnit.Framework;
using ColumnizerLib;

using System;
using System.Text;
using NUnit.Framework;

namespace ColumnizerLib.UnitTests;
namespace LogExpert.ColumnizerLib.Tests;

[TestFixture]
public class ColumnTests
{
[SetUp]
public void SetUp()
public void SetUp ()
{
// Reset to default before each test
Column.SetMaxDisplayLength(20_000);
}

[Test]
public void Column_DisplayMaxLength_DefaultIs20000()
public void Column_DisplayMaxLength_DefaultIs20000 ()
{
Assert.That(Column.GetMaxDisplayLength(), Is.EqualTo(20_000));
}

[Test]
public void Column_DisplayMaxLength_CanBeConfigured()
public void Column_DisplayMaxLength_CanBeConfigured ()
{
Column.SetMaxDisplayLength(50_000);
Assert.That(Column.GetMaxDisplayLength(), Is.EqualTo(50_000));

// Reset for other tests
Column.SetMaxDisplayLength(20_000);
}

[Test]
public void Column_DisplayMaxLength_EnforcesMinimum()
public void Column_DisplayMaxLength_EnforcesMinimum ()
{
Assert.Throws<ArgumentOutOfRangeException>(() => Column.SetMaxDisplayLength(500));
_ = Assert.Throws<ArgumentOutOfRangeException>(() => Column.SetMaxDisplayLength(500));
}

[Test]
public void Column_TruncatesAtConfiguredDisplayLength()
public void Column_TruncatesAtConfiguredDisplayLength ()
{
Column.SetMaxDisplayLength(10_000);

// Create a line longer than the display max length
var longValue = new StringBuilder().Append('X', 15_000).ToString();

Column column = new()
{
FullValue = longValue
Expand All @@ -55,21 +54,21 @@ public void Column_TruncatesAtConfiguredDisplayLength()
// FullValue should contain the full line
Assert.That(column.FullValue, Is.EqualTo(longValue));
Assert.That(column.FullValue.Length, Is.EqualTo(15_000));

// DisplayValue should be truncated at 10,000 with "..." appended
Assert.That(column.DisplayValue.Length, Is.EqualTo(10_003)); // 10000 + "..."
Assert.That(column.DisplayValue.EndsWith("..."), Is.True);
Assert.That(column.DisplayValue.StartsWith("XXX"), Is.True);
Assert.That(column.DisplayValue.EndsWith("...", StringComparison.OrdinalIgnoreCase), Is.True);
Assert.That(column.DisplayValue.StartsWith("XXX", StringComparison.OrdinalIgnoreCase), Is.True);

// Reset for other tests
Column.SetMaxDisplayLength(20_000);
}

[Test]
public void Column_NoTruncationWhenBelowLimit()
public void Column_NoTruncationWhenBelowLimit ()
{
Column.SetMaxDisplayLength(20_000);

var normalValue = new StringBuilder().Append('Y', 5_000).ToString();
Column column = new()
{
Expand All @@ -81,14 +80,15 @@ public void Column_NoTruncationWhenBelowLimit()
}

[Test]
public void Column_NullCharReplacement()
public void Column_NullCharReplacement ()
{
Column column = new();

column.FullValue = "asdf\0";
Column column = new()
{
FullValue = "asdf\0"
};

//Switch between the different implementation for the windows versions
//Not that great solution but currently I'm out of ideas, I know that currently
//Not that great solution but currently I'm out of ideas, I know that currently
//only one implementation depending on the windows version is executed
if (Environment.Version >= Version.Parse("6.2"))
{
Expand All @@ -103,11 +103,12 @@ public void Column_NullCharReplacement()
}

[Test]
public void Column_TabReplacement()
public void Column_TabReplacement ()
{
Column column = new();

column.FullValue = "asdf\t";
Column column = new()
{
FullValue = "asdf\t"
};

Assert.That(column.DisplayValue, Is.EqualTo("asdf "));
Assert.That(column.FullValue, Is.EqualTo("asdf\t"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using LogExpert;
using LogExpert.Extensions;
using ColumnizerLib;
using ColumnizerLib.Extensions;

using NUnit.Framework;

namespace ColumnizerLib.UnitTests.Extensions;
namespace LogExpert.ColumnizerLib.Tests.Extensions;

[TestFixture]

Expand All @@ -19,7 +19,8 @@ private class TestingLogLine : ILogLine
}

[Test]
public void ToClipBoardText_ReturnsExpected()
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Unit Test")]
public void ToClipBoardText_ReturnsExpected ()
{
var underTest = new TestingLogLine
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>

<IsTestProject>true</IsTestProject>
<AssemblyTitle>ColumnizerLib.UnitTests</AssemblyTitle>
<Company>Microsoft</Company>
<OutputPath>bin\$(Configuration)</OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ColumnizerLib\ColumnizerLib.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>

<IsTestProject>true</IsTestProject>
<AssemblyTitle>ColumnizerLib.Tests</AssemblyTitle>
<Company>Microsoft</Company>
<OutputPath>bin\$(Configuration)</OutputPath>
<RootNamespace>LogExpert.ColumnizerLib.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ColumnizerLib\ColumnizerLib.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions src/ColumnizerLib/Column.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using LogExpert;

namespace ColumnizerLib;

public class Column : IColumn
Expand Down Expand Up @@ -90,7 +88,7 @@ public static void SetMaxDisplayLength (int maxLength)
{
if (maxLength < 1000)
{
throw new ArgumentOutOfRangeException(nameof(maxLength), "Maximum display length must be at least 1000 characters.");
throw new ArgumentOutOfRangeException(nameof(maxLength), Resources.Column_Error_Messages_MaximumDisplayLengthMustBeAtLeast1000Characters);
}

_maxDisplayLength = maxLength;
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnizerLib/ColumnizedLogLine.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LogExpert;
namespace ColumnizerLib;

public class ColumnizedLogLine : IColumnizedLogLine
{
Expand Down
18 changes: 18 additions & 0 deletions src/ColumnizerLib/ColumnizerLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
<TargetFramework>net10.0</TargetFramework>

<DocumentationFile>$(SolutionDir)..\bin\Docs\ColumnizerLib.xml</DocumentationFile>

<RootNamespace>ColumnizerLib</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<CustomToolNamespace>ColumnizerLib</CustomToolNamespace>
</EmbeddedResource>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/ColumnizerLib/Extensions/LogLineExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LogExpert.Extensions;
namespace ColumnizerLib.Extensions;

//TODO: Move this to LogExpert.UI, change to internal and fix tests
public static class LogLineExtensions
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnizerLib/IAutoLogLineColumnizerCallback.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LogExpert;
namespace ColumnizerLib;

public interface IAutoLogLineColumnizerCallback
{
Expand Down
4 changes: 2 additions & 2 deletions src/ColumnizerLib/IColumn.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogExpert;
namespace ColumnizerLib;

public interface IColumn : ITextValue
{
Expand Down
4 changes: 2 additions & 2 deletions src/ColumnizerLib/IColumnizedLogLine.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogExpert;
namespace ColumnizerLib;

public interface IColumnizedLogLine
{
Expand Down
3 changes: 1 addition & 2 deletions src/ColumnizerLib/IColumnizerConfigurator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// A Columnizer can implement this interface if it has to show an own settings dialog to the user.
Expand Down
4 changes: 2 additions & 2 deletions src/ColumnizerLib/IColumnizerPriority.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogExpert;
namespace ColumnizerLib;

public interface IColumnizerPriority
{
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnizerLib/IContextMenuEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// Implement this interface to add a menu entry to the context menu of LogExpert.
Expand Down
4 changes: 2 additions & 2 deletions src/ColumnizerLib/IFileSystemCallback.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;

namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// Service interface implemented by LogExpert. This can be used by IFileSystemPlugin implementations to get certain services.
Expand Down
6 changes: 3 additions & 3 deletions src/ColumnizerLib/IFileSystemPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// Interface for file system plugins. A file system plugin is responsible for feeding file data to LogExpert.
Expand Down Expand Up @@ -31,15 +31,15 @@ public interface IFileSystemPlugin
/// </summary>
/// <param name="uriString">The URI of the file to be loaded.</param>
/// <returns>Return <code>true</code> if the file system plugin can handle the URI.</returns>
bool CanHandleUri(string uriString);
bool CanHandleUri (string uriString);

/// <summary>
/// Return a file system specific implementation of <see cref="ILogFileInfo"/> here.
/// The method is called from LogExpert when a file is about to be opened. It's called after <see cref="CanHandleUri"/> was called.
/// </summary>
/// <param name="uriString"></param>
/// <returns></returns>
ILogFileInfo GetLogfileInfo(string uriString);
ILogFileInfo GetLogfileInfo (string uriString);

#endregion
}
4 changes: 2 additions & 2 deletions src/ColumnizerLib/IInitColumnizer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;

namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// Implement this interface in your columnizer if you need to do some initialization work
Expand Down
4 changes: 2 additions & 2 deletions src/ColumnizerLib/IKeywordAction.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;

namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// Implement this interface to execute a self defined action when LogExpert detects a
Expand Down
4 changes: 2 additions & 2 deletions src/ColumnizerLib/ILogExpertCallback.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;

namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// This callback interface is implemented by LogExpert. You can use it e.g. when implementing a
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnizerLib/ILogExpertLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LogExpert;
namespace ColumnizerLib;

/// <summary>
/// Simple Logger interface to let plugins log into LogExpert's application log file.
Expand Down
Loading