Skip to content

Fix for UnnecessaryDelegateConstraint#946

Merged
mikkelbu merged 1 commit intomasterfrom
Issue945_UnnecessaryDelelegatFix
Nov 2, 2025
Merged

Fix for UnnecessaryDelegateConstraint#946
mikkelbu merged 1 commit intomasterfrom
Issue945_UnnecessaryDelelegatFix

Conversation

@manfred-brands
Copy link
Copy Markdown
Member

Fixes #945

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issue #945 by correcting the logic in DelegateUnnecessaryAnalyzer to properly handle constraint expressions with multiple parts. The fix consolidates the constraint validation logic to avoid false positives when delayed constraints or throws constraints are present anywhere in the expression chain.

Key changes:

  • Refactored constraint checking logic from a loop to a single conditional check
  • Added test coverage for multi-part constraint expressions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/nunit.analyzers/DelegateUnnecessary/DelegateUnnecessaryAnalyzer.cs Refactored constraint validation to check all parts upfront and return early if any delayed constraint exists
src/nunit.analyzers.tests/DelegateUnnecessary/DelegateUnnecessaryAnalyzerTests.cs Added test cases for multi-part constraint expressions with Throws, Or, and After clauses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@manfred-brands manfred-brands force-pushed the Issue945_UnnecessaryDelelegatFix branch from 86fc926 to ede254c Compare November 1, 2025 00:48
Copy link
Copy Markdown
Member

@mikkelbu mikkelbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikkelbu mikkelbu merged commit 8a6f1c7 into master Nov 2, 2025
6 checks passed
@mikkelbu mikkelbu deleted the Issue945_UnnecessaryDelelegatFix branch November 2, 2025 09:07
@mikkelbu mikkelbu added this to the Release 4.11.2 milestone Nov 2, 2025
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.

[NUnit2057] Reported for Throws assert

3 participants