diff --git a/samples/Elmah.Io.Functions.TimerTrigger60/Function1.cs b/samples/Elmah.Io.Functions.TimerTrigger60/Function1.cs index 0c0bf2d..b6ad694 100644 --- a/samples/Elmah.Io.Functions.TimerTrigger60/Function1.cs +++ b/samples/Elmah.Io.Functions.TimerTrigger60/Function1.cs @@ -8,7 +8,7 @@ namespace Elmah.Io.Functions.TimerTrigger60 public class Function1 { [FunctionName("Function1")] - public void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log) + public void Run([TimerTrigger("0 */5 * * * *", RunOnStartup = true)]TimerInfo myTimer, ILogger log) { log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); throw new Exception("An error happened"); diff --git a/src/Elmah.Io.Functions/ElmahIoHeartbeatFilter.cs b/src/Elmah.Io.Functions/ElmahIoHeartbeatFilter.cs index bdcffe0..171dbdb 100644 --- a/src/Elmah.Io.Functions/ElmahIoHeartbeatFilter.cs +++ b/src/Elmah.Io.Functions/ElmahIoHeartbeatFilter.cs @@ -19,9 +19,9 @@ public class ElmahIoHeartbeatFilter : IFunctionInvocationFilter { private readonly ElmahIoFunctionOptions options; private ElmahioAPI api; - internal static string _assemblyVersion = typeof(ElmahIoHeartbeatFilter).Assembly.GetName().Version.ToString(); + private static string _assemblyVersion = typeof(ElmahIoHeartbeatFilter).Assembly.GetName().Version.ToString(); #pragma warning disable CS0618 // Type or member is obsolete - internal static string _functionsAssemblyVersion = typeof(IFunctionInvocationFilter).Assembly.GetName().Version.ToString(); + private static string _functionsAssemblyVersion = typeof(IFunctionInvocationFilter).Assembly.GetName().Version.ToString(); #pragma warning restore CS0618 // Type or member is obsolete /// @@ -31,7 +31,7 @@ public ElmahIoHeartbeatFilter(IOptions options) { this.options = options.Value; if (string.IsNullOrWhiteSpace(this.options.ApiKey)) throw new ArgumentNullException(nameof(this.options.ApiKey)); - if (this.options.LogId == null || this.options.LogId == Guid.Empty) throw new ArgumentNullException(nameof(this.options.LogId)); + if (this.options.LogId == Guid.Empty) throw new ArgumentNullException(nameof(this.options.LogId)); if (string.IsNullOrWhiteSpace(this.options.HeartbeatId)) throw new ArgumentNullException(nameof(this.options.HeartbeatId)); } diff --git a/src/Elmah.Io.Functions/MessageShipper.cs b/src/Elmah.Io.Functions/MessageShipper.cs index 8750099..bcaa029 100644 --- a/src/Elmah.Io.Functions/MessageShipper.cs +++ b/src/Elmah.Io.Functions/MessageShipper.cs @@ -11,11 +11,11 @@ namespace Elmah.Io.Functions { - internal class MessageShipper + internal static class MessageShipper { - internal static string _assemblyVersion = typeof(MessageShipper).Assembly.GetName().Version.ToString(); + private static string _assemblyVersion = typeof(MessageShipper).Assembly.GetName().Version.ToString(); #pragma warning disable CS0618 // Type or member is obsolete - internal static string _functionsAssemblyVersion = typeof(FunctionExceptionContext).Assembly.GetName().Version.ToString(); + private static string _functionsAssemblyVersion = typeof(FunctionExceptionContext).Assembly.GetName().Version.ToString(); internal static IElmahioAPI elmahIoClient; @@ -29,7 +29,7 @@ public static async Task Ship(FunctionExceptionContext exceptionContext, HttpCon DateTime = DateTime.UtcNow, Detail = Detail(exception), Type = baseException?.GetType().FullName, - Title = baseException.Message, + Title = baseException?.Message ?? "An error happened", Data = Data(exceptionContext), Cookies = Cookies(context), Form = Form(context), @@ -139,14 +139,15 @@ private static List Form(HttpContext httpContext) .Request? .Form? .Keys - .Select(k => new Item(k, httpContext.Request.Form[k])).ToList(); + .Select(k => new Item(k, httpContext.Request.Form[k])) + .ToList() ?? new List(); } catch (InvalidOperationException) { // Request not a form POST or similar } - return null; + return new List(); } private static List ServerVariables(HttpContext httpContext) @@ -155,7 +156,8 @@ private static List ServerVariables(HttpContext httpContext) .Request? .Headers? .Keys - .Select(k => new Item(k, httpContext.Request.Headers[k])).ToList(); + .Select(k => new Item(k, httpContext.Request.Headers[k])) + .ToList() ?? new List(); } private static List QueryString(HttpContext httpContext) @@ -164,7 +166,8 @@ private static List QueryString(HttpContext httpContext) .Request? .Query? .Keys - .Select(k => new Item(k, httpContext?.Request.Query[k])).ToList(); + .Select(k => new Item(k, httpContext?.Request.Query[k])) + .ToList() ?? new List(); } private static int? StatusCode(Exception exception, HttpContext context)