diff --git a/Octokit.Tests.Integration/Clients/GistsClientTests.cs b/Octokit.Tests.Integration/Clients/GistsClientTests.cs
index 7345da20..b8690c1c 100644
--- a/Octokit.Tests.Integration/Clients/GistsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/GistsClientTests.cs
@@ -55,7 +55,7 @@ public class GistsClientTests
Assert.NotNull(updatedGist);
Assert.Equal(updatedGist.Description, gistUpdate.Description);
- Assert.DoesNotThrow(async () => { await _fixture.Delete(createdGist.Id); });
+ await _fixture.Delete(createdGist.Id);
}
[IntegrationTest]
diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs
index b06cb06e..2bd9f787 100644
--- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs
@@ -96,7 +96,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable
var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number);
- Assert.DoesNotThrow(async () => { await _client.Delete(Helper.UserName, _repository.Name, createdComment.Id); });
+ await _client.Delete(Helper.UserName, _repository.Name, createdComment.Id);
}
[IntegrationTest]
diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
index 5986788c..ec334c5a 100644
--- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs
@@ -501,7 +501,7 @@ public class RepositoriesClientTests
var repoName = Helper.MakeNameWithTimestamp("repo-to-delete");
await github.Repository.Create(new NewRepository { Name = repoName });
- Assert.DoesNotThrow(async () => { await github.Repository.Delete(Helper.UserName, repoName); });
+ await github.Repository.Delete(Helper.UserName, repoName);
}
}
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index 2c11df59..aaec3359 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -101,6 +101,7 @@
+
diff --git a/Octokit.Tests.Integration/SelfTests.cs b/Octokit.Tests.Integration/SelfTests.cs
new file mode 100644
index 00000000..b2362323
--- /dev/null
+++ b/Octokit.Tests.Integration/SelfTests.cs
@@ -0,0 +1,17 @@
+using Xunit;
+
+namespace Octokit.Tests.Integration
+{
+ ///
+ /// Tests to make sure our tests are ok.
+ ///
+ public class SelfTests
+ {
+ [Fact]
+ public void NoTestsUseAsyncVoid()
+ {
+ var errors = typeof(SelfTests).Assembly.GetAsyncVoidMethodsList();
+ Assert.Equal("", errors);
+ }
+ }
+}
diff --git a/Octokit.Tests/Helpers/ReflectionExtensions.cs b/Octokit.Tests/Helpers/ReflectionExtensions.cs
new file mode 100644
index 00000000..6446d811
--- /dev/null
+++ b/Octokit.Tests/Helpers/ReflectionExtensions.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+public static class ReflectionExtensions
+{
+ public static string GetAsyncVoidMethodsList(this Assembly assembly)
+ {
+ return String.Join("\r\n",
+ GetLoadableTypes(assembly)
+ .SelectMany(type => type.GetMethods())
+ .Where(HasAttribute)
+ .Where(method => method.ReturnType == typeof(void))
+ .Select(method =>
+ String.Format("Method '{0}' of '{1}' has an async void return type and that's bad",
+ method.Name,
+ method.DeclaringType.Name))
+ .ToList());
+ }
+
+ public static IEnumerable GetLoadableTypes(this Assembly assembly)
+ {
+ try
+ {
+ return assembly.GetTypes();
+ }
+ catch (ReflectionTypeLoadException e)
+ {
+ return e.Types.Where(t => t != null);
+ }
+ }
+
+ public static bool HasAttribute(this MethodInfo method) where TAttribute : Attribute
+ {
+ return method.GetCustomAttributes(typeof(TAttribute), false).Any();
+ }
+}
diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj
index 89a7ff81..35876386 100644
--- a/Octokit.Tests/Octokit.Tests.csproj
+++ b/Octokit.Tests/Octokit.Tests.csproj
@@ -110,6 +110,7 @@
+
@@ -170,6 +171,7 @@
+
diff --git a/Octokit.Tests/SelfTests.cs b/Octokit.Tests/SelfTests.cs
new file mode 100644
index 00000000..30b554fd
--- /dev/null
+++ b/Octokit.Tests/SelfTests.cs
@@ -0,0 +1,14 @@
+using Xunit;
+
+///
+/// Tests to make sure our tests are ok.
+///
+public class SelfTests
+{
+ [Fact]
+ public void NoTestsUseAsyncVoid()
+ {
+ var errors = typeof(SelfTests).Assembly.GetAsyncVoidMethodsList();
+ Assert.Equal("", errors);
+ }
+}
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index ce54f593..90e0860e 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -366,4 +366,4 @@
-->
-
+
\ No newline at end of file