Skip to content

Commit 4e5d2d2

Browse files
committed
Client cleanup
1 parent 8943396 commit 4e5d2d2

28 files changed

+75
-91
lines changed

Source/Extras/Extensions/ExceptionlessExtraConfigurationExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ public static void ReadFromConfigSection(this ExceptionlessConfiguration config)
9898
if (!String.IsNullOrEmpty(section.ServerUrl))
9999
config.ServerUrl = section.ServerUrl;
100100

101-
if (section.EnableSSL.HasValue)
102-
config.EnableSSL = section.EnableSSL.Value;
103-
104101
if (section.QueueMaxAge.HasValue)
105102
config.QueueMaxAge = section.QueueMaxAge.Value;
106103

@@ -145,20 +142,20 @@ public static void ReadFromConfigSection(this ExceptionlessConfiguration config)
145142

146143
Type resolverInterface = types.FirstOrDefault(t => t.Name.Equals(resolver.Service) || t.FullName.Equals(resolver.Service));
147144
if (resolverInterface == null) {
148-
config.Resolver.GetLog().Error(typeof(ExceptionlessExtraConfigurationExtensions), String.Format("An error occurred while retrieving service type \"{0}\".", resolver.Service));
145+
config.Resolver.GetLog().Error(typeof(ExceptionlessExtraConfigurationExtensions), $"An error occurred while retrieving service type \"{resolver.Service}\".");
149146
continue;
150147
}
151148

152149
try {
153150
Type implementationType = Type.GetType(resolver.Type);
154151
if (!resolverInterface.IsAssignableFrom(implementationType)) {
155-
config.Resolver.GetLog().Error(typeof(ExceptionlessExtraConfigurationExtensions), String.Format("Type \"{0}\" does not implement \"{1}\".", resolver.Type, resolver.Service));
152+
config.Resolver.GetLog().Error(typeof(ExceptionlessExtraConfigurationExtensions), $"Type \"{resolver.Type}\" does not implement \"{resolver.Service}\".");
156153
continue;
157154
}
158155

159156
config.Resolver.Register(resolverInterface, implementationType);
160157
} catch (Exception ex) {
161-
config.Resolver.GetLog().Error(typeof(ExceptionlessExtraConfigurationExtensions), ex, String.Format("An error occurred while registering service \"{0}\" implementation \"{1}\".", resolver.Service, resolver.Type));
158+
config.Resolver.GetLog().Error(typeof(ExceptionlessExtraConfigurationExtensions), ex, $"An error occurred while registering service \"{resolver.Service}\" implementation \"{resolver.Type}\".");
162159
}
163160
}
164161
}
@@ -207,7 +204,7 @@ private static string GetEnvironmentalVariable(string name) {
207204
if (_environmentVariables == null) {
208205
try {
209206
_environmentVariables = Environment.GetEnvironmentVariables().Cast<DictionaryEntry>().ToDictionary(e => e.Key.ToString(), e => e.Value.ToString());
210-
} catch (Exception ex) {
207+
} catch (Exception) {
211208
_environmentVariables = new Dictionary<string, string>();
212209
return null;
213210
}

Source/Extras/Extensions/ToErrorModelExtensions.cs

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

116116
private static string GetMessage(this Exception exception) {
117-
string defaultMessage = String.Format("Exception of type '{0}' was thrown.", exception.GetType().FullName);
117+
string defaultMessage = $"Exception of type '{exception.GetType().FullName}' was thrown.";
118118
string message = !String.IsNullOrEmpty(exception.Message) ? String.Join(" ", exception.Message.Split(new[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)).Trim() : null;
119119

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

Source/Extras/Submission/SubmissionClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public SubmissionResponse PostUserDescription(string referenceId, UserDescriptio
4747

4848
HttpWebResponse response;
4949
try {
50-
var request = CreateHttpWebRequest(config, String.Format("events/by-ref/{0}/user-description", referenceId));
50+
var request = CreateHttpWebRequest(config, $"events/by-ref/{referenceId}/user-description");
5151
response = request.PostJsonAsyncWithCompression(data).Result as HttpWebResponse;
5252
} catch (AggregateException aex) {
5353
var ex = aex.GetInnermostException() as WebException;
@@ -77,7 +77,7 @@ public SettingsResponse GetSettings(ExceptionlessConfiguration config, IJsonSeri
7777
}
7878

7979
if (response == null || response.StatusCode != HttpStatusCode.OK)
80-
return new SettingsResponse(false, message: String.Format("Unable to retrieve configuration settings: {0}", GetResponseMessage(response)));
80+
return new SettingsResponse(false, message: $"Unable to retrieve configuration settings: {GetResponseMessage(response)}");
8181

8282
var json = response.GetResponseText();
8383
if (String.IsNullOrWhiteSpace(json))
@@ -127,7 +127,7 @@ private static void ConfigureServicePointManagerSettings() {
127127
ServicePointManager.Expect100Continue = false;
128128
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
129129
} catch (Exception ex) {
130-
Trace.WriteLine(String.Format("An error occurred while configuring SSL certificate validation. Exception: {0}", ex));
130+
Trace.WriteLine($"An error occurred while configuring SSL certificate validation. Exception: {ex}");
131131
}
132132
}
133133
}

Source/Extras/Utility/AssemblyHelper.cs

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

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

Source/Extras/Utility/SingleGlobalInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class SingleGlobalInstance : IDisposable {
1212
private static readonly ConcurrentDictionary<string, WaitHandle> _namedLocks = new ConcurrentDictionary<string, WaitHandle>();
1313

1414
private void InitWaitHandle() {
15-
string mutexId = String.Format("Global\\{{{0}}}", _key);
15+
string mutexId = $"Global\\{{{_key}}}";
1616

1717
try {
1818
var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);

Source/Platforms/Web/RequestInfoCollector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static RequestInfo Collect(HttpContextBase context, ExceptionlessConfigur
5858
}
5959
} else if (context.Request.ContentLength > 0) {
6060
string value = Math.Round(context.Request.ContentLength / 1024m, 0).ToString("N0");
61-
info.PostData = String.Format("Data is too large ({0}) to be included.", value + "kb");
61+
info.PostData = $"Data is too large ({value}kb) to be included.";
6262
}
6363

6464
try {
@@ -88,7 +88,7 @@ private static Dictionary<string, string> ToDictionary(this HttpCookieCollection
8888
foreach (string key in cookies.AllKeys.Distinct().Where(k => !String.IsNullOrEmpty(k) && !k.AnyWildcardMatches(_ignoredCookies, true) && !k.AnyWildcardMatches(exclusions, true))) {
8989
try {
9090
HttpCookie cookie = cookies.Get(key);
91-
if (cookie != null && cookie.Value != null && cookie.Value.Length < MAX_DATA_ITEM_LENGTH && !d.ContainsKey(key))
91+
if (cookie?.Value != null && cookie.Value.Length < MAX_DATA_ITEM_LENGTH && !d.ContainsKey(key))
9292
d.Add(key, cookie.Value);
9393
} catch (Exception ex) {
9494
if (!d.ContainsKey(key))

Source/Platforms/Windows/Dialogs/CrashReportForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public CrashReportForm(ExceptionlessClient client, Event ev) {
1616

1717
Client = client;
1818
Event = ev;
19-
Text = String.Format("{0} Error", AssemblyHelper.GetAssemblyTitle());
20-
InformationHeaderLabel.Text = String.Format("{0} has encountered a problem and needs to close. We are sorry for the inconvenience.", AssemblyHelper.GetAssemblyTitle());
19+
Text = $"{AssemblyHelper.GetAssemblyTitle()} Error";
20+
InformationHeaderLabel.Text = $"{AssemblyHelper.GetAssemblyTitle()} has encountered a problem and needs to close. We are sorry for the inconvenience.";
2121

2222
var userInfo = ev.GetUserIdentity();
2323
if (userInfo != null && !String.IsNullOrEmpty(userInfo.Identity)) {

Source/Platforms/Wpf/Dialogs/CrashReportDialog.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public CrashReportDialog(ExceptionlessClient client, Event ev) {
1919

2020
Client = client;
2121
Event = ev;
22-
Title = String.Format("{0} Error", AssemblyHelper.GetAssemblyTitle());
23-
InformationHeaderLabel.Text = String.Format("{0} has encountered a problem and needs to close. We are sorry for the inconvenience.", AssemblyHelper.GetAssemblyTitle());
22+
Title = $"{AssemblyHelper.GetAssemblyTitle()} Error";
23+
InformationHeaderLabel.Text = $"{AssemblyHelper.GetAssemblyTitle()} has encountered a problem and needs to close. We are sorry for the inconvenience.";
2424

2525
var userInfo = ev.GetUserIdentity();
2626
if (userInfo != null && !String.IsNullOrEmpty(userInfo.Identity)) {

Source/Samples/SampleConsole/Plugins/SystemUptimePlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void Run(EventPluginContext context) {
1818
var uptime = TimeSpan.FromSeconds(pc.NextValue());
1919

2020
// Store the system uptime as an extended property.
21-
context.Event.SetProperty("System Uptime", String.Format("{0} Days {1} Hours {2} Minutes {3} Seconds", uptime.Days, uptime.Hours, uptime.Minutes, uptime.Seconds));
21+
context.Event.SetProperty("System Uptime", $"{uptime.Days} Days {uptime.Hours} Hours {uptime.Minutes} Minutes {uptime.Seconds} Seconds");
2222
}
2323
}
2424
}

Source/Samples/SampleConsole/Program.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,15 @@ private static void Main() {
6363

6464
var tokenSource = new CancellationTokenSource();
6565
CancellationToken token = tokenSource.Token;
66-
if (false)
67-
SampleApiUsages();
68-
69-
66+
7067
ExceptionlessClient.Default.Configuration.AddPlugin(ctx => ctx.Event.Data[RandomData.GetWord()] = RandomData.GetWord());
7168
ExceptionlessClient.Default.Configuration.AddPlugin(ctx => ctx.Event.Data[RandomData.GetWord()] = RandomData.GetWord());
7269
ExceptionlessClient.Default.Configuration.AddPlugin(ctx => {
7370
// use server settings to see if we should include this data
7471
if (ctx.Client.Configuration.Settings.GetBoolean("IncludeConditionalData", true))
7572
ctx.Event.AddObject(new { Total = 32.34, ItemCount = 2, Email = "[email protected]" }, "ConditionalData");
7673
});
77-
ExceptionlessClient.Default.Configuration.Settings.Changed += (sender, args) => Trace.WriteLine(String.Format("Action: {0} Key: {1} Value: {2}", args.Action, args.Item.Key, args.Item.Value ));
74+
ExceptionlessClient.Default.Configuration.Settings.Changed += (sender, args) => Trace.WriteLine($"Action: {args.Action} Key: {args.Item.Key} Value: {args.Item.Value}");
7875

7976
WriteOptionsMenu();
8077

0 commit comments

Comments
 (0)