From 118bd54c17de577e8fd51f426948bca8ccee7215 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Thu, 19 Feb 2026 00:08:13 +0000 Subject: [PATCH] fix: use continue instead of return in InstanceValuesInTestClassAnalyzer foreach loop In the foreach loop over fieldsAndProperties, a `return` statement was exiting the entire AnalyzeOperation method when the assignment target's containing type didn't match the test class. This should be `continue` to skip the current field/property and keep checking the remaining ones. Closes #4859 --- TUnit.Analyzers/InstanceValuesInTestClassAnalyzer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TUnit.Analyzers/InstanceValuesInTestClassAnalyzer.cs b/TUnit.Analyzers/InstanceValuesInTestClassAnalyzer.cs index b9f7c54306f..dfb2c585fd2 100644 --- a/TUnit.Analyzers/InstanceValuesInTestClassAnalyzer.cs +++ b/TUnit.Analyzers/InstanceValuesInTestClassAnalyzer.cs @@ -56,7 +56,7 @@ private void AnalyzeOperation(OperationAnalysisContext context) if (!SymbolEqualityComparer.Default.Equals(targetSymbol?.ContainingType, testClass)) { - return; + continue; } if (SymbolEqualityComparer.Default.Equals(targetSymbol, fieldOrProperty))