Skip to content

Commit

Permalink
Merge pull request BlogEngine#110 from ThisWillDoIt/master
Browse files Browse the repository at this point in the history
Introduced nameof operator for ArgumentNullException strings
  • Loading branch information
rxtur authored Oct 7, 2016
2 parents 80d347b + a080e78 commit 7fe3cc7
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 45 deletions.
6 changes: 3 additions & 3 deletions BlogEngine/BlogEngine.Core/Helpers/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public static Uri ConvertToAbsolute(string relativeUri)
{
if (String.IsNullOrEmpty(relativeUri))
{
throw new ArgumentNullException("relativeUri");
throw new ArgumentNullException(nameof(relativeUri));
}

var absolute = AbsoluteWebRoot.ToString();
Expand Down Expand Up @@ -1031,7 +1031,7 @@ public static string RenderControl(System.Web.UI.Control control)
{
if (control == null)
{
throw new ArgumentNullException("control");
throw new ArgumentNullException(nameof(control));
}

using (var sWriter = new System.IO.StringWriter())
Expand Down Expand Up @@ -1108,7 +1108,7 @@ public static string SendMailMessage(MailMessage message, string smtpServer = ""
int intPort = BlogSettings.Instance.SmtpServerPort;

if (message == null)
throw new ArgumentNullException("message");
throw new ArgumentNullException(nameof(message));

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public override void Add(ProviderBase provider)
{
if (provider == null)
{
throw new ArgumentNullException("provider");
throw new ArgumentNullException(nameof(provider));
}

if (!(provider is BlogProvider))
{
throw new ArgumentException("Invalid provider type", "provider");
throw new ArgumentException("Invalid provider type", nameof(provider));
}

base.Add(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
throw new ArgumentNullException(nameof(config));
}

if (String.IsNullOrEmpty(name))
Expand Down Expand Up @@ -1989,7 +1989,7 @@ public override void SavePingServices(StringCollection services)
{
if (services == null)
{
throw new ArgumentNullException("services");
throw new ArgumentNullException(nameof(services));
}

using (var conn = this.CreateConnection())
Expand Down Expand Up @@ -2075,7 +2075,7 @@ public override void SaveToDataStore(ExtensionType extensionType, string extensi
{
if (settings == null)
{
throw new ArgumentNullException("settings");
throw new ArgumentNullException(nameof(settings));
}

// Save
Expand Down Expand Up @@ -2195,7 +2195,7 @@ public override void SaveSettings(StringDictionary settings)
{
if (settings == null)
{
throw new ArgumentNullException("settings");
throw new ArgumentNullException(nameof(settings));
}

using (var conn = this.CreateConnection())
Expand Down Expand Up @@ -2288,7 +2288,7 @@ public override void SaveRights(IEnumerable<Right> rights)
{
if (rights == null)
{
throw new ArgumentNullException("rights");
throw new ArgumentNullException(nameof(rights));
}

using (var conn = this.CreateConnection())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public override string GetUserNameByEmail(string email)
{
if (email == null)
{
throw new ArgumentNullException("email");
throw new ArgumentNullException(nameof(email));
}

string userName = null;
Expand Down Expand Up @@ -550,7 +550,7 @@ public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
throw new ArgumentNullException(nameof(config));
}

if (string.IsNullOrEmpty(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
throw new ArgumentNullException(nameof(config));
}

if (String.IsNullOrEmpty(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public override void Add(ProviderBase provider)
{
if (provider == null)
{
throw new ArgumentNullException("provider");
throw new ArgumentNullException(nameof(provider));
}

if (!(provider is BlogFileSystemProvider))
{
throw new ArgumentException("Invalid provider type", "provider");
throw new ArgumentException("Invalid provider type", nameof(provider));
}

base.Add(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
throw new ArgumentNullException(nameof(config));
}

if (String.IsNullOrEmpty(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override void Initialize(string name, System.Collections.Specialized.Name
{
if (config == null)
{
throw new ArgumentNullException("config");
throw new ArgumentNullException(nameof(config));
}

if (String.IsNullOrEmpty(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override void SavePingServices(StringCollection services)
{
if (services == null)
{
throw new ArgumentNullException("services");
throw new ArgumentNullException(nameof(services));
}

var fileName = this.Folder + "pingservices.xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override void SaveSettings(StringDictionary settings)
{
if (settings == null)
{
throw new ArgumentNullException("settings");
throw new ArgumentNullException(nameof(settings));
}

var filename = $"{Folder}settings.xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public override MembershipUser GetUser(object providerUserKey, bool userIsOnline
{
if (providerUserKey == null)
{
throw new ArgumentNullException("providerUserKey");
throw new ArgumentNullException(nameof(providerUserKey));
}

var doc = new XmlDocument();
Expand Down Expand Up @@ -565,7 +565,7 @@ public override string GetUserNameByEmail(string email)
{
if (email == null)
{
throw new ArgumentNullException("email");
throw new ArgumentNullException(nameof(email));
}

var doc = new XmlDocument();
Expand Down Expand Up @@ -594,7 +594,7 @@ public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
throw new ArgumentNullException(nameof(config));
}

if (string.IsNullOrEmpty(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
throw new ArgumentNullException(nameof(config));
}

if (string.IsNullOrEmpty(name))
Expand Down Expand Up @@ -413,7 +413,7 @@ public override bool RoleExists(string roleName)
{
if (String.IsNullOrWhiteSpace(roleName))
{
throw new ArgumentNullException("roleName");
throw new ArgumentNullException(nameof(roleName));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion BlogEngine/BlogEngine.Core/RemoteFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal RemoteFile(Uri filePath, bool ignoreRemoteDownloadSettings)
{
if (filePath == null)
{
throw new ArgumentNullException("filePath");
throw new ArgumentNullException(nameof(filePath));
}

this.url = filePath;
Expand Down
2 changes: 1 addition & 1 deletion BlogEngine/BlogEngine.Core/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Role(string name, List<string> userNames)
{
if (userNames == null)
{
throw new System.ArgumentNullException("userNames");
throw new System.ArgumentNullException(nameof(userNames));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static string AfterLast(string value, string last)
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
}

return value.Substring(value.LastIndexOf(last) + last.Length);
Expand All @@ -94,12 +94,12 @@ private static string BeforeLast(string value, string last)
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
}

if (last == null)
{
throw new ArgumentNullException("last");
throw new ArgumentNullException(nameof(last));
}

return value.Substring(0, value.LastIndexOf(last));
Expand All @@ -124,7 +124,7 @@ private static string BetweenFirst(string value, string startText, string endTex
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
}

var start = value.IndexOf(startText, StringComparison.OrdinalIgnoreCase) + startText.Length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static bool Send(TrackbackMessage message)

if (message == null)
{
throw new ArgumentNullException("message");
throw new ArgumentNullException(nameof(message));
}

OnSending(message.UrlToNotifyTrackback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public TrackbackMessage(IPublishable item, Uri urlToNotifyTrackback, Uri itemUrl
{
if (item == null)
{
throw new ArgumentNullException("item");
throw new ArgumentNullException(nameof(item));
}

this.Title = item.Title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public CustomIdentity(string username, bool isAuthenticated)
public CustomIdentity(string username, string password)
{
if (String.IsNullOrWhiteSpace(username))
throw new ArgumentNullException("username");
throw new ArgumentNullException(nameof(username));

if (String.IsNullOrWhiteSpace(password))
throw new ArgumentNullException("password");
throw new ArgumentNullException(nameof(password));

if (!Membership.ValidateUser(username, password)) { return; }

Expand Down
8 changes: 4 additions & 4 deletions BlogEngine/BlogEngine.Core/Services/Security/Right.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private static string PrepareRoleName(string roleName)
{
if (String.IsNullOrWhiteSpace(roleName))
{
throw new ArgumentNullException("roleName");
throw new ArgumentNullException(nameof(roleName));
}
else
{
Expand All @@ -375,7 +375,7 @@ public static Right GetRightByName(string rightName)
{
if (String.IsNullOrWhiteSpace(rightName))
{
throw new ArgumentNullException("rightName");
throw new ArgumentNullException(nameof(rightName));
}
else
{
Expand Down Expand Up @@ -439,7 +439,7 @@ public static IEnumerable<Right> GetRights(IEnumerable<string> roles)
{
if (roles == null)
{
throw new ArgumentNullException("roles");
throw new ArgumentNullException(nameof(roles));
}
else if (!roles.Any())
{
Expand Down Expand Up @@ -473,7 +473,7 @@ public static bool HasRight(Rights right, IEnumerable<string> roles)
{
if (roles == null)
{
throw new ArgumentNullException("roles");
throw new ArgumentNullException(nameof(roles));
}
else if (!roles.Any())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public SyndicationGenerator(BlogSettings settings, List<Category> categories)
{
if (settings == null)
{
throw new ArgumentNullException("settings");
throw new ArgumentNullException(nameof(settings));
}

if (categories == null)
{
throw new ArgumentNullException("categories");
throw new ArgumentNullException(nameof(categories));
}

// ------------------------------------------------------------
Expand Down Expand Up @@ -168,7 +168,7 @@ protected set
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException(nameof(value));
}

this.blogSettings = value;
Expand Down Expand Up @@ -243,12 +243,12 @@ public void WriteFeed(SyndicationFormat format, Stream stream, List<IPublishable
{
if (stream == null)
{
throw new ArgumentNullException("stream");
throw new ArgumentNullException(nameof(stream));
}

if (publishables == null)
{
throw new ArgumentNullException("publishables");
throw new ArgumentNullException(nameof(publishables));
}

if (!stream.CanWrite)
Expand Down
2 changes: 1 addition & 1 deletion BlogEngine/BlogEngine.Core/Web/BlogCulture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public BlogCulture(CultureInfo cultureInfo, ResourceType resourceType)
{
if (cultureInfo == null)
{
throw new ArgumentNullException("cultureInfo");
throw new ArgumentNullException(nameof(cultureInfo));
}
this.cultureInfo = cultureInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static void RegisterDiContainer()
static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
{
if (ignoreList == null)
throw new ArgumentNullException("ignoreList");
throw new ArgumentNullException(nameof(ignoreList));

ignoreList.Ignore("*.intellisense.js");
ignoreList.Ignore("*-vsdoc.js");
Expand Down

0 comments on commit 7fe3cc7

Please sign in to comment.