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

remove static uses of PrettyMarkupFormatter #1609

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/bunit.web/Diffing/DiffMarkupFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DiffMarkupFormatter : PrettyMarkupFormatter, IMarkupFormatter
/// The <see cref="DiffMarkupFormatter"/> is not thread safe, so using this singleton
/// instance to format elements may not result in the desired effect.
/// </remarks>
[Obsolete("This instance is not thread safe, use a new instance instead.")]
public static new readonly DiffMarkupFormatter Instance = new();

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/bunit.web/Extensions/NodePrintExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public static string ToMarkupElementOnly(this IElement element)
if (element is null)
throw new ArgumentNullException(nameof(element));

var diffMarkupFormatter = new DiffMarkupFormatter();
var result = new StringBuilder();
result.Append(Symbols.LessThan);

Expand All @@ -120,7 +121,7 @@ public static string ToMarkupElementOnly(this IElement element)

foreach (var attribute in element.Attributes)
{
result.Append(' ').Append(DiffMarkupFormatter.Instance.ConvertToString(attribute));
result.Append(' ').Append(diffMarkupFormatter.ConvertToString(attribute));
}

if (element.HasChildNodes)
Expand Down