Skip to content

Commit 50fe66f

Browse files
committed
Use more string interpolation
1 parent 099bc30 commit 50fe66f

File tree

8 files changed

+14
-17
lines changed

8 files changed

+14
-17
lines changed

src/Examples/DapperExample/TranslationToSql/Builders/SqlQueryBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ private void WriteColumn(ColumnNode column, bool isVirtualColumn, StringBuilder
306306
{
307307
foreach (char specialCharacter in SpecialCharactersInLike)
308308
{
309-
safeValue = safeValue.Replace(specialCharacter.ToString(), @"\" + specialCharacter);
309+
safeValue = safeValue.Replace(specialCharacter.ToString(), $@"\{specialCharacter}");
310310
}
311311
}
312312

src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ private static void SetRelationshipTypes(ResourceGraph resourceGraph)
7272

7373
if (rightType == null)
7474
{
75-
throw new InvalidConfigurationException($"Resource type '{relationship.LeftType.ClrType}' depends on " +
76-
$"'{rightClrType}', which was not added to the resource graph.");
75+
throw new InvalidConfigurationException(
76+
$"Resource type '{relationship.LeftType.ClrType}' depends on '{rightClrType}', which was not added to the resource graph.");
7777
}
7878

7979
relationship.RightType = rightType;
@@ -129,8 +129,8 @@ private static void ValidateAttributesInDerivedType(ResourceType resourceType)
129129
{
130130
if (resourceType.FindAttributeByPublicName(attribute.PublicName) == null)
131131
{
132-
throw new InvalidConfigurationException($"Attribute '{attribute.PublicName}' from base type " +
133-
$"'{resourceType.BaseType.ClrType}' does not exist in derived type '{resourceType.ClrType}'.");
132+
throw new InvalidConfigurationException(
133+
$"Attribute '{attribute.PublicName}' from base type '{resourceType.BaseType.ClrType}' does not exist in derived type '{resourceType.ClrType}'.");
134134
}
135135
}
136136
}
@@ -141,8 +141,8 @@ private static void ValidateRelationshipsInDerivedType(ResourceType resourceType
141141
{
142142
if (resourceType.FindRelationshipByPublicName(relationship.PublicName) == null)
143143
{
144-
throw new InvalidConfigurationException($"Relationship '{relationship.PublicName}' from base type " +
145-
$"'{resourceType.BaseType.ClrType}' does not exist in derived type '{resourceType.ClrType}'.");
144+
throw new InvalidConfigurationException(
145+
$"Relationship '{relationship.PublicName}' from base type '{resourceType.BaseType.ClrType}' does not exist in derived type '{resourceType.ClrType}'.");
146146
}
147147
}
148148
}

src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public void Apply(ApplicationModel application)
101101

102102
if (resourceType == null)
103103
{
104-
throw new InvalidConfigurationException($"Controller '{controller.ControllerType}' depends on " +
105-
$"resource type '{resourceClrType}', which does not exist in the resource graph.");
104+
throw new InvalidConfigurationException(
105+
$"Controller '{controller.ControllerType}' depends on resource type '{resourceClrType}', which does not exist in the resource graph.");
106106
}
107107

108108
if (_controllerPerResourceTypeMap.TryGetValue(resourceType, out ControllerModel? existingModel))

src/JsonApiDotNetCore/Serialization/Request/Adapters/DocumentInOperationsRequestAdapter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ private void AssertMaxOperationsNotExceeded(IList<AtomicOperationObject?> atomic
4747
if (atomicOperationObjects.Count > _options.MaximumOperationsPerRequest)
4848
{
4949
throw new ModelConversionException(state.Position, "Too many operations in request.",
50-
$"The number of operations in this request ({atomicOperationObjects.Count}) is higher " +
51-
$"than the maximum of {_options.MaximumOperationsPerRequest}.");
50+
$"The number of operations in this request ({atomicOperationObjects.Count}) is higher than the maximum of {_options.MaximumOperationsPerRequest}.");
5251
}
5352
}
5453

src/JsonApiDotNetCore/Serialization/Request/NotSupportedExceptionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static JsonApiException EnrichSourcePointer(this NotSupportedException ex
4848
}
4949
else
5050
{
51-
error.Source.Pointer = sourcePointer + '/' + error.Source.Pointer;
51+
error.Source.Pointer = $"{sourcePointer}/{error.Source.Pointer}";
5252
}
5353
}
5454
}

test/DapperTests/UnitTests/LogicalCombinatorTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void Collapses_and_filters()
4343
conditionRight3
4444
}.Select(condition => condition.ToString());
4545

46-
string expectedText = '(' + string.Join(") AND (", terms) + ')';
46+
string expectedText = $"({string.Join(") AND (", terms)})";
4747
result.ToString().Should().Be(expectedText);
4848
}
4949
}

test/DapperTests/UnitTests/ParameterNodeTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public void Can_format_parameter(object? parameterValue, string formattedValueEx
4040
string text = parameter.ToString();
4141

4242
// Assert
43-
text.Should().Be("@name = " + formattedValueExpected);
43+
text.Should().Be($"@name = {formattedValueExpected}");
4444
}
4545
}

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
592592
await dbContext.SaveChangesAsync();
593593
});
594594

595-
string routePrefix = $"/blogPosts?filter=equals(author.userName,'{account.UserName}')" +
596-
"&fields[webAccounts]=userName&include=author&sort=id&foo=bar,baz";
597-
595+
string routePrefix = $"/blogPosts?filter=equals(author.userName,'{account.UserName}')&fields[webAccounts]=userName&include=author&sort=id&foo=bar,baz";
598596
string route = $"{routePrefix}&page[number]={pageNumber}";
599597

600598
// Act

0 commit comments

Comments
 (0)