From fe9b611c61b69d3657d1292d2f0ffceecde6b407 Mon Sep 17 00:00:00 2001 From: Drew Seward Date: Tue, 20 Mar 2018 18:24:33 -0700 Subject: [PATCH] chore: Remove IBugsnagger::*Async Not a whole mountain of need to expose a Task for the app to await on, honestly, maybe an OnError callback to know if things _are_ going wrong, but shouldn't need any more than that. --- Bugsnag.NET.Tests/Bugsnag.NET.Tests.csproj | 2 - .../Integration/IntegrationTests.NET.cs | 42 ---------------- .../Integration/IntegrationTests.PCL.cs | 42 ---------------- .../Integration/Utils/ITestApp.cs | 5 -- .../Utils/InstanceApproachAsyncApp.cs | 40 --------------- .../Utils/StaticApproachAsyncApp.cs | 45 ----------------- Bugsnag.NET.Tests/Integration/Utils/Utils.cs | 24 --------- Bugsnag.NET/Bugsnag.cs | 5 -- Bugsnag.NET/Bugsnagger.cs | 49 ------------------- Bugsnag.PCL/Bugsnag.cs | 5 -- Bugsnag.PCL/Bugsnagger.cs | 44 ----------------- lib/Bugsnag.Common/Interfaces/IBugsnagger.cs | 9 ---- 12 files changed, 312 deletions(-) delete mode 100755 Bugsnag.NET.Tests/Integration/Utils/InstanceApproachAsyncApp.cs delete mode 100755 Bugsnag.NET.Tests/Integration/Utils/StaticApproachAsyncApp.cs diff --git a/Bugsnag.NET.Tests/Bugsnag.NET.Tests.csproj b/Bugsnag.NET.Tests/Bugsnag.NET.Tests.csproj index 17a4214..4d99574 100755 --- a/Bugsnag.NET.Tests/Bugsnag.NET.Tests.csproj +++ b/Bugsnag.NET.Tests/Bugsnag.NET.Tests.csproj @@ -54,10 +54,8 @@ - - diff --git a/Bugsnag.NET.Tests/Integration/IntegrationTests.NET.cs b/Bugsnag.NET.Tests/Integration/IntegrationTests.NET.cs index 60e28fc..2bd5cdd 100755 --- a/Bugsnag.NET.Tests/Integration/IntegrationTests.NET.cs +++ b/Bugsnag.NET.Tests/Integration/IntegrationTests.NET.cs @@ -20,12 +20,6 @@ public void SendError_StaticApproach() Utils.Run(StaticApproach.TestApp); } - [Test] - public async Task SendError_StaticApproachAsync() - { - await Utils.Run(StaticApproach.AsyncTestApp); - } - [Test] public void SendError_InstanceApproach() { @@ -34,14 +28,6 @@ public void SendError_InstanceApproach() ); } - [Test] - public async Task SendError_InstanceApproachAsync() - { - await Utils.Run( - _instanceApproach.AsyncTestApp(snagger => snagger.ErrorAsync) - ); - } - [Test] public void SendWarning_InstanceApproach() { @@ -50,14 +36,6 @@ public void SendWarning_InstanceApproach() ); } - [Test] - public async Task SendWarning_InstanceApproachAsync() - { - await Utils.Run( - _instanceApproach.AsyncTestApp(snagger => snagger.WarningAsync) - ); - } - [Test] public void SendInfo_InstanceApproach() { @@ -66,14 +44,6 @@ public void SendInfo_InstanceApproach() ); } - [Test] - public async Task SendInfo_InstanceApproachAsync() - { - await Utils.Run( - _instanceApproach.AsyncTestApp(snagger => snagger.InfoAsync) - ); - } - static InstanceApproach _instanceApproach = new InstanceApproach(_GetSnagger); static IBugsnagger _GetSnagger() => new BsNET.Bugsnagger @@ -93,11 +63,6 @@ class StaticApproach _SetApp, _OnUnhandledException ); - public static IAsyncTestApp AsyncTestApp { get; } = new StaticApproachAsyncApp( - _SetApiKey, - _SetApp, - _OnUnhandledExceptionAsync - ); static void _SetApiKey(string key) => BsNET.Bugsnag.ApiKey = key; static void _SetApp() => BsNET.Bugsnag.App = new App @@ -112,13 +77,6 @@ static void _OnUnhandledException(Exception ex) client.Notify(@event); } - static Task _OnUnhandledExceptionAsync(Exception ex) - { - var client = BsNET.Bugsnag.Error; - var @event = client.GetEvent(ex, null, _GetMetadata()); - - return client.NotifyAsync(@event); - } static object _GetMetadata() => new diff --git a/Bugsnag.NET.Tests/Integration/IntegrationTests.PCL.cs b/Bugsnag.NET.Tests/Integration/IntegrationTests.PCL.cs index fcd745e..6fc21ff 100755 --- a/Bugsnag.NET.Tests/Integration/IntegrationTests.PCL.cs +++ b/Bugsnag.NET.Tests/Integration/IntegrationTests.PCL.cs @@ -19,12 +19,6 @@ public void SendError_StaticApproach() Utils.Run(StaticApproach.TestApp); } - [Test] - public async Task SendError_StaticApproachAsync() - { - await Utils.Run(StaticApproach.AsyncTestApp); - } - [Test] public void SendError_InstanceApproach() { @@ -33,14 +27,6 @@ public void SendError_InstanceApproach() ); } - [Test] - public async Task SendError_InstanceApproachAsync() - { - await Utils.Run( - _instanceApproach.AsyncTestApp(snagger => snagger.ErrorAsync) - ); - } - [Test] public void SendWarning_InstanceApproach() { @@ -49,14 +35,6 @@ public void SendWarning_InstanceApproach() ); } - [Test] - public async Task SendWarning_InstanceApproachAsync() - { - await Utils.Run( - _instanceApproach.AsyncTestApp(snagger => snagger.WarningAsync) - ); - } - [Test] public void SendInfo_InstanceApproach() { @@ -65,14 +43,6 @@ public void SendInfo_InstanceApproach() ); } - [Test] - public async Task SendInfo_InstanceApproachAsync() - { - await Utils.Run( - _instanceApproach.AsyncTestApp(snagger => snagger.InfoAsync) - ); - } - static InstanceApproach _instanceApproach = new InstanceApproach(_GetSnagger); static IBugsnagger _GetSnagger() => new BsPCL.Bugsnagger @@ -92,11 +62,6 @@ class StaticApproach _SetApp, _OnUnhandledException ); - public static IAsyncTestApp AsyncTestApp { get; } = new StaticApproachAsyncApp( - _SetApiKey, - _SetApp, - _OnUnhandledExceptionAsync - ); static void _SetApiKey(string key) => BsPCL.Bugsnag.ApiKey = key; static void _SetApp() => BsPCL.Bugsnag.App = new App @@ -111,13 +76,6 @@ static void _OnUnhandledException(Exception ex) client.Notify(@event); } - static Task _OnUnhandledExceptionAsync(Exception ex) - { - var client = BsPCL.Bugsnag.Error; - var @event = client.GetEvent(ex, null, _GetMetadata()); - - return client.NotifyAsync(@event); - } static object _GetMetadata() => new diff --git a/Bugsnag.NET.Tests/Integration/Utils/ITestApp.cs b/Bugsnag.NET.Tests/Integration/Utils/ITestApp.cs index 3fd98d0..78802db 100755 --- a/Bugsnag.NET.Tests/Integration/Utils/ITestApp.cs +++ b/Bugsnag.NET.Tests/Integration/Utils/ITestApp.cs @@ -10,9 +10,4 @@ interface ITestApp { void Run(string testInfo); } - - interface IAsyncTestApp - { - Task Run(string testInfo); - } } diff --git a/Bugsnag.NET.Tests/Integration/Utils/InstanceApproachAsyncApp.cs b/Bugsnag.NET.Tests/Integration/Utils/InstanceApproachAsyncApp.cs deleted file mode 100755 index 038f57f..0000000 --- a/Bugsnag.NET.Tests/Integration/Utils/InstanceApproachAsyncApp.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Bugsnag.Common; - -namespace Bugsnag.Tests.Integration -{ - class InstanceApproachAsyncApp : IAsyncTestApp - { - public InstanceApproachAsyncApp( - IBugsnagger snagger, - Func notifyAsync) - { - _snagger = snagger; - _notifyAsync = notifyAsync; - } - - readonly IBugsnagger _snagger; - - readonly Func _notifyAsync; - - public async Task Run(string testInfo) - { - try - { - // Main bulk of app code would go here - - Utils.TriggerError(testInfo); - } - catch (Exception ex) - { - await _OnUnhandledException(ex); - } - } - - Task _OnUnhandledException(Exception ex) => _notifyAsync(_snagger, ex); - } -} diff --git a/Bugsnag.NET.Tests/Integration/Utils/StaticApproachAsyncApp.cs b/Bugsnag.NET.Tests/Integration/Utils/StaticApproachAsyncApp.cs deleted file mode 100755 index e2539c7..0000000 --- a/Bugsnag.NET.Tests/Integration/Utils/StaticApproachAsyncApp.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Bugsnag.Tests.Integration -{ - class StaticApproachAsyncApp : IAsyncTestApp - { - public StaticApproachAsyncApp( - Action setApiKey, - Action setApp, - Func onUnhandledException) - { - _setApiKey = setApiKey; - _setApp = setApp; - _onUnhandledException = onUnhandledException; - } - - readonly Action _setApiKey; - readonly Action _setApp; - readonly Func _onUnhandledException; - - void _InitBugsnag() - { - _setApiKey(Utils.ReadApiKey()); - _setApp(); - } - - public async Task Run(string testInfo) - { - _InitBugsnag(); - - try - { - Utils.TriggerError(testInfo); - } - catch (Exception ex) - { - await _onUnhandledException(ex); - } - } - } -} diff --git a/Bugsnag.NET.Tests/Integration/Utils/Utils.cs b/Bugsnag.NET.Tests/Integration/Utils/Utils.cs index 467a3c3..4abf2d9 100755 --- a/Bugsnag.NET.Tests/Integration/Utils/Utils.cs +++ b/Bugsnag.NET.Tests/Integration/Utils/Utils.cs @@ -28,20 +28,6 @@ internal static void Run( Inconclusive(); } - internal static async Task Run( - IAsyncTestApp app, - [CallerMemberName] string callerName = "[unknown test]", - [CallerFilePath] string sourceFilePath = "[unknown file]", - [CallerLineNumber] int sourceLineNumber = 0) - { - var fileHint = $"{sourceFilePath}:{sourceLineNumber}"; - - await app.Run($"{callerName} ({sourceFilePath}:{sourceLineNumber})"); - - Inconclusive(); - } - - public static void TriggerError(string testInfo) { throw new ApplicationException($"Error triggered by {testInfo}"); @@ -84,16 +70,6 @@ public ITestApp TestApp(Func> getN return TestApp((snagger, ex) => getNotify(snagger)(ex, null, _GetMetadata())); } - public IAsyncTestApp AsyncTestApp(Func notifyAsync) - { - return new InstanceApproachAsyncApp(_getSnagger(), notifyAsync); - } - - public IAsyncTestApp AsyncTestApp(Func> getNotify) - { - return AsyncTestApp((snagger, ex) => getNotify(snagger)(ex, null, _GetMetadata())); - } - object _GetMetadata() => new { diff --git a/Bugsnag.NET/Bugsnag.cs b/Bugsnag.NET/Bugsnag.cs index 26eaa8c..7ccbd65 100755 --- a/Bugsnag.NET/Bugsnag.cs +++ b/Bugsnag.NET/Bugsnag.cs @@ -43,11 +43,6 @@ private Bugsnag(Severity severity) public void Notify(IEnumerable events) => Snagger.Notify(events); public void Notify(IEnumerable events, bool useSSL) => Snagger.Notify(events, useSSL); - public Task NotifyAsync(IEvent evt) => Snagger.NotifyAsync(evt); - public Task NotifyAsync(IEvent evt, bool useSSL) => Snagger.NotifyAsync(evt, useSSL); - public Task NotifyAsync(IEnumerable events) => Snagger.NotifyAsync(events); - public Task NotifyAsync(IEnumerable events, bool useSSL) => Snagger.NotifyAsync(events, useSSL); - public IEvent GetEvent(Exception ex, IUser user, object metaData) { return new Event(ex, Snagger.FinalizeStacktraceLine) diff --git a/Bugsnag.NET/Bugsnagger.cs b/Bugsnag.NET/Bugsnagger.cs index ef32f1e..8419cca 100755 --- a/Bugsnag.NET/Bugsnagger.cs +++ b/Bugsnag.NET/Bugsnagger.cs @@ -21,49 +21,6 @@ public class Bugsnagger : IBugsnagger public Func FinalizeStacktraceLine { get; set; } = x => x; public Func FinalizeEvent { get; set; } = (@event, ex) => @event; - [Obsolete("Has not been verified to work yet")] - public Task ErrorAsync(Exception ex, IUser user, object metadata) - { - var @event = this.CreateEvent(Severity.Error, ex, user, metadata); - - return NotifyAsync(@event); - } - - [Obsolete("Has not been verified to work yet")] - public Task WarningAsync(Exception ex, IUser user, object metadata) - { - var @event = this.CreateEvent(Severity.Warning, ex, user, metadata); - - return NotifyAsync(@event); - } - - [Obsolete("Has not been verified to work yet")] - public Task InfoAsync(Exception ex, IUser user, object metadata) - { - var @event = this.CreateEvent(Severity.Info, ex, user, metadata); - - return NotifyAsync(@event); - } - - [Obsolete("Has not been verified to work yet")] - public Task NotifyAsync(IEvent @event) => NotifyAsync(@event, true); - - [Obsolete("Has not been verified to work yet")] - public Task NotifyAsync(IEvent @event, bool useSSL) => - NotifyAsync(new[] { @event }, useSSL); - - [Obsolete("Has not been verified to work yet")] - public Task NotifyAsync(IEnumerable events) => NotifyAsync(events, true); - - [Obsolete("Has not been verified to work yet")] - public Task NotifyAsync(IEnumerable events, bool useSSL) - { - var notice = new Notice(ApiKey, Notifier, events); - - return _Client.SendAsync(notice, useSSL); - } - - [Obsolete("Prefer ErrorAsync")] public void Error(Exception ex, IUser user, object metadata) { var @event = this.CreateEvent(Severity.Error, ex, user, metadata); @@ -71,7 +28,6 @@ public void Error(Exception ex, IUser user, object metadata) Notify(@event); } - [Obsolete("Prefer WarningAsync")] public void Warning(Exception ex, IUser user, object metadata) { var @event = this.CreateEvent(Severity.Warning, ex, user, metadata); @@ -79,7 +35,6 @@ public void Warning(Exception ex, IUser user, object metadata) Notify(@event); } - [Obsolete("Prefer InfoAsync")] public void Info(Exception ex, IUser user, object metadata) { var @event = this.CreateEvent(Severity.Info, ex, user, metadata); @@ -87,17 +42,13 @@ public void Info(Exception ex, IUser user, object metadata) Notify(@event); } - [Obsolete("Prefer NotifyAsync")] public void Notify(IEvent @event) => Notify(@event, true); - [Obsolete("Prefer NotifyAsync")] public void Notify(IEvent @event, bool useHttps) => Notify(new[] { @event }, useHttps); - [Obsolete("Prefer NotifyAsync")] public void Notify(IEnumerable events) => Notify(events, true); - [Obsolete("Prefer NotifyAsync")] public void Notify(IEnumerable events, bool useHttps) { var notice = new Notice(ApiKey, Notifier, events); diff --git a/Bugsnag.PCL/Bugsnag.cs b/Bugsnag.PCL/Bugsnag.cs index 498b3cc..1b309de 100644 --- a/Bugsnag.PCL/Bugsnag.cs +++ b/Bugsnag.PCL/Bugsnag.cs @@ -44,11 +44,6 @@ private Bugsnag(Severity severity) public void Notify(IEnumerable events) => Snagger.Notify(events); public void Notify(IEnumerable events, bool useSSL) => Snagger.Notify(events, useSSL); - public Task NotifyAsync(IEvent evt) => Snagger.NotifyAsync(evt); - public Task NotifyAsync(IEvent evt, bool useSSL) => Snagger.NotifyAsync(evt, useSSL); - public Task NotifyAsync(IEnumerable events) => Snagger.NotifyAsync(events); - public Task NotifyAsync(IEnumerable events, bool useSSL) => Snagger.NotifyAsync(events, useSSL); - public IEvent GetEvent(Exception ex, IUser user, object metaData) { return GetEvent(ex, user, null, metaData); diff --git a/Bugsnag.PCL/Bugsnagger.cs b/Bugsnag.PCL/Bugsnagger.cs index a45f8bc..019ed8b 100755 --- a/Bugsnag.PCL/Bugsnagger.cs +++ b/Bugsnag.PCL/Bugsnagger.cs @@ -21,44 +21,6 @@ public class Bugsnagger : IBugsnagger public Func FinalizeStacktraceLine { get; set; } = x => x; public Func FinalizeEvent { get; set; } = (@event, ex) => @event; - public Task ErrorAsync(Exception ex, IUser user, object metadata) - { - var @event = this.CreateEvent(Severity.Error, ex, user, metadata); - - return NotifyAsync(@event); - } - - public Task WarningAsync(Exception ex, IUser user, object metadata) - { - var @event = this.CreateEvent(Severity.Warning, ex, user, metadata); - - return NotifyAsync(@event); - } - - public Task InfoAsync(Exception ex, IUser user, object metadata) - { - var @event = this.CreateEvent(Severity.Info, ex, user, metadata); - - return NotifyAsync(@event); - } - - public Task NotifyAsync(IEvent @event) => - NotifyAsync(@event, true); - - public Task NotifyAsync(IEvent @event, bool useSSL) => - NotifyAsync(new[] { @event }, useSSL); - - public Task NotifyAsync(IEnumerable events) => - NotifyAsync(events, true); - - public Task NotifyAsync(IEnumerable events, bool useSSL) - { - var notice = new Notice(ApiKey, Notifier, events); - - return _Client.SendAsync(notice, useSSL); - } - - [Obsolete("Prefer ErrorAsync")] public void Error(Exception ex, IUser user, object metadata) { var @event = this.CreateEvent(Severity.Error, ex, user, metadata); @@ -66,7 +28,6 @@ public void Error(Exception ex, IUser user, object metadata) Notify(@event); } - [Obsolete("Prefer WarningAsync")] public void Warning(Exception ex, IUser user, object metadata) { var @event = this.CreateEvent(Severity.Warning, ex, user, metadata); @@ -74,7 +35,6 @@ public void Warning(Exception ex, IUser user, object metadata) Notify(@event); } - [Obsolete("Prefer InfoAsync")] public void Info(Exception ex, IUser user, object metadata) { var @event = this.CreateEvent(Severity.Info, ex, user, metadata); @@ -82,16 +42,12 @@ public void Info(Exception ex, IUser user, object metadata) Notify(@event); } - [Obsolete("Prefer NotifyAsync")] public void Notify(IEvent @event) => Notify(@event, true); - [Obsolete("Prefer NotifyAsync")] public void Notify(IEvent @event, bool useHttps) => Notify(new[] { @event }, useHttps); - [Obsolete("Prefer NotifyAsync")] public void Notify(IEnumerable events) => Notify(events, true); - [Obsolete("Prefer NotifyAsync")] public void Notify(IEnumerable events, bool useSSL) { var notice = new Notice(ApiKey, Notifier, events); diff --git a/lib/Bugsnag.Common/Interfaces/IBugsnagger.cs b/lib/Bugsnag.Common/Interfaces/IBugsnagger.cs index 2d34693..b2626af 100755 --- a/lib/Bugsnag.Common/Interfaces/IBugsnagger.cs +++ b/lib/Bugsnag.Common/Interfaces/IBugsnagger.cs @@ -22,18 +22,9 @@ public interface IBugsnagger void Warning(Exception ex, IUser user, object metadata); void Info(Exception ex, IUser user, object metadata); - Task ErrorAsync(Exception ex, IUser user, object metadata); - Task WarningAsync(Exception ex, IUser user, object metadata); - Task InfoAsync(Exception ex, IUser user, object metadata); - void Notify(IEvent @event); void Notify(IEvent @event, bool useHttps); void Notify(IEnumerable events); void Notify(IEnumerable events, bool useHttps); - - Task NotifyAsync(IEvent @event); - Task NotifyAsync(IEvent @event, bool useSSL); - Task NotifyAsync(IEnumerable events); - Task NotifyAsync(IEnumerable events, bool useSSL); } }