Skip to content

Commit 1661da3

Browse files
committed
Cleanup: String interpolation
1 parent e24d963 commit 1661da3

16 files changed

+27
-28
lines changed

src/Exceptionless/Configuration/ExceptionlessConfiguration.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public void AddPlugin<T>(T plugin) where T : IEventPlugin {
388388
RemovePlugin(key);
389389

390390
if (!_plugins.TryAdd(key, new PluginRegistration(key, GetPriority(typeof(T)), new Lazy<IEventPlugin>(() => plugin))))
391-
Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key));
391+
Resolver.GetLog().Error($"Unable to add plugin: {key}");
392392
}
393393

394394
/// <summary>
@@ -409,7 +409,7 @@ public void AddPlugin(string key, Type pluginType) {
409409

410410
var plugin = new PluginRegistration(key, GetPriority(pluginType), new Lazy<IEventPlugin>(() => Resolver.Resolve(pluginType) as IEventPlugin));
411411
if (!_plugins.TryAdd(key, plugin))
412-
Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key));
412+
Resolver.GetLog().Error($"Unable to add plugin: {key}");
413413
}
414414

415415
/// <summary>
@@ -432,7 +432,7 @@ public void AddPlugin(string key, int priority, Func<ExceptionlessConfiguration,
432432

433433
var plugin = new PluginRegistration(key, priority, new Lazy<IEventPlugin>(() => factory(this)));
434434
if (!_plugins.TryAdd(key, plugin))
435-
Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key));
435+
Resolver.GetLog().Error($"Unable to add plugin: {key}");
436436
}
437437

438438
/// <summary>
@@ -463,7 +463,7 @@ public void AddPlugin(string key, int priority, Action<EventPluginContext> plugi
463463

464464
var plugin = new PluginRegistration(key, priority, new Lazy<IEventPlugin>(() => new ActionPlugin(pluginAction)));
465465
if (!_plugins.TryAdd(key, plugin))
466-
Resolver.GetLog().Error(String.Format("Unable to add plugin: {0}", key));
466+
Resolver.GetLog().Error($"Unable to add plugin: {key}");
467467
}
468468

469469
/// <summary>
@@ -520,7 +520,7 @@ public ValidationResult Validate() {
520520
result.Messages.Add("ApiKey is not set.");
521521

522522
if (key != null && (key.Length < 10 || key.Contains(" ")))
523-
result.Messages.Add(String.Format("ApiKey \"{0}\" is not valid.", key));
523+
result.Messages.Add($"ApiKey \"{key}\" is not valid.");
524524

525525
if (String.IsNullOrEmpty(ServerUrl))
526526
result.Messages.Add("ServerUrl is not set.");
@@ -561,7 +561,7 @@ public IEventPlugin Plugin {
561561
}
562562

563563
public override string ToString() {
564-
return String.Format("Key: {0}, Priority: {1}", Key, Priority);
564+
return $"Key: {Key}, Priority: {Priority}";
565565
}
566566

567567
public void Dispose() {

src/Exceptionless/Extensions/DataDictionaryExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static T GetValue<T>(this DataDictionary items, string key, IJsonSerializ
1616

1717
object data;
1818
if (!items.TryGetValue(key, out data))
19-
throw new KeyNotFoundException(String.Format("The key '{0}' was not found.", key));
19+
throw new KeyNotFoundException($"The key '{key}' was not found.");
2020

2121
if (data == null || data is T)
2222
return (T)data;

src/Exceptionless/Extensions/EventExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public static string GetEventReference(this Event ev, string name) {
237237
if (ev == null || String.IsNullOrEmpty(name))
238238
return null;
239239

240-
return ev.Data.GetString(String.Format("@ref:{0}", name));
240+
return ev.Data.GetString($"@ref:{name}");
241241
}
242242

243243
/// <summary>
@@ -253,7 +253,7 @@ public static void SetEventReference(this Event ev, string name, string id) {
253253
if (!IsValidIdentifier(id) || String.IsNullOrEmpty(id))
254254
throw new ArgumentException("Id must contain between 8 and 100 alphanumeric or '-' characters.", "id");
255255

256-
ev.SetProperty(String.Format("@ref:{0}", name), id);
256+
ev.SetProperty($"@ref:{name}", id);
257257
}
258258

259259
private static bool IsValidIdentifier(string value) {

src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,20 +352,20 @@ public static void ReadFromConfigSection(this ExceptionlessConfiguration config)
352352

353353
Type resolverInterface = types.FirstOrDefault(t => t.Name.Equals(resolver.Service) || t.FullName.Equals(resolver.Service));
354354
if (resolverInterface == null) {
355-
config.Resolver.GetLog().Error(typeof(ExceptionlessConfigurationExtensions), String.Format("Error retrieving service type \"{0}\".", resolver.Service));
355+
config.Resolver.GetLog().Error(typeof(ExceptionlessConfigurationExtensions), $"Error retrieving service type \"{resolver.Service}\".");
356356
continue;
357357
}
358358

359359
try {
360360
Type implementationType = Type.GetType(resolver.Type);
361361
if (!resolverInterface.IsAssignableFrom(implementationType)) {
362-
config.Resolver.GetLog().Error(typeof(ExceptionlessConfigurationExtensions), String.Format("Type \"{0}\" does not implement \"{1}\".", resolver.Type, resolver.Service));
362+
config.Resolver.GetLog().Error(typeof(ExceptionlessConfigurationExtensions), $"Type \"{resolver.Type}\" does not implement \"{resolver.Service}\".");
363363
continue;
364364
}
365365

366366
config.Resolver.Register(resolverInterface, implementationType);
367367
} catch (Exception ex) {
368-
config.Resolver.GetLog().Error(typeof(ExceptionlessConfigurationExtensions), ex, String.Format("An error occurred while registering service \"{0}\" implementation \"{1}\".", resolver.Service, resolver.Type));
368+
config.Resolver.GetLog().Error(typeof(ExceptionlessConfigurationExtensions), ex, $"An error occurred while registering service \"{resolver.Service}\" implementation \"{resolver.Type}\".");
369369
}
370370
}
371371
}

src/Exceptionless/Extensions/FileStorageExtensions.cs

Lines changed: 4 additions & 5 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.IO;
44
using System.Linq;
@@ -32,11 +32,10 @@ public static ICollection<ObjectInfo> GetQueueFiles(this IObjectStorage storage,
3232
public static bool IncrementAttempts(this IObjectStorage storage, ObjectInfo info) {
3333
string[] parts = info.Path.Split('.');
3434
if (parts.Length < 3)
35-
throw new ArgumentException(String.Format("Path \"{0}\" must contain the number of attempts.", info.Path));
35+
throw new ArgumentException($"Path \"{info.Path}\" must contain the number of attempts.");
3636

37-
int version;
38-
if (!Int32.TryParse(parts[1], out version))
39-
throw new ArgumentException(String.Format("Path \"{0}\" must contain the number of attempts.", info.Path));
37+
if (!Int32.TryParse(parts[1], out int version))
38+
throw new ArgumentException($"Path \"{info.Path}\" must contain the number of attempts.");
4039

4140
version++;
4241
string newpath = String.Join(".", parts[0], version, parts[2]);

src/Exceptionless/Extensions/ToErrorModelExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private static bool ValueIsEmpty(object value) {
134134
};
135135

136136
private static string GetMessage(this Exception exception, string typeName) {
137-
string defaultMessage = String.Format("Exception of type '{0}' was thrown.", typeName);
137+
string defaultMessage = $"Exception of type '{typeName}' was thrown.";
138138
string message = !String.IsNullOrEmpty(exception.Message) ? exception.Message.Trim() : null;
139139
return !String.IsNullOrEmpty(message) ? message : defaultMessage;
140140
}

src/Exceptionless/Extensions/ToSimpleErrorModelExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static bool ValueIsEmpty(object value) {
104104
}
105105

106106
private static string GetMessage(this Exception exception, string typeName) {
107-
string defaultMessage = String.Format("Exception of type '{0}' was thrown.", typeName);
107+
string defaultMessage = $"Exception of type '{typeName}' was thrown.";
108108
string message = !String.IsNullOrEmpty(exception.Message) ? exception.Message.Trim() : null;
109109

110110
return !String.IsNullOrEmpty(message) ? message : defaultMessage;

src/Exceptionless/Plugins/Default/010_EventExclusionPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void Run(EventPluginContext context) {
3131
}
3232

3333
if (!context.Client.Configuration.Settings.GetTypeAndSourceEnabled(context.Event.Type, context.Event.Source)) {
34-
context.Log.Info(String.Format("Cancelling event from excluded type: {0} and source: {1}", context.Event.Type, context.Event.Source));
34+
context.Log.Info($"Cancelling event from excluded type: {context.Event.Type} and source: {context.Event.Source}");
3535
context.Cancel = true;
3636
return;
3737
}

src/Exceptionless/Queue/DefaultEventQueue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void SuspendProcessing(TimeSpan? duration = null, bool discardFutureQueue
141141
if (!duration.HasValue)
142142
duration = TimeSpan.FromMinutes(5);
143143

144-
_log.Info(typeof(DefaultEventQueue), String.Format("Suspending processing for: {0}.", duration.Value));
144+
_log.Info(typeof(DefaultEventQueue), $"Suspending processing for: {duration.Value}.");
145145
_suspendProcessingUntil = DateTime.Now.Add(duration.Value);
146146
_queueTimer.Change(duration.Value, _processQueueInterval);
147147

src/Exceptionless/Utility/AssemblyHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static List<Type> GetTypes(IExceptionlessLog log) {
3636

3737
types.AddRange(assembly.GetExportedTypes());
3838
} catch (Exception ex) {
39-
log.Error(typeof(AssemblyHelper), ex, String.Format("An error occurred while getting types for assembly \"{0}\".", assembly));
39+
log.Error(typeof(AssemblyHelper), ex, $"An error occurred while getting types for assembly \"{assembly}\".");
4040
}
4141
}
4242

0 commit comments

Comments
 (0)