Skip to content

Commit abd7487

Browse files
committed
Cleanup: use nameof
1 parent 1661da3 commit abd7487

18 files changed

+54
-54
lines changed

samples/Exceptionless.SampleWcf/Service1.svc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public string GetData(int value) {
1010

1111
public CompositeType GetDataUsingDataContract(CompositeType composite) {
1212
if (composite == null)
13-
throw new ArgumentNullException("composite");
13+
throw new ArgumentNullException(nameof(composite));
1414

1515
if (composite.BoolValue)
1616
composite.StringValue += "Suffix";

src/Exceptionless/Configuration/ExceptionlessConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ExceptionlessConfiguration {
4040

4141
public ExceptionlessConfiguration(IDependencyResolver resolver) {
4242
if (resolver == null)
43-
throw new ArgumentNullException("resolver");
43+
throw new ArgumentNullException(nameof(resolver));
4444

4545
ServerUrl = DEFAULT_SERVER_URL;
4646
ConfigServerUrl = DEFAULT_CONFIG_SERVER_URL;

src/Exceptionless/Dependency/DefaultDependencyResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public sealed class DefaultDependencyResolver : IDependencyResolver {
77

88
public object Resolve(Type serviceType) {
99
if (serviceType == null)
10-
throw new ArgumentNullException("serviceType");
10+
throw new ArgumentNullException(nameof(serviceType));
1111

1212
return _container.Resolve(serviceType);
1313
}

src/Exceptionless/Dependency/DependencyResolverExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ public static bool HasDefaultRegistration<TService, TDefaultImplementation>(this
2525

2626
public static object Resolve(this IDependencyResolver resolver, Type type) {
2727
if (resolver == null)
28-
throw new ArgumentNullException("resolver");
28+
throw new ArgumentNullException(nameof(resolver));
2929

3030
if (type == null)
31-
throw new ArgumentNullException("type");
31+
throw new ArgumentNullException(nameof(type));
3232

3333
return resolver.Resolve(type);
3434
}
3535

3636
public static TService Resolve<TService>(this IDependencyResolver resolver, TService defaultImplementation = null) where TService : class {
3737
if (resolver == null)
38-
throw new ArgumentNullException("resolver");
38+
throw new ArgumentNullException(nameof(resolver));
3939

4040
var serviceImpl = resolver.Resolve(typeof(TService));
4141
return serviceImpl as TService ?? defaultImplementation;
4242
}
4343

4444
public static void Register<TService>(this IDependencyResolver resolver, TService implementation) {
4545
if (resolver == null)
46-
throw new ArgumentNullException("resolver");
46+
throw new ArgumentNullException(nameof(resolver));
4747

4848
resolver.Register(typeof(TService), () => implementation);
4949
}
5050

5151
public static void Register<TService>(this IDependencyResolver resolver) {
5252
if (resolver == null)
53-
throw new ArgumentNullException("resolver");
53+
throw new ArgumentNullException(nameof(resolver));
5454

5555
resolver.Register(typeof(TService), typeof(TService));
5656
}
5757

5858
public static void Register<TService, TImplementation>(this IDependencyResolver resolver) where TImplementation : TService {
5959
if (resolver == null)
60-
throw new ArgumentNullException("resolver");
60+
throw new ArgumentNullException(nameof(resolver));
6161

6262
resolver.Register(typeof(TService), typeof(TImplementation));
6363
}

src/Exceptionless/ExceptionlessClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ExceptionlessClient(Action<ExceptionlessConfiguration> configure) : this(
3131

3232
public ExceptionlessClient(ExceptionlessConfiguration configuration) {
3333
if (configuration == null)
34-
throw new ArgumentNullException("configuration");
34+
throw new ArgumentNullException(nameof(configuration));
3535

3636
Configuration = configuration;
3737
Configuration.Changed += OnConfigurationChanged;
@@ -91,7 +91,7 @@ private async void OnUpdateSettingsAsync(object state) {
9191
/// <param name="description">The user's description of the event.</param>
9292
public async Task<bool> UpdateUserEmailAndDescriptionAsync(string referenceId, string email, string description) {
9393
if (String.IsNullOrEmpty(referenceId))
94-
throw new ArgumentNullException("referenceId");
94+
throw new ArgumentNullException(nameof(referenceId));
9595

9696
if (String.IsNullOrEmpty(email) && String.IsNullOrEmpty(description))
9797
return true;
@@ -161,7 +161,7 @@ public Task ProcessQueueAsync() {
161161
/// </param>
162162
public void SubmitEvent(Event ev, ContextData pluginContextData = null) {
163163
if (ev == null)
164-
throw new ArgumentNullException("ev");
164+
throw new ArgumentNullException(nameof(ev));
165165

166166
if (!Configuration.Enabled) {
167167
_log.Value.Info(typeof(ExceptionlessClient), "Configuration is disabled. The event will not be submitted.");

src/Exceptionless/Extensions/DataDictionaryExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ namespace Exceptionless {
99
public static class DataDictionaryExtensions {
1010
public static T GetValue<T>(this DataDictionary items, string key, IJsonSerializer serializer = null) {
1111
if (items == null)
12-
throw new ArgumentNullException("items");
12+
throw new ArgumentNullException(nameof(items));
1313

1414
if (String.IsNullOrEmpty(key))
15-
throw new ArgumentNullException("key");
15+
throw new ArgumentNullException(nameof(key));
1616

1717
object data;
1818
if (!items.TryGetValue(key, out data))

src/Exceptionless/Extensions/EventExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static void SetGeo(this Event ev, string coordinates) {
185185
if (coordinates.Contains(",") || coordinates.Contains(".") || coordinates.Contains(":"))
186186
ev.Geo = coordinates;
187187
else
188-
throw new ArgumentException("Must be either lat,lon or an IP address.", "coordinates");
188+
throw new ArgumentException("Must be either lat,lon or an IP address.", nameof(coordinates));
189189
}
190190

191191
/// <summary>
@@ -196,9 +196,9 @@ public static void SetGeo(this Event ev, string coordinates) {
196196
/// <param name="longitude">The event longitude.</param>
197197
public static void SetGeo(this Event ev, double latitude, double longitude) {
198198
if (latitude < -90.0 || latitude > 90.0)
199-
throw new ArgumentOutOfRangeException("latitude", "Must be a valid latitude value between -90.0 and 90.0.");
199+
throw new ArgumentOutOfRangeException(nameof(latitude), "Must be a valid latitude value between -90.0 and 90.0.");
200200
if (longitude < -180.0 || longitude > 180.0)
201-
throw new ArgumentOutOfRangeException("longitude", "Must be a valid longitude value between -180.0 and 180.0.");
201+
throw new ArgumentOutOfRangeException(nameof(longitude), "Must be a valid longitude value between -180.0 and 180.0.");
202202

203203
ev.Geo = latitude.ToString("#0.0#######", CultureInfo.InvariantCulture) + "," + longitude.ToString("#0.0#######", CultureInfo.InvariantCulture);
204204
}
@@ -222,7 +222,7 @@ public static void AddTags(this Event ev, params string[] tags) {
222222
/// <param name="referenceId">The event reference id.</param>
223223
public static void SetReferenceId(this Event ev, string referenceId) {
224224
if (!IsValidIdentifier(referenceId))
225-
throw new ArgumentException("ReferenceId must contain between 8 and 100 alphanumeric or '-' characters.", "referenceId");
225+
throw new ArgumentException("ReferenceId must contain between 8 and 100 alphanumeric or '-' characters.", nameof(referenceId));
226226

227227
ev.ReferenceId = referenceId;
228228
}
@@ -248,10 +248,10 @@ public static string GetEventReference(this Event ev, string name) {
248248
/// <param name="id">The reference id that points to a specific event</param>
249249
public static void SetEventReference(this Event ev, string name, string id) {
250250
if (String.IsNullOrEmpty(name))
251-
throw new ArgumentNullException("name");
251+
throw new ArgumentNullException(nameof(name));
252252

253253
if (!IsValidIdentifier(id) || String.IsNullOrEmpty(id))
254-
throw new ArgumentException("Id must contain between 8 and 100 alphanumeric or '-' characters.", "id");
254+
throw new ArgumentException("Id must contain between 8 and 100 alphanumeric or '-' characters.", nameof(id));
255255

256256
ev.SetProperty($"@ref:{name}", id);
257257
}

src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public static void UseReferenceIds(this ExceptionlessConfiguration config) {
135135
/// <param name="assemblies">The assembly that contains the Exceptionless configuration attributes.</param>
136136
public static void ReadFromAttributes(this ExceptionlessConfiguration config, params Assembly[] assemblies) {
137137
if (config == null)
138-
throw new ArgumentNullException("config");
138+
throw new ArgumentNullException(nameof(config));
139139

140140
config.ReadFromAttributes(assemblies.ToList());
141141
}
@@ -148,7 +148,7 @@ public static void ReadFromAttributes(this ExceptionlessConfiguration config, pa
148148
/// <param name="assemblies">A list of assemblies that should be checked for the Exceptionless configuration attributes.</param>
149149
public static void ReadFromAttributes(this ExceptionlessConfiguration config, ICollection<Assembly> assemblies = null) {
150150
if (config == null)
151-
throw new ArgumentNullException("config");
151+
throw new ArgumentNullException(nameof(config));
152152

153153
if (assemblies == null) {
154154
Assembly callingAssembly = null;

src/Exceptionless/Extensions/RequestInfoExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private static string CreateQueryString(IEnumerable<KeyValuePair<string, string>
6060

6161
private static string EscapeUriDataStringRfc3986(string value) {
6262
if (value == null)
63-
throw new ArgumentNullException("value");
63+
throw new ArgumentNullException(nameof(value));
6464

6565
return value; //.HexEscape(_uriRfc3986CharsToEscape);
6666
}

src/Exceptionless/Logging/FileExceptionlessLog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class FileExceptionlessLog : IExceptionlessLog, IDisposable {
1717

1818
public FileExceptionlessLog(string filePath, bool append = false) {
1919
if (String.IsNullOrEmpty(filePath))
20-
throw new ArgumentNullException("filePath");
20+
throw new ArgumentNullException(nameof(filePath));
2121

2222
FilePath = filePath;
2323
MinimumLogLevel = LogLevel.Trace;

0 commit comments

Comments
 (0)