summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/UpdateHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-03-14 18:16:44 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-03-14 18:16:44 -0400
commit307304a03edb82f3a1f5cfa6c47cb17687560ccb (patch)
treefdd46e84bac0d05e4eafdbb4f05d8c5c70507a7b /src/StardewModdingAPI/Framework/UpdateHelper.cs
parent06871a0603fa59ca6734fd913e118a4fe4a4c64c (diff)
downloadSMAPI-307304a03edb82f3a1f5cfa6c47cb17687560ccb.tar.gz
SMAPI-307304a03edb82f3a1f5cfa6c47cb17687560ccb.tar.bz2
SMAPI-307304a03edb82f3a1f5cfa6c47cb17687560ccb.zip
revert all projects except installer to .NET Framework 4.5
This caused obscure invalid-IL crashes when compiled through MonoDevelop on Linux.
Diffstat (limited to 'src/StardewModdingAPI/Framework/UpdateHelper.cs')
-rw-r--r--src/StardewModdingAPI/Framework/UpdateHelper.cs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/StardewModdingAPI/Framework/UpdateHelper.cs b/src/StardewModdingAPI/Framework/UpdateHelper.cs
index 342a08cf..e01e55c8 100644
--- a/src/StardewModdingAPI/Framework/UpdateHelper.cs
+++ b/src/StardewModdingAPI/Framework/UpdateHelper.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Net;
using System.Reflection;
+using System.Threading.Tasks;
using Newtonsoft.Json;
using StardewModdingAPI.Framework.Models;
@@ -14,17 +15,17 @@ namespace StardewModdingAPI.Framework
*********/
/// <summary>Get the latest release from a GitHub repository.</summary>
/// <param name="repository">The name of the repository from which to fetch releases (like "cjsu/SMAPI").</param>
- public static GitRelease GetLatestVersion(string repository)
+ public static async Task<GitRelease> GetLatestVersionAsync(string repository)
{
// build request
// (avoid HttpClient for Mac compatibility)
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"https://api.github.com/repos/{repository}/releases/latest");
+ HttpWebRequest request = WebRequest.CreateHttp($"https://api.github.com/repos/{repository}/releases/latest");
AssemblyName assembly = typeof(UpdateHelper).Assembly.GetName();
request.UserAgent = $"{assembly.Name}/{assembly.Version}";
request.Accept = "application/vnd.github.v3+json";
// fetch data
- using (WebResponse response = request.GetResponse())
+ using (WebResponse response = await request.GetResponseAsync())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{