Skip to content

Conversation

@SimonCropp
Copy link
Contributor

PrettyMarkupFormatter is not thread safe

VerifyTests/Verify.Bunit#60

@egil
Copy link
Member

egil commented Nov 13, 2024

Thanks Simon. The particular use in bUnit is actually thread-safe, as the Attribute writing method does not rely on any state, but I am fine with instantiating the class here and add the obsolete flag, so other users dont assume the static instance is thread safe.

@linkdotnet any objections to merging this?

@SimonCropp
Copy link
Contributor Author

@egil

The particular use in bUnit is actually thread-safe,

r u certain? is it not possible to call ToMarkupElementOnly from multiple threads?

@egil
Copy link
Member

egil commented Nov 14, 2024

@egil

The particular use in bUnit is actually thread-safe,

r u certain? is it not possible to call ToMarkupElementOnly from multiple threads?

As far as I can tell, ConvertToString(attribute) calls base.Attribute(), and that method has no references to fields in the base class. Thus, I think it is safe.

@linkdotnet linkdotnet merged commit 9197071 into bUnit-dev:main Dec 13, 2024
10 checks passed
@SimonCropp SimonCropp deleted the PrettyMarkupFormatter-is-not-thread-safe branch December 14, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants