Skip to content

fix: remove struct constraint from Guard.Against.Expression to support reference types (#339) - #406

Open
Moha-sami wants to merge 1 commit into
ardalis:mainfrom
Moha-sami:fix-expression-reference-types
Open

fix: remove struct constraint from Guard.Against.Expression to support reference types (#339)#406
Moha-sami wants to merge 1 commit into
ardalis:mainfrom
Moha-sami:fix-expression-reference-types

Conversation

@Moha-sami

Copy link
Copy Markdown

Fixes #339

Summary

Removes the where T : struct constraint from Guard.Against.Expression<T> and Guard.Against.ExpressionAsync<T> so reference types (classes, strings, objects) can also be validated using custom expression predicates.

Details

  • Updated GuardAgainstExpressionExtensions.cs signatures.
  • Added unit tests in GuardAgainstExpression.cs verifying Guard.Against.Expression for reference types.
  • Verified all 959 unit tests pass cleanly.

@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

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.

Can we support Expression on refrence type not only struct

1 participant