diff --git a/src/Elmah.Io/ErrorLog.cs b/src/Elmah.Io/ErrorLog.cs index f7aeff5..e16548e 100644 --- a/src/Elmah.Io/ErrorLog.cs +++ b/src/Elmah.Io/ErrorLog.cs @@ -16,6 +16,9 @@ namespace Elmah.Io /// /// /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S2223", Justification = "The public Api field is kept for backwards compatibility")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S1104", Justification = "The public Api field is kept for backwards compatibility")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S3010", Justification = "The public Api field is kept for backwards compatibility")] public class ErrorLog : global::Elmah.ErrorLog, IErrorLog { internal static readonly string _assemblyVersion = typeof(ErrorLog).Assembly.GetName().Version.ToString(); @@ -199,14 +202,14 @@ public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList) return EndGetErrors(BeginGetErrors(pageIndex, pageSize, errorEntryList, null, null)); } - private T EndImpl(IAsyncResult asyncResult) + private static T EndImpl(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException(nameof(asyncResult)); } - if (!(asyncResult is Task task)) + if (asyncResult is not Task task) { throw new ArgumentException(null, nameof(asyncResult)); } @@ -248,10 +251,10 @@ private ErrorLogEntry MapErrorLogEntry(Message message) User = message.User, }; - (message.Cookies ?? new List()).ToList().ForEach(c => error.Cookies.Add(c.Key, c.Value)); - (message.Form ?? new List()).ToList().ForEach(c => error.Form.Add(c.Key, c.Value)); - (message.QueryString ?? new List()).ToList().ForEach(c => error.QueryString.Add(c.Key, c.Value)); - (message.ServerVariables ?? new List()).ToList().ForEach(c => error.ServerVariables.Add(c.Key, c.Value)); + (message.Cookies ?? []).ToList().ForEach(c => error.Cookies.Add(c.Key, c.Value)); + (message.Form ?? []).ToList().ForEach(c => error.Form.Add(c.Key, c.Value)); + (message.QueryString ?? []).ToList().ForEach(c => error.QueryString.Add(c.Key, c.Value)); + (message.ServerVariables ?? []).ToList().ForEach(c => error.ServerVariables.Add(c.Key, c.Value)); var errorLogEntry = new ErrorLogEntry(this, message.Id, error); return errorLogEntry; @@ -296,7 +299,7 @@ private IList Itemize(NameValueCollection nameValues) private IList Data(Exception exception) { - if (exception == null) return new List(); + if (exception == null) return []; var items = new List(); var dataItems = exception.ToDataList(); if (dataItems.Count > 0) @@ -324,7 +327,7 @@ private IList Data(Exception exception) return items; } - private string UserAgent() + private static string UserAgent() { return new StringBuilder() .Append(new ProductInfoHeaderValue(new ProductHeaderValue("Elmah.Io", _assemblyVersion)).ToString())