Skip to content

Commit f95c259

Browse files
authored
Merge pull request #173 from servicetitan/upstream_StringInterpolation
Convert string.Format() to string interpolation (#44)
2 parents cc29867 + 08a3d14 commit f95c259

File tree

99 files changed

+189
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+189
-223
lines changed

Extensions/Xtensive.Orm.BulkOperations.Tests/Issues/IssueJira0565_IgnoringTakeMethodOnTranslation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2015 Xtensive LLC.
1+
// Copyright (C) 2015 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Alexey Kulakov
@@ -307,7 +307,7 @@ private static void IgnoreMe(string format, object argument, string reason = nul
307307
{
308308
var message = string.Format(format, argument);
309309
if (!string.IsNullOrEmpty(reason)) {
310-
message = string.Format("{0}. Reason: {1}", message, reason);
310+
message = $"{message}. Reason: {reason}";
311311
}
312312

313313
throw new IgnoreException(message);

Extensions/Xtensive.Orm.BulkOperations/Internals/ExpressionVisitor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019-2020 Xtensive LLC.
1+
// Copyright (C) 2019-2020 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44

@@ -115,7 +115,7 @@ protected virtual Expression Visit(Expression exp)
115115
case ExpressionType.ListInit:
116116
return VisitListInit((ListInitExpression) exp);
117117
default:
118-
throw new Exception(String.Format("Unhandled expression type: '{0}'", exp.NodeType));
118+
throw new Exception($"Unhandled expression type: '{exp.NodeType}'");
119119
}
120120
}
121121

@@ -142,7 +142,7 @@ private MemberBinding VisitBinding(MemberBinding binding)
142142
case MemberBindingType.ListBinding:
143143
return VisitMemberListBinding((MemberListBinding) binding);
144144
default:
145-
throw new Exception(String.Format("Unhandled binding type '{0}'", binding.BindingType));
145+
throw new Exception($"Unhandled binding type '{binding.BindingType}'");
146146
}
147147
}
148148

Extensions/Xtensive.Orm.Security/GenericPrincipal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public virtual void SetPassword(string password)
3232
var service = Session.Services.Get<IHashingService>(config.HashingServiceName);
3333

3434
if (service == null)
35-
throw new InvalidOperationException(string.Format("Hashing service by name {0} is not found. Check Xtensive.Security configuration", config.HashingServiceName));
35+
throw new InvalidOperationException($"Hashing service by name {config.HashingServiceName} is not found. Check Xtensive.Security configuration");
3636

3737
PasswordHash = service.ComputeHash(password);
3838
}

Extensions/Xtensive.Orm.Security/Services/GenericAuthenticationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected virtual IPrincipal Authenticate(string username, string password)
5353
var service = Session.Services.Get<IHashingService>(config.HashingServiceName);
5454

5555
if (service == null)
56-
throw new InvalidOperationException(string.Format("Hashing service by name {0} is not found. Check Xtensive.Security configuration", config.HashingServiceName));
56+
throw new InvalidOperationException($"Hashing service by name {config.HashingServiceName} is not found. Check Xtensive.Security configuration");
5757

5858
// GenericPrincipal is not in the model, let's find its descendant
5959
var model = Session.Domain.Model;

Extensions/Xtensive.Orm.Tracking.Tests/Model/MyStructure.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
@@ -18,7 +18,7 @@ public MyStructure() : base() { }
1818
public MyStructure(Session session) : base(session) {}
1919
public override string ToString()
2020
{
21-
return string.Format("MyEntityStructure: Z={0}, SubStructure=({1})", Z, SubStructure);
21+
return $"MyEntityStructure: Z={Z}, SubStructure=({SubStructure})";
2222
}
2323
}
2424

@@ -34,7 +34,7 @@ public MyEntitySubStructure() : base() { }
3434
public MyEntitySubStructure(Session session) : base(session) { }
3535
public override string ToString()
3636
{
37-
return string.Format("MyEntitySubStructure: X={0}, Y={1}", X, Y);
37+
return $"MyEntitySubStructure: X={X}, Y={Y}";
3838
}
3939
}
4040
}

Orm/Xtensive.Orm.Manual/Advanced/CustomLinqCompilerTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ public class Person : Entity
3535

3636
public string FullName
3737
{
38-
get { return string.Format("{0} {1}", FirstName, LastName); }
38+
get { return $"{FirstName} {LastName}"; }
3939
}
4040

4141
public string FullName2
4242
{
43-
get { return string.Format("{0} {1}", FirstName, LastName); }
43+
get { return $"{FirstName} {LastName}"; }
4444
}
4545

4646
public string AddPrefix(string prefix)
4747
{
48-
return string.Format("{0}{1}", prefix, LastName);
48+
return $"{prefix}{LastName}";
4949
}
5050

5151
public Person(Session session)

Orm/Xtensive.Orm.Manual/Advanced/CustomSqlCompilerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static char GetThirdChar(this string source)
6767

6868
public static string BuildAddressString(string country, string city, string building)
6969
{
70-
return string.Format("{0}, {1}-{2}", country, city, building);
70+
return $"{country}, {city}-{building}";
7171
}
7272
}
7373

Orm/Xtensive.Orm.Manual/Caching/CalculatedValueCachingTest.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public class Product : Entity
3737

3838
public override string ToString()
3939
{
40-
return string.Format("Product #{0}, Name={1}, Orders.Count={2}",
41-
Id, Name, Orders.Count);
40+
return $"Product #{Id}, Name={Name}, Orders.Count={Orders.Count}";
4241
}
4342

4443
public Product(Session session)
@@ -99,8 +98,7 @@ public double TotalPriceCached {
9998

10099
public override string ToString()
101100
{
102-
return string.Format("Order #{0}, Product={1}, Quantity={2}",
103-
Id, Product.Name, Quantity);
101+
return $"Order #{Id}, Product={Product.Name}, Quantity={Quantity}";
104102
}
105103

106104
public Order(Session session)

Orm/Xtensive.Orm.Manual/Concurrency/LockingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private void TestThread(object state)
109109
var startTime = DateTime.UtcNow;
110110
var threadNumber = Interlocked.Increment(ref threadCount);
111111
try {
112-
string threadName = string.Format("Thread {0}", threadNumber).Indent(2 + (int) (threadNumber - 1) * 5);
112+
string threadName = $"Thread {threadNumber}".Indent(2 + (int) (threadNumber - 1) * 5);
113113
using (var session = GetDomain().OpenSession()) {
114114
while ((DateTime.UtcNow - startTime).TotalMilliseconds < TestTime) {
115115
try {

Orm/Xtensive.Orm.MySql/Sql.Drivers.MySql/Connection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2011-2020 Xtensive LLC.
1+
// Copyright (C) 2011-2020 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Malisa Ncube
@@ -99,7 +99,7 @@ public override Task ReleaseSavepointAsync(string name, CancellationToken token
9999
private static string GetCreateSavepointCommandText(string name) => $"SAVEPOINT {name}";
100100

101101
private static string GetRollbackToSavepointCommandText(string name) =>
102-
string.Format("ROLLBACK TO SAVEPOINT {0}; RELEASE SAVEPOINT {0};", name);
102+
$"ROLLBACK TO SAVEPOINT {name}; RELEASE SAVEPOINT {name};";
103103

104104
private static string GetReleaseSavepointCommandText(string name) => $"RELEASE SAVEPOINT {name}";
105105

0 commit comments

Comments
 (0)