Skip to content

Commit

Permalink
Update package references and add conditional packing
Browse files Browse the repository at this point in the history
The commit revises the Directory.Build.props to only include README.md and icon.png if they don't already exist. It also updates the version of Frank.Reflection in the Frank.Testing.Logging project and replaces VarDump with Frank.Reflection.Dump in Frank.Testing.TestOutputExtensions. The commit introduces a new function in TestOutputCSharpExtensions to handle output of an Enumerable source.
  • Loading branch information
frankhaugen committed Jan 22, 2024
1 parent 2164ac8 commit b0354e1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
<None Include="../README.md" Pack="true" PackagePath="\"/>
<None Include="../icon.png" Pack="true" PackagePath="\"/>
<None Include="../README.md" Pack="true" PackagePath="\" Condition="!Exists('README.md')"/>
<None Include="../icon.png" Pack="true" PackagePath="\" Condition="!Exists('icon.png')"/>
<InternalsVisibleTo Include="$(AssemblyName).Tests"/>
<InternalsVisibleTo Include="LINQPadQuery"/>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Frank.Testing.Logging/Frank.Testing.Logging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Frank.PulseFlow.Logging" Version="1.7.0" />
<PackageReference Include="Frank.Reflection" Version="1.1.0" />
<PackageReference Include="Frank.Reflection" Version="1.3.0" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="xunit.extensibility.core" Version="2.6.6" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="VarDump" Version="0.2.14" />
<PackageReference Include="Frank.Reflection.Dump" Version="1.3.0" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
</ItemGroup>

Expand Down
26 changes: 24 additions & 2 deletions Frank.Testing.TestOutputExtensions/TestOutputCSharpExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.ComponentModel;

using Frank.Reflection.Dump;

using VarDump;
using VarDump.Visitor;

Expand Down Expand Up @@ -34,8 +36,21 @@ public static class TestOutputCSharpExtensions
public static void WriteCSharp<T>(this ITestOutputHelper outputHelper, T source, DumpOptions? dumpOptions = null)
{
var options = dumpOptions ?? DumpOptions;
var dumper = new CSharpDumper(options);
outputHelper.WriteLine(dumper.Dump(source));
outputHelper.WriteLine(source.DumpClass(options));
}

/// <summary>
/// Writes the C# representation of the elements in the specified source collection to the test output.
/// </summary>
/// <typeparam name="T">The type of elements in the source collection.</typeparam>
/// <param name="outputHelper">The test output helper.</param>
/// <param name="source">The source collection.</param>
/// <param name="idSelector">The function to extract an identifier from each element.</param>
/// <param name="dumpOptions">The options for dumping the elements. Null to use the default options.</param>
public static void WriteCSharp<T>(this ITestOutputHelper outputHelper, IEnumerable<T> source, Func<T, string> idSelector, DumpOptions? dumpOptions = null)
{
var options = dumpOptions ?? DumpOptions;
outputHelper.WriteLine(source.DumpEnumerable(idSelector, options));
}

private static DumpOptions DumpOptions => new DumpOptions()
Expand All @@ -48,4 +63,11 @@ public static void WriteCSharp<T>(this ITestOutputHelper outputHelper, T source,
SortDirection = ListSortDirection.Ascending,
MaxDepth = 64,
};
}

public enum CSharpDumpType
{
Variable,
Class,
IEnumerable
}

0 comments on commit b0354e1

Please sign in to comment.