Closed luboshl closed 2 months ago
Solution was not good. TypeDetailsCache
is instance class but is used as static field in MiniValidator
. Thus there was still only one instance and the problem with parallel access from multiple threads sometimes happened. Creation of instance of NonNullablePropertyHelper
was moved to the Visit
method before properties iteration in 07f4d60cb361c08d2ddfec7e88d9c26dfd5c500d.
NullabilityInfoContext
is not thread-safe (see i.e. https://github.com/dotnet/runtime/issues/100254). SoNonNullablePropertyHelper
was changed from static to instance class. For performance reasons instance is not created for every call to methodIsNonNullableReferenceType(property)
but it is created once inTypeDetailsCache
class.Previous solution with static class sometimes caused tests to fail because they run in parallel (see https://github.com/luboshl/MiniValidationPlus/actions/runs/9961358339/job/27522843648#step:7:42). The same could happen in application code.