diff --git a/src/bunit.web/Diffing/DiffMarkupFormatter.cs b/src/bunit.web/Diffing/DiffMarkupFormatter.cs index ccb033627..4feffd455 100644 --- a/src/bunit.web/Diffing/DiffMarkupFormatter.cs +++ b/src/bunit.web/Diffing/DiffMarkupFormatter.cs @@ -16,6 +16,7 @@ public class DiffMarkupFormatter : PrettyMarkupFormatter, IMarkupFormatter /// The is not thread safe, so using this singleton /// instance to format elements may not result in the desired effect. /// + [Obsolete("This instance is not thread safe, use a new instance instead.")] public static new readonly DiffMarkupFormatter Instance = new(); /// diff --git a/src/bunit.web/Extensions/NodePrintExtensions.cs b/src/bunit.web/Extensions/NodePrintExtensions.cs index c54924824..d113d2642 100644 --- a/src/bunit.web/Extensions/NodePrintExtensions.cs +++ b/src/bunit.web/Extensions/NodePrintExtensions.cs @@ -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); @@ -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)