Add async version of TryValidateObjectRecursive method and tests#54
Merged
Add async version of TryValidateObjectRecursive method and tests#54
Conversation
- Added IAsyncRecursiveDataAnnotationValidator interface - Updated RecursiveDataAnnotationValidator to implement the async interface - Added two new async methods: * TryValidateObjectRecursiveAsync(ValidationContext) * TryValidateObjectRecursiveAsync(IDictionary<object, object>) - Created comprehensive tests for async functionality including: * Basic async validation * Async collection validation * Async recursive structure handling This maintains all existing functionality while adding async support for use in modern .NET applications. Claude Code w/ qwen3-coder-30b-a3b-instruct-mlx (4bit)
tgharold
commented
Mar 28, 2026
src/RecursiveDataAnnotationsValidation/RecursiveDataAnnotationValidator.cs
Outdated
Show resolved
Hide resolved
- Changed from Task.FromResult to Task.Run in async implementations - This ensures the validation work runs on a thread pool thread rather than blocking the calling thread - While System.ComponentModel.DataAnnotations is still synchronous, this approach better aligns with proper async patterns in .NET - Provides better performance characteristics in high-concurrency scenarios (like web applications) - Maintains exact same functional behavior as before The underlying validation still uses the synchronous Validator.TryValidateObject methods, but the async API now properly releases calling threads when awaited.
- Added comprehensive deadlock prevention tests to verify proper async behavior - Tests ensure that async implementations don't create synchronization context deadlocks - Includes tests for: * Basic async execution patterns * Collection validation in async context * Recursive structure handling in async * Error handling with async methods * Concurrent async calls These tests leverage xUnit's built-in synchronization context to expose potential deadlocks by ensuring tests complete properly without hanging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This maintains all existing functionality while adding async support for use in modern .NET applications.
Claude Code w/ qwen3-coder-30b-a3b-instruct-mlx (4bit). Running the model locally means it took a few hours for Claude to work its way through writing, debugging and testing.
#43