From a8936cf922edf8370fe30d687c26e01cf28eb16a Mon Sep 17 00:00:00 2001 From: JustArchi Date: Tue, 17 Jul 2018 21:19:55 +0200 Subject: [PATCH] Add handling for SteamKit2.ProtocolTypes --- ArchiSteamFarm/IPC.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm/IPC.cs b/ArchiSteamFarm/IPC.cs index ac29f5cc8..bf3ae910d 100644 --- a/ArchiSteamFarm/IPC.cs +++ b/ArchiSteamFarm/IPC.cs @@ -712,8 +712,19 @@ namespace ArchiSteamFarm { Type targetType = Type.GetType(argument); if (targetType == null) { - await ResponseJsonObject(request, response, new GenericResponse(false, string.Format(Strings.ErrorIsInvalid, nameof(argument))), HttpStatusCode.BadRequest).ConfigureAwait(false); - return true; + // We can try one more time by trying to smartly guess the assembly name from the namespace, this will work for custom libraries like SteamKit2 + int index = argument.IndexOf('.'); + if ((index <= 0) || (index >= argument.Length - 1)) { + await ResponseJsonObject(request, response, new GenericResponse(false, string.Format(Strings.ErrorIsInvalid, nameof(argument))), HttpStatusCode.BadRequest).ConfigureAwait(false); + return true; + } + + targetType = Type.GetType(argument + "," + argument.Substring(0, index)); + + if (targetType == null) { + await ResponseJsonObject(request, response, new GenericResponse(false, string.Format(Strings.ErrorIsInvalid, nameof(argument))), HttpStatusCode.BadRequest).ConfigureAwait(false); + return true; + } } string baseType = targetType.BaseType?.GetUnifiedName();