diff --git a/TUnit.Analyzers.CodeFixers/Base/AsyncMethodSignatureRewriter.cs b/TUnit.Analyzers.CodeFixers/Base/AsyncMethodSignatureRewriter.cs index 783a5d0021..02b9777f50 100644 --- a/TUnit.Analyzers.CodeFixers/Base/AsyncMethodSignatureRewriter.cs +++ b/TUnit.Analyzers.CodeFixers/Base/AsyncMethodSignatureRewriter.cs @@ -84,7 +84,7 @@ private static string GetMethodKey(MethodDeclarationSyntax node) // Build a key from class name, method name, and parameter types var className = node.Ancestors().OfType().FirstOrDefault()?.Identifier.Text ?? ""; var methodName = node.Identifier.Text; - var parameters = string.Join(",", node.ParameterList.Parameters.Select(p => p.Type?.ToString() ?? "")); + var parameters = string.Join(',', node.ParameterList.Parameters.Select(p => p.Type?.ToString() ?? "")); return $"{className}.{methodName}({parameters})"; } diff --git a/TUnit.Assertions.SourceGenerator/Generators/AssertionExtensionGenerator.cs b/TUnit.Assertions.SourceGenerator/Generators/AssertionExtensionGenerator.cs index fffcd9b3a8..5778c0cfc8 100644 --- a/TUnit.Assertions.SourceGenerator/Generators/AssertionExtensionGenerator.cs +++ b/TUnit.Assertions.SourceGenerator/Generators/AssertionExtensionGenerator.cs @@ -422,7 +422,7 @@ private static void GenerateExtensionMethod( if (allConstraints.Count > 0) { sourceBuilder.AppendLine(); - sourceBuilder.Append($" {string.Join(" ", allConstraints)}"); + sourceBuilder.Append($" {string.Join(' ', allConstraints)}"); } sourceBuilder.AppendLine(); diff --git a/TUnit.Assertions.SourceGenerator/Generators/AssertionMethodGenerator.cs b/TUnit.Assertions.SourceGenerator/Generators/AssertionMethodGenerator.cs index 406ef8fcca..9253661813 100644 --- a/TUnit.Assertions.SourceGenerator/Generators/AssertionMethodGenerator.cs +++ b/TUnit.Assertions.SourceGenerator/Generators/AssertionMethodGenerator.cs @@ -1167,7 +1167,7 @@ private static void GenerateMethod(StringBuilder sourceBuilder, string targetTyp { // Add generic constraints from the method sourceBuilder.AppendLine(); - sourceBuilder.Append($" {string.Join(" ", genericConstraints)}"); + sourceBuilder.Append($" {string.Join(' ', genericConstraints)}"); } sourceBuilder.AppendLine(); diff --git a/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs b/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs index be0db41b01..b88b7bda8e 100644 --- a/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs +++ b/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs @@ -1073,7 +1073,7 @@ private static string GenerateClassName(AssertionMethodData data) } // Include parameter types to distinguish overloads - var paramTypes = string.Join("_", data.AdditionalParameters.Select(p => p.SimpleTypeName)); + var paramTypes = string.Join('_', data.AdditionalParameters.Select(p => p.SimpleTypeName)); return $"{targetTypeName}_{methodName}_{paramTypes}_Assertion"; } diff --git a/TUnit.Assertions/Extensions/AssertionExtensions.cs b/TUnit.Assertions/Extensions/AssertionExtensions.cs index e681f86481..6163550a53 100644 --- a/TUnit.Assertions/Extensions/AssertionExtensions.cs +++ b/TUnit.Assertions/Extensions/AssertionExtensions.cs @@ -683,7 +683,7 @@ private static string GetMemberPath(Expression 0 ? string.Join(".", parts) : "Unknown"; + return parts.Count > 0 ? string.Join('.', parts) : "Unknown"; } /// diff --git a/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs b/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs index ba44c376b4..8690b1b911 100644 --- a/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs +++ b/TUnit.Core.SourceGenerator/Extensions/TypeExtensions.cs @@ -266,6 +266,6 @@ public static string GetNestedClassName(this INamedTypeSymbol typeSymbol) typeHierarchy.Reverse(); // Join with '+' separator (matching .NET Type.FullName convention for nested types) - return string.Join("+", typeHierarchy); + return string.Join('+', typeHierarchy); } } diff --git a/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs b/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs index 267ef14ab7..5528bc2561 100644 --- a/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs +++ b/TUnit.Core.SourceGenerator/Generators/HookMetadataGenerator.cs @@ -407,7 +407,7 @@ private static string GetSafeFileName(HookModel hook) // Only add if there are parameters (matches main branch behavior - no _0_ suffix for empty params) if (hook.Parameters.Length > 0) { - var paramTypes = string.Join("_", hook.Parameters.Select(p => SanitizeForFileName(GetSimpleTypeName(p.TypeName)))); + var paramTypes = string.Join('_', hook.Parameters.Select(p => SanitizeForFileName(GetSimpleTypeName(p.TypeName)))); baseName += $"__{paramTypes}"; } diff --git a/TUnit.Core.SourceGenerator/Generators/PropertyInjectionSourceGenerator.cs b/TUnit.Core.SourceGenerator/Generators/PropertyInjectionSourceGenerator.cs index 15e344efcb..0ba602ca70 100644 --- a/TUnit.Core.SourceGenerator/Generators/PropertyInjectionSourceGenerator.cs +++ b/TUnit.Core.SourceGenerator/Generators/PropertyInjectionSourceGenerator.cs @@ -1258,7 +1258,7 @@ private static string GetAssemblyQualifiedTypeName(ITypeSymbol typeSymbol) } } - return constraintParts.Count > 0 ? string.Join(" ", constraintParts) : null; + return constraintParts.Count > 0 ? string.Join(' ', constraintParts) : null; } #endregion diff --git a/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs b/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs index 1a5c0b939e..c88f2e1c93 100644 --- a/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs +++ b/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs @@ -3604,7 +3604,7 @@ private static string BuildTypeKey(IEnumerable types) { formattedTypes[i] = typesList[i].ToDisplayString(DisplayFormats.FullyQualifiedGenericWithoutGlobalPrefix); } - return string.Join(",", formattedTypes); + return string.Join(',', formattedTypes); } /// diff --git a/TUnit.Core/Extensions/ReflectionExtensions.cs b/TUnit.Core/Extensions/ReflectionExtensions.cs index 07b12e3a66..108a2d3328 100644 --- a/TUnit.Core/Extensions/ReflectionExtensions.cs +++ b/TUnit.Core/Extensions/ReflectionExtensions.cs @@ -13,7 +13,7 @@ internal static string GetFormattedName(this Type type) return type.Name; } - var genericArguments = string.Join(",", type.GetGenericArguments().Select(GetFormattedName)); + var genericArguments = string.Join(',', type.GetGenericArguments().Select(GetFormattedName)); var backtickIndex = type.Name.IndexOf("`", StringComparison.Ordinal); if (backtickIndex == -1) diff --git a/TUnit.Core/Extensions/TestContextExtensions.cs b/TUnit.Core/Extensions/TestContextExtensions.cs index cf842a8684..20fba78ece 100644 --- a/TUnit.Core/Extensions/TestContextExtensions.cs +++ b/TUnit.Core/Extensions/TestContextExtensions.cs @@ -72,7 +72,7 @@ public static string GetClassTypeName(this TestContext context) } hierarchy.Reverse(); - return string.Join("+", hierarchy); + return string.Join('+', hierarchy); } /// diff --git a/TUnit.Core/GenericTestMetadata.cs b/TUnit.Core/GenericTestMetadata.cs index 19f1950f1a..5f7d1ae91e 100644 --- a/TUnit.Core/GenericTestMetadata.cs +++ b/TUnit.Core/GenericTestMetadata.cs @@ -40,7 +40,7 @@ public override Func null, - TestNodeUidListFilter testNodeUidListFilter => string.Join(",", + TestNodeUidListFilter testNodeUidListFilter => string.Join(',', testNodeUidListFilter.TestNodeUids.Select(x => x.Value)), TreeNodeFilter treeNodeFilter => treeNodeFilter.Filter, _ => throw new ArgumentOutOfRangeException(nameof(filter)) diff --git a/TUnit.Engine/Services/TestFilterService.cs b/TUnit.Engine/Services/TestFilterService.cs index f16c784093..6c3a7a5800 100644 --- a/TUnit.Engine/Services/TestFilterService.cs +++ b/TUnit.Engine/Services/TestFilterService.cs @@ -271,6 +271,6 @@ internal static string GetNestedClassName(ClassMetadata classMetadata) } hierarchy.Reverse(); - return string.Join("+", hierarchy); + return string.Join('+', hierarchy); } } diff --git a/TUnit.Mocks.Http/RequestMatcher.cs b/TUnit.Mocks.Http/RequestMatcher.cs index 4c4ba92625..88c4707a31 100644 --- a/TUnit.Mocks.Http/RequestMatcher.cs +++ b/TUnit.Mocks.Http/RequestMatcher.cs @@ -181,8 +181,8 @@ internal string Describe() if (_exactPath != null) parts.Add(_exactPath); if (_pathPrefix != null) parts.Add($"{_pathPrefix}*"); if (_pathPattern != null) parts.Add($"~/{_pathPattern}/"); - if (_requiredHeaders.Count > 0) parts.Add($"headers:{string.Join(",", _requiredHeaders.Keys)}"); + if (_requiredHeaders.Count > 0) parts.Add($"headers:{string.Join(',', _requiredHeaders.Keys)}"); if (_bodyContains != null) parts.Add($"body contains \"{_bodyContains}\""); - return parts.Count > 0 ? string.Join(" ", parts) : "*"; + return parts.Count > 0 ? string.Join(' ', parts) : "*"; } } diff --git a/TUnit.Mocks.SourceGenerator/Builders/MockImplBuilder.cs b/TUnit.Mocks.SourceGenerator/Builders/MockImplBuilder.cs index 6a984d22e6..7c71fadfe2 100644 --- a/TUnit.Mocks.SourceGenerator/Builders/MockImplBuilder.cs +++ b/TUnit.Mocks.SourceGenerator/Builders/MockImplBuilder.cs @@ -992,7 +992,7 @@ private static string FormatConstraintClauses(EquatableArray 0 ? " " + string.Join(" ", clauses) : ""; + return clauses.Count > 0 ? " " + string.Join(' ', clauses) : ""; } /// @@ -1125,7 +1125,7 @@ public static string GetCompositeSafeName(MockTypeModel model) var name = model.FullyQualifiedName; if (model.AdditionalInterfaceNames.Length > 0) { - name += "_" + string.Join("_", model.AdditionalInterfaceNames); + name += "_" + string.Join('_', model.AdditionalInterfaceNames); } return GetSafeName(name); } diff --git a/TUnit.Mocks.SourceGenerator/Discovery/MemberDiscovery.cs b/TUnit.Mocks.SourceGenerator/Discovery/MemberDiscovery.cs index cb3d576d57..dbd2f74303 100644 --- a/TUnit.Mocks.SourceGenerator/Discovery/MemberDiscovery.cs +++ b/TUnit.Mocks.SourceGenerator/Discovery/MemberDiscovery.cs @@ -84,7 +84,7 @@ public static (EquatableArray Methods, EquatableArray p.Type.GetFullyQualifiedName())); + var paramTypes = string.Join(',', indexer.Parameters.Select(p => p.Type.GetFullyQualifiedName())); var key = $"I:[{paramTypes}]"; if (seenProperties.TryGetValue(key, out var existingIndex)) { @@ -183,7 +183,7 @@ public static (EquatableArray Methods, EquatableArray p.Type.GetFullyQualifiedName())); + var paramTypes = string.Join(',', indexer.Parameters.Select(p => p.Type.GetFullyQualifiedName())); var key = $"I:[{paramTypes}]"; if (seenProperties.TryGetValue(key, out var existingIndex)) { @@ -550,7 +550,7 @@ private static string ComputeUnwrappedSmartDefault(ITypeSymbol returnType, bool private static string GetMethodKey(IMethodSymbol method) { - var paramTypes = string.Join(",", method.Parameters.Select(p => + var paramTypes = string.Join(',', method.Parameters.Select(p => p.Type.GetFullyQualifiedName() + (p.RefKind != RefKind.None ? "&" : ""))); var typeParams = method.TypeParameters.Length > 0 ? $"`{method.TypeParameters.Length}" : ""; return $"M:{method.Name}{typeParams}({paramTypes})"; diff --git a/TUnit.Mocks.SourceGenerator/Extensions/TypeSymbolExtensions.cs b/TUnit.Mocks.SourceGenerator/Extensions/TypeSymbolExtensions.cs index 8b719cfce4..8643508e76 100644 --- a/TUnit.Mocks.SourceGenerator/Extensions/TypeSymbolExtensions.cs +++ b/TUnit.Mocks.SourceGenerator/Extensions/TypeSymbolExtensions.cs @@ -118,13 +118,13 @@ private static string GetMemberKey(ISymbol member) { if (member is IMethodSymbol method) { - var paramTypes = string.Join(",", method.Parameters.Select(p => p.Type.GetFullyQualifiedName() + (p.RefKind != RefKind.None ? "&" : ""))); + var paramTypes = string.Join(',', method.Parameters.Select(p => p.Type.GetFullyQualifiedName() + (p.RefKind != RefKind.None ? "&" : ""))); var typeParams = method.TypeParameters.Length > 0 ? $"`{method.TypeParameters.Length}" : ""; return $"M:{method.Name}{typeParams}({paramTypes})"; } if (member is IPropertySymbol prop) { - var paramTypes = string.Join(",", prop.Parameters.Select(p => p.Type.GetFullyQualifiedName())); + var paramTypes = string.Join(',', prop.Parameters.Select(p => p.Type.GetFullyQualifiedName())); return prop.Parameters.Length > 0 ? $"P:{prop.Name}[{paramTypes}]" : $"P:{prop.Name}"; } if (member is IEventSymbol evt) diff --git a/TUnit.Mocks/Mock.cs b/TUnit.Mocks/Mock.cs index 2013837af9..132c7eb29c 100644 --- a/TUnit.Mocks/Mock.cs +++ b/TUnit.Mocks/Mock.cs @@ -286,7 +286,7 @@ public static bool TryCreateAutoMock(Type type, MockBehavior behavior, out IMock private static string GetMultiKey(params Type[] types) { - return string.Join("|", types.Select(t => t.FullName ?? t.ToString())); + return string.Join('|', types.Select(t => t.FullName ?? t.ToString())); } ///