diff --git a/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj b/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj
index 75cae53..cdb926c 100644
--- a/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj
+++ b/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj
@@ -6,7 +6,7 @@
AMWD.Common.AspNetCoreAMWD.Common.AspNetCore
- {semvertag:main}{!:~dirty}
+ {semvertag:main}{!:-dirty}truefalse
@@ -33,17 +33,21 @@
MIT
-
+ true
+
+
+
+
+
-
diff --git a/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj b/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj
index e6edb79..cac7921 100644
--- a/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj
+++ b/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj
@@ -6,7 +6,7 @@
AMWD.Common.EntityFrameworkCoreAMWD.Common.EntityFrameworkCore
- {semvertag:main}{!:~dirty}
+ {semvertag:main}{!:-dirty}truefalse
@@ -33,29 +33,33 @@
MIT
-
+ true
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
- allruntime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/AMWD.Common.Moq/AMWD.Common.Moq.csproj b/AMWD.Common.Moq/AMWD.Common.Moq.csproj
index 9adc2d2..32a5f93 100644
--- a/AMWD.Common.Moq/AMWD.Common.Moq.csproj
+++ b/AMWD.Common.Moq/AMWD.Common.Moq.csproj
@@ -6,7 +6,7 @@
AMWD.Common.MoqAMWD.Common.Moq
- {semvertag:main}{!:~dirty}
+ {semvertag:main}{!:-dirty}truefalse
@@ -33,17 +33,21 @@
MIT
-
+ true
+
+
+
+
+
-
-
+ allruntime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/AMWD.Common/AMWD.Common.csproj b/AMWD.Common/AMWD.Common.csproj
index f0df83b..9e48be6 100644
--- a/AMWD.Common/AMWD.Common.csproj
+++ b/AMWD.Common/AMWD.Common.csproj
@@ -6,7 +6,7 @@
AMWD.CommonAMWD.Common
- {semvertag:main}{!:~dirty}
+ {semvertag:main}{!:-dirty}truefalse
@@ -33,19 +33,22 @@
MIT
-
+ true
+
+
+
+
+
-
-
diff --git a/AMWD.Common/Extensions/ReflectionExtensions.cs b/AMWD.Common/Extensions/ReflectionExtensions.cs
new file mode 100644
index 0000000..2496477
--- /dev/null
+++ b/AMWD.Common/Extensions/ReflectionExtensions.cs
@@ -0,0 +1,42 @@
+using System.Reflection;
+using System.Threading.Tasks;
+
+namespace AMWD.Common.Extensions
+{
+ ///
+ /// Extension methods for .
+ ///
+ [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ public static class ReflectionExtensions
+ {
+ ///
+ /// Calls a method from it's reflection asynchronously without result.
+ ///
+ /// The to call on an object.
+ /// The reflected instance to call the method on.
+ /// The parameters of the called method.
+ /// An awaitable .
+ public static async Task CallAsync(this MethodInfo methodInfo, object obj, params object[] parameters)
+ {
+ var task = (Task)methodInfo.Invoke(obj, parameters);
+ await task.ConfigureAwait(false);
+ }
+
+ ///
+ /// Invokes a method from it's reflection asynchronously with a result.
+ ///
+ /// The result type, that is expected (and casted to).
+ /// The to invoke on an object.
+ /// The reflected instance to invoke the method on.
+ /// The parameters of the called method.
+ /// An awaitable with result.
+ public static async Task InvokeAsync(this MethodInfo methodInfo, object obj, params object[] parameters)
+ {
+ var task = (Task)methodInfo.Invoke(obj, parameters);
+ await task.ConfigureAwait(false);
+
+ var resultPropertyInfo = task.GetType().GetProperty("Result");
+ return (TResult)resultPropertyInfo.GetValue(task);
+ }
+ }
+}
diff --git a/AMWD.Common/Extensions/StringExtensions.cs b/AMWD.Common/Extensions/StringExtensions.cs
index cec9ef6..551f0a0 100644
--- a/AMWD.Common/Extensions/StringExtensions.cs
+++ b/AMWD.Common/Extensions/StringExtensions.cs
@@ -1,13 +1,14 @@
-using System.Collections.Generic;
+using System.Collections;
+using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
+using System.Threading;
using System.Threading.Tasks;
-using DNS.Client;
-using DNS.Protocol;
+using AMWD.Common.Extensions;
namespace System
{
@@ -150,47 +151,67 @@ namespace System
/// You can enhance the check by requesting the MX record of the domain.
///
/// The email address as string to validate.
- /// A value indicating whether to resolve a MX record (Google DNS is used).
+ /// A value indicating whether to resolve a MX record (Google DNS is used).
/// true when the email address is valid, other wise false.
- public static bool IsValidEmailAddress(this string email, bool checkRecordExists = false)
- => email.IsValidEmailAddress(checkRecordExists ? new[] { new IPEndPoint(IPAddress.Parse("8.8.8.8"), 53) } : null);
+ public static bool IsValidEmailAddress(this string email, bool checkForDnsRecord = false)
+ => email.IsValidEmailAddress(checkForDnsRecord ? new[] { new IPEndPoint(IPAddress.Parse("8.8.8.8"), 53) } : null);
///
/// Checks whether the given is a valid .
///
///
/// The check is enhanced by a request for MX records on the defined .
+ ///
+ /// The DNS resolution is only used when the DNS NuGet package is available.
+ /// See: https://www.nuget.org/packages/DNS/7.0.0
///
- /// The email address as string to validate.
+ /// The email address as string to validate.
/// A list of s of nameservers.
/// true when the email address is valid, other wise false.
- public static bool IsValidEmailAddress(this string email, IEnumerable nameservers)
+ public static bool IsValidEmailAddress(this string emailAddress, IEnumerable nameservers)
{
try
{
- var mailAddress = new MailAddress(email);
- bool isValid = mailAddress.Address == email;
+ var mailAddress = new MailAddress(emailAddress);
+ bool isValid = mailAddress.Address == emailAddress;
if (isValid && nameservers?.Any() == true)
{
+ var dnsClientType = Type.GetType("DNS.Client.DnsClient, DNS");
+ if (dnsClientType == null)
+ throw new DllNotFoundException("The DNS NuGet package is required: https://www.nuget.org/packages/DNS/7.0.0");
+
+ var recordTypeType = Type.GetType("DNS.Protocol.RecordType, DNS");
+ var resolveMethodInfo = dnsClientType.GetMethod("Resolve", new[] { typeof(string), recordTypeType, typeof(CancellationToken) });
+
bool exists = false;
foreach (var nameserver in nameservers)
{
- var client = new DnsClient(nameserver);
- var waitTask = Task.Run(async () => await client.Resolve(mailAddress.Host, RecordType.MX));
+ object dnsClient = Activator.CreateInstance(dnsClientType, new object[] { nameserver });
+
+ var waitTask = Task.Run(async () => await resolveMethodInfo.InvokeAsync
-
-
+
+
+