Skip to content
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

Make extension explicit on overloads #661

Merged
merged 26 commits into from
Sep 24, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update InnerVerifier_Inner.cs
  • Loading branch information
SimonCropp committed Sep 23, 2022
commit 6d40e9105ac44c8724cfc6ffd936fd8f897ae954
45 changes: 45 additions & 0 deletions src/Verify/Verifier/InnerVerifier_Inner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,51 @@ bool TryGetTargetBuilder(object? target, [NotNullWhen(true)] out StringBuilder?
return true;
}

bool TryGetTargetWithAppends(object? target, [NotNullWhen(true)] out object? result)
{
var appends = VerifierSettings.GetJsonAppenders(settings);

var hasAppends = appends.Any();

if (target is null)
{
if (!hasAppends)
{
result = null;
return false;
}

var infoBuilder = new InfoBuilder();

foreach (var append in appends)
{
infoBuilder.Add(append.Name, append.Data);
}

result = infoBuilder;
return true;
}
else
{
if (!hasAppends)
{
result = target;
return true;
}

var infoBuilder = new InfoBuilder();
infoBuilder.Add("target", target);

foreach (var append in appends)
{
infoBuilder.Add(append.Name, append.Data);
}

result = infoBuilder;
return true;
}
}

IEnumerable<Target> GetTargetList(IEnumerable<Target> targets)
{
foreach (var target in targets)
Expand Down