diff --git a/.gitignore b/.gitignore index 161f99ac4a..91216319f8 100644 --- a/.gitignore +++ b/.gitignore @@ -289,6 +289,7 @@ paket-files/ Output/* /Python.Runtime.dll Thumbs.db +RELEASES *.sublime-* diff --git a/Deploy/binary_zip.ps1 b/Deploy/binary_zip.ps1 deleted file mode 100644 index 712eebb3eb..0000000000 --- a/Deploy/binary_zip.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -$sourceDirectoryName = $env:APPVEYOR_BUILD_FOLDER + "\Output\Release" -$fileName = $env:APPVEYOR_BUILD_FOLDER + "\Wox-$env:APPVEYOR_BUILD_VERSION.zip" - -$currentPath = Convert-Path . -Write-Host "Current path: " + $currentPath -Write-Host "Target path: " + $sourceDirectoryName - -[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") -[System.IO.Compression.ZipFile]::CreateFromDirectory($sourceDirectoryName, $fileName) \ No newline at end of file diff --git a/Deploy/nuget.ps1 b/Deploy/nuget.ps1 deleted file mode 100644 index 363566475b..0000000000 --- a/Deploy/nuget.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\wox.plugin.nuspec" - -$currentPath = Convert-Path . -Write-Host "Current path:" + $currentPath -Write-Host "nuspec path:" + $path - -& nuget pack $path -Version $env:APPVEYOR_BUILD_VERSION diff --git a/Deploy/squirrel_installer.ps1 b/Deploy/squirrel_installer.ps1 deleted file mode 100644 index cec94831e5..0000000000 --- a/Deploy/squirrel_installer.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -# msbuild based installer generation is not working in appveyor, not sure why - -$currentPath = Convert-Path . -Write-Host "Current path: " + $currentPath - -$path = $env:APPVEYOR_BUILD_FOLDER + "\Deploy\wox.nuspec" -Write-Host "nuspec path: " + $path -$releasePath = $env:APPVEYOR_BUILD_FOLDER + "\Output\Release" -& nuget.exe pack $path -Version $env:APPVEYOR_BUILD_VERSION -Properties Configuration=Release -BasePath $releasePath - -$nupkgPath = $env:APPVEYOR_BUILD_FOLDER + "\Wox." + $env:APPVEYOR_BUILD_VERSION + ".nupkg" -Write-Host "nupkg path: " + $nupkgPath - -# must use Squirrel.com, Squirrel.exe will produce nothing -$squirrelPath = $env:APPVEYOR_BUILD_FOLDER + "\packages\squirrel*\tools\Squirrel.com" -Write-Host "squirrel path: " + $squirrelPath -$iconPath = $env:APPVEYOR_BUILD_FOLDER + "\Wox\Resources\app.ico" -& $squirrelPath --releasify $nupkgPath --setupIcon $iconPath --no-msi - -$path = "Releases\" + "Wox-" + $env:APPVEYOR_BUILD_VERSION + ".exe" -mv Releases\Setup.exe $path diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 1424cd75dd..7b8424e75a 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,8 +1,8 @@ ## Known problems for 1.3.183: -1. `System.NullReferenceException`: https://github.com/Wox-launcher/Wox/releases/tag/v1.3.357 +1. `System.NullReferenceException`: https://github.com/Wox-launcher/Wox/releases/tag/v1.3.424 2. `System.UriFormatException`: delete your old theme file -3. `System.Threading.Tasks.TaskCanceledException`: 设置 http 代理 +3. `System.Threading.Tasks.TaskCanceledException`: https://github.com/Wox-launcher/Wox/releases/tag/v1.3.424 ## English diff --git a/Plugins/Wox.Plugin.Program/Programs/UWP.cs b/Plugins/Wox.Plugin.Program/Programs/UWP.cs index 81c4b7a33a..bf58e46f94 100644 --- a/Plugins/Wox.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Wox.Plugin.Program/Programs/UWP.cs @@ -146,7 +146,20 @@ namespace Wox.Plugin.Program.Programs var support = Environment.OSVersion.Version.Major >= windows10.Major; if (support) { - var applications = CurrentUserPackages().AsParallel().SelectMany(p => new UWP(p).Apps).ToArray(); + var applications = CurrentUserPackages().AsParallel().SelectMany(p => + { + UWP u; + try + { + u = new UWP(p); + } + catch (Exception e) + { + Log.Exception($"|UWP.All|Can't convert Package to UWP for <{p.Id.FullName}>:", e); + return new Application[] { }; + } + return u.Apps; + }).ToArray(); return applications; } else @@ -157,17 +170,31 @@ namespace Wox.Plugin.Program.Programs private static IEnumerable CurrentUserPackages() { - var user = WindowsIdentity.GetCurrent().User; + var u = WindowsIdentity.GetCurrent().User; - if (user != null) + if (u != null) { - var userSecurityId = user.Value; - var packageManager = new PackageManager(); - var packages = packageManager.FindPackagesForUser(userSecurityId); - packages = - packages.Where( - p => !p.IsFramework && !p.IsDevelopmentMode && !string.IsNullOrEmpty(p.InstalledLocation.Path)); - return packages; + var id = u.Value; + var m = new PackageManager(); + var ps = m.FindPackagesForUser(id); + ps = ps.Where(p => + { + bool valid; + try + { + var f = p.IsFramework; + var d = p.IsDevelopmentMode; + var path = p.InstalledLocation.Path; + valid = !f && !d && !string.IsNullOrEmpty(path); + } + catch (Exception e) + { + Log.Exception($"|UWP.CurrentUserPackages|Can't get package info for <{p.Id.FullName}>", e); + valid = false; + } + return valid; + }); + return ps; } else { diff --git a/README.md b/README.md index 527ece01a5..79a7b382f3 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ Contribution - I'd appreciate if you could solve [help_needed](https://github.com/Wox-launcher/Wox/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp_needed) labeled issue - Don't hesitate to ask questions in the [issues](https://github.com/Wox-launcher/Wox/issues) +Build +----- + +1. Install Visual Studio 2015 and tick all Windows 10 sdk options +2. Open powershell with admin permission and `Set-ExecutionPolicy Unrestricted -Scope CurrentUser` + Documentation ------------- - [Wiki](https://github.com/Wox-launcher/Wox/wiki) diff --git a/Scripts/post_build.ps1 b/Scripts/post_build.ps1 new file mode 100644 index 0000000000..eb302a6c62 --- /dev/null +++ b/Scripts/post_build.ps1 @@ -0,0 +1,140 @@ +param( + [string]$config = "Release", + [string]$solution +) +Write-Host "Config: $config" + +function Build-Version { + if ([string]::IsNullOrEmpty($env:APPVEYOR_BUILD_VERSION)) { + $v = "1.2.0" + } else { + $v = $env:APPVEYOR_BUILD_VERSION + } + + Write-Host "Build Version: $v" + return $v +} + +function Build-Path { + if (![string]::IsNullOrEmpty($env:APPVEYOR_BUILD_FOLDER)) { + $p = $env:APPVEYOR_BUILD_FOLDER + } elseif (![string]::IsNullOrEmpty($solution)) { + $p = $solution + } else { + $p = Get-Location + } + + Write-Host "Build Folder: $p" + Set-Location $p + + return $p +} + +function Copy-Resources ($path, $config) { + $project = "$path\Wox" + $output = "$path\Output" + $target = "$output\$config" + Copy-Item -Recurse -Force $project\Themes\* $target\Themes\ + Copy-Item -Recurse -Force $project\Images\* $target\Images\ + Copy-Item -Recurse -Force $path\Plugins\HelloWorldPython $target\Plugins\HelloWorldPython + Copy-Item -Recurse -Force $path\JsonRPC $target\JsonRPC + Copy-Item -Force $path\packages\squirrel*\tools\Squirrel.exe $output\Update.exe +} + +function Delete-Unused ($path, $config) { + $target = "$path\Output\$config" + $included = Get-ChildItem $target -Filter "*.dll" + foreach ($i in $included){ + Remove-Item -Path $target\Plugins -Include $i -Recurse + Write-Host "Deleting duplicated $i" + } + Remove-Item -Path $target -Include "*.xml" -Recurse +} + +function Validate-Directory ($output) { + New-Item $output -ItemType Directory -Force +} + +function Pack-Nuget ($path, $version, $output) { + Write-Host "Begin build nuget library" + + $spec = "$path\Scripts\wox.plugin.nuspec" + Write-Host "nuspec path: $spec" + Write-Host "Output path: $output" + + Nuget pack $spec -Version $version -OutputDirectory $output + + Write-Host "End build nuget library" +} + +function Zip-Release ($path, $version, $output) { + Write-Host "Begin zip release" + + $input = "$path\Output\Release" + Write-Host "Input path: $input" + $file = "$output\Wox-$version.zip" + Write-Host "Filename: $file" + + [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") + [System.IO.Compression.ZipFile]::CreateFromDirectory($input, $file) + + Write-Host "End zip release" +} + +function Pack-Squirrel-Installer ($path, $version, $output) { + # msbuild based installer generation is not working in appveyor, not sure why + Write-Host "Begin pack squirrel installer" + + $spec = "$path\Scripts\wox.nuspec" + Write-Host "nuspec path: $spec" + $input = "$path\Output\Release" + Write-Host "Input path: $input" + Nuget pack $spec -Version $version -Properties Configuration=Release -BasePath $input -OutputDirectory $output + + $nupkg = "$output\Wox.$version.nupkg" + Write-Host "nupkg path: $nupkg" + $icon = "$path\Wox\Resources\app.ico" + Write-Host "icon: $icon" + # Squirrel.com: https://github.com/Squirrel/Squirrel.Windows/issues/369 + New-Alias Squirrel $path\packages\squirrel*\tools\Squirrel.exe -Force + # why we need Write-Output: https://github.com/Squirrel/Squirrel.Windows/issues/489#issuecomment-156039327 + # directory of releaseDir in fucking squirrel can't be same as directory ($nupkg) in releasify + $temp = "$output\Temp" + + Squirrel --releasify $nupkg --releaseDir $temp --setupIcon $icon --no-msi | Write-Output + Move-Item $temp\* $output -Force + Remove-Item $temp + + $file = "$output\Wox-$version.exe" + Write-Host "Filename: $file" + + Move-Item "$output\Setup.exe" $file -Force + + Write-Host "End pack squirrel installer" +} + +function Main { + $p = Build-Path + $v = Build-Version + Copy-Resources $p $config + + if ($config -eq "Release"){ + + Delete-Unused $p $config + $o = "$p\Output\Packages" + Validate-Directory $o + New-Alias Nuget $p\packages\NuGet.CommandLine.*\tools\NuGet.exe -Force + Pack-Squirrel-Installer $p $v $o + + $isInCI = $env:APPVEYOR + if ($isInCI) { + Pack-Nuget $p $v $o + Zip-Release $p $v $o + } + + Write-Host "List output directory" + Get-ChildItem $o + } +} + +Main \ No newline at end of file diff --git a/Deploy/wox.nuspec b/Scripts/wox.nuspec similarity index 100% rename from Deploy/wox.nuspec rename to Scripts/wox.nuspec diff --git a/Deploy/wox.plugin.nuspec b/Scripts/wox.plugin.nuspec similarity index 100% rename from Deploy/wox.plugin.nuspec rename to Scripts/wox.plugin.nuspec diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index a39cab0df9..050ccceb81 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -1,13 +1,14 @@ using System; -using System.Diagnostics; +using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Net.Sockets; +using System.Linq; using System.Threading.Tasks; using System.Windows; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; +using JetBrains.Annotations; using Squirrel; +using Newtonsoft.Json; using Wox.Core.Resource; using Wox.Infrastructure; using Wox.Infrastructure.Http; @@ -17,107 +18,95 @@ namespace Wox.Core { public static class Updater { + private static readonly Internationalization Translater = InternationalizationManager.Instance; + public static async Task UpdateApp() { - - var c = new WebClient { Proxy = Http.WebProxy() }; - var d = new FileDownloader(c); + UpdateManager m; + UpdateInfo u; try { - const string url = Constant.Github; - // UpdateApp() will return value only if the app is squirrel installed - using (var m = await UpdateManager.GitHubUpdateManager(url, urlDownloader: d)) - { - var e = await m.CheckForUpdate(); - var fe = e.FutureReleaseEntry; - var ce = e.CurrentlyInstalledVersion; - if (fe.Version > ce.Version) - { - var t = NewVersinoTips(fe.Version.ToString()); - MessageBox.Show(t); - - await m.DownloadReleases(e.ReleasesToApply); - await m.ApplyReleases(e); - await m.CreateUninstallerRegistryEntry(); - - Log.Info($"|Updater.UpdateApp|TEST <{e.Formatted()}>"); - Log.Info($"|Updater.UpdateApp|TEST <{fe.Formatted()}>"); - Log.Info($"|Updater.UpdateApp|TEST <{ce.Formatted()}>"); - Log.Info($"|Updater.UpdateApp|TEST <{e.ReleasesToApply.Formatted()}>"); - Log.Info($"|Updater.UpdateApp|TEST <{t.Formatted()}>"); - } - } + m = await GitHubUpdateManager(Constant.Repository); } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Log.Exception("|Updater.UpdateApp|Network error", e); - + Log.Exception($"|Updater.UpdateApp|Please check your connection and proxy settings to api.github.com.", e); + return; } - catch (Exception e) - { - const string info = "Update.exe not found, not a Squirrel-installed app?"; - if (e.Message == info) - { - Log.Error($"|Updater.UpdateApp|{info}"); - } - else - { - throw; - } - } - } - - public static async Task NewVersion() - { - const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest"; - - string response; try { - response = await Http.Get(githubAPI); + // UpdateApp CheckForUpdate will return value only if the app is squirrel installed + u = await m.CheckForUpdate().NonNull(); } - catch (WebException e) + catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Log.Exception("|Updater.NewVersion|Can't connect to github api to check new version", e); - return string.Empty; + Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to api.github.com.", e); + m.Dispose(); + return; } - if (!string.IsNullOrEmpty(response)) + var fr = u.FutureReleaseEntry; + var cr = u.CurrentlyInstalledVersion; + Log.Info($"|Updater.UpdateApp|Future Release <{fr.Formatted()}>"); + if (fr.Version > cr.Version) { - JContainer json; try { - json = (JContainer)JsonConvert.DeserializeObject(response); + await m.DownloadReleases(u.ReleasesToApply); } - catch (JsonSerializationException e) + catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Log.Exception("|Updater.NewVersion|can't parse response", e); - return string.Empty; - } - var version = json?["tag_name"]?.ToString(); - if (!string.IsNullOrEmpty(version)) - { - return version; - } - else - { - Log.Warn("|Updater.NewVersion|Can't find tag_name from Github API response"); - return string.Empty; + Log.Exception($"|Updater.UpdateApp|Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e); + m.Dispose(); + return; } + + await m.ApplyReleases(u); + await m.CreateUninstallerRegistryEntry(); + + var newVersionTips = Translater.GetTranslation("newVersionTips"); + newVersionTips = string.Format(newVersionTips, fr.Version); + MessageBox.Show(newVersionTips); + Log.Info($"|Updater.UpdateApp|Update succeed:{newVersionTips}"); } - else - { - Log.Warn("|Updater.NewVersion|Can't get response from Github API"); - return string.Empty; - } + + // always dispose UpdateManager + m.Dispose(); } - public static int NumericVersion(string version) + [UsedImplicitly] + private class GithubRelease { - var newVersion = version.Replace("v", ".").Replace(".", "").Replace("*", ""); - return int.Parse(newVersion); + [JsonProperty("prerelease")] + public bool Prerelease { get; [UsedImplicitly] set; } + + [JsonProperty("published_at")] + public DateTime PublishedAt { get; [UsedImplicitly] set; } + + [JsonProperty("html_url")] + public string HtmlUrl { get; [UsedImplicitly] set; } + } + + /// https://github.com/Squirrel/Squirrel.Windows/blob/master/src/Squirrel/UpdateManager.Factory.cs + private static async Task GitHubUpdateManager(string repository) + { + var uri = new Uri(repository); + var api = $"https://api.github.com/repos{uri.AbsolutePath}/releases"; + + var json = await Http.Get(api); + + var releases = JsonConvert.DeserializeObject>(json); + var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First(); + var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/"); + + var client = new WebClient { Proxy = Http.WebProxy() }; + var downloader = new FileDownloader(client); + + var manager = new UpdateManager(latestUrl, urlDownloader: downloader); + + return manager; } public static string NewVersinoTips(string version) @@ -128,4 +117,4 @@ namespace Wox.Core } } -} +} \ No newline at end of file diff --git a/Wox.Infrastructure/Http/Http.cs b/Wox.Infrastructure/Http/Http.cs index 2cff5fc6fe..d79f3481fc 100644 --- a/Wox.Infrastructure/Http/Http.cs +++ b/Wox.Infrastructure/Http/Http.cs @@ -1,8 +1,10 @@ using System.IO; using System.Net; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using JetBrains.Annotations; +using Wox.Infrastructure.Logger; using Wox.Infrastructure.UserSettings; namespace Wox.Infrastructure.Http @@ -36,7 +38,6 @@ namespace Wox.Infrastructure.Http } } - /// Can't download file public static void Download([NotNull] string url, [NotNull] string filePath) { var client = new WebClient { Proxy = WebProxy() }; @@ -44,35 +45,30 @@ namespace Wox.Infrastructure.Http client.DownloadFile(url, filePath); } - /// Can't get response from http get public static async Task Get([NotNull] string url, string encoding = "UTF-8") { - - HttpWebRequest request = WebRequest.CreateHttp(url); + Log.Debug($"|Http.Get|Url <{url}>"); + var request = WebRequest.CreateHttp(url); request.Method = "GET"; - request.Timeout = 10 * 1000; + request.Timeout = 1000; request.Proxy = WebProxy(); request.UserAgent = UserAgent; var response = await request.GetResponseAsync() as HttpWebResponse; - if (response != null) + response = response.NonNull(); + var stream = response.GetResponseStream().NonNull(); + + using (var reader = new StreamReader(stream, Encoding.GetEncoding(encoding))) { - var stream = response.GetResponseStream(); - if (stream != null) + var content = await reader.ReadToEndAsync(); + if (response.StatusCode == HttpStatusCode.OK) { - using (var reader = new StreamReader(stream, Encoding.GetEncoding(encoding))) - { - return await reader.ReadToEndAsync(); - } + return content; } else { - return string.Empty; + throw new HttpRequestException($"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>"); } } - else - { - return string.Empty; - } } } } \ No newline at end of file diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 48691866c1..f7ea74b31c 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -93,6 +93,7 @@ namespace Wox.Infrastructure.Logger logger.Error($"Exception stack trace:\n <{e.StackTrace}>"); logger.Error($"Exception source:\n <{e.Source}>"); logger.Error($"Exception target site:\n <{e.TargetSite}>"); + logger.Error($"Exception HResult:\n <{e.HResult}>"); e = e.InnerException; } while (e != null); diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index 4acce08458..dcad17d7f3 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -11,14 +11,14 @@ namespace Wox.Infrastructure public const string Plugins = "Plugins"; private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); - public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location).ToString(); + public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location.NonNull()).ToString(); public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe"); public static readonly string DataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox); public static readonly string PluginsDirectory = Path.Combine(DataDirectory, Plugins); public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins); - public const string Github = "https://github.com/Wox-launcher/Wox"; + public const string Repository = "https://github.com/Wox-launcher/Wox"; public const string Issue = "https://github.com/Wox-launcher/Wox/issues/new"; - public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion; + public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location.NonNull()).ProductVersion; public static readonly string DefaultIcon = Path.Combine(ProgramDirectory, "Images", "app.png"); public static readonly string ErrorIcon = Path.Combine(ProgramDirectory, "Images", "app_error.png"); diff --git a/Wox.sln b/Wox.sln index 4c229fa733..69bfd7c94d 100644 --- a/Wox.sln +++ b/Wox.sln @@ -58,9 +58,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitignore = .gitignore appveyor.yml = appveyor.yml LICENSE = LICENSE - Performance1.psess = Performance1.psess + Scripts\post_build.ps1 = Scripts\post_build.ps1 README.md = README.md SolutionAssemblyInfo.cs = SolutionAssemblyInfo.cs + Scripts\wox.nuspec = Scripts\wox.nuspec + Scripts\wox.plugin.nuspec = Scripts\wox.plugin.nuspec EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldCSharp", "Plugins\HelloWorldCSharp\HelloWorldCSharp.csproj", "{03FFA443-5F50-48D5-8869-F3DF316803AA}" diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 14a798a6a7..3407cf5762 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -29,8 +29,6 @@ namespace Wox [STAThread] public static void Main() { - RegisterAppDomainExceptions(); - if (SingleInstance.InitializeAsFirstInstance(Unique)) { using (var application = new App()) @@ -46,6 +44,8 @@ namespace Wox Stopwatch.Normal("|App.OnStartup|Startup cost", () => { Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------"); + Log.Info($"|App.OnStartup|Runtime info:{ErrorReporting.RuntimeInfo()}"); + RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); ImageLoader.Initialize(); @@ -59,6 +59,7 @@ namespace Wox var window = new MainWindow(_settings, _mainVM); API = new PublicAPIInstance(_settingsVM, _mainVM); PluginManager.InitializePlugins(API); + Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}"); Current.MainWindow = window; Current.MainWindow.Title = Constant.Wox; @@ -140,8 +141,10 @@ namespace Wox private static void RegisterAppDomainExceptions() { AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle; - AppDomain.CurrentDomain.FirstChanceException += - (s, e) => { Log.Exception("|App.RegisterAppDomainExceptions|First Chance Exception:", e.Exception); }; + AppDomain.CurrentDomain.FirstChanceException += (_, e) => + { + Log.Exception("|App.RegisterAppDomainExceptions|First Chance Exception:", e.Exception); + }; } public void Dispose() diff --git a/Wox/CrashReporter.cs b/Wox/CrashReporter.cs deleted file mode 100644 index 793cbed6de..0000000000 --- a/Wox/CrashReporter.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace Wox -{ - public class CrashReporter - { - private Exception exception; - - public CrashReporter(Exception e) - { - exception = e; - } - - public void Show() - { - if (exception == null) return; - - if (exception.InnerException != null) - { - exception = exception.InnerException; - } - ReportWindow reportWindow = new ReportWindow(exception); - reportWindow.Show(); - } - } -} diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index f536838fbc..e6bec5a45a 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -1,35 +1,49 @@ using System; -using System.Windows; using System.Windows.Threading; using NLog; +using Wox.Infrastructure; using Wox.Infrastructure.Exception; namespace Wox.Helper { public static class ErrorReporting { - public static void Report(Exception e) + private static void Report(Exception e) { var logger = LogManager.GetLogger("UnHandledException"); logger.Fatal(ExceptionFormatter.FormatExcpetion(e)); - new CrashReporter(e).Show(); + var reportWindow = new ReportWindow(e); + reportWindow.Show(); } public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e) { //handle non-ui thread exceptions - Application.Current.MainWindow.Dispatcher.Invoke(() => - { - Report((Exception)e.ExceptionObject); - }); + Report((Exception)e.ExceptionObject); } public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { //handle ui thread exceptions Report(e.Exception); - //prevent crash + //prevent application exist, so the user can copy prompted error info e.Handled = true; } + + public static string RuntimeInfo() + { + var info = $"\nWox version: {Constant.Version}" + + $"\nOS Version: {Environment.OSVersion.VersionString}" + + $"\nIntPtr Length: {IntPtr.Size}" + + $"\nx64: {Environment.Is64BitOperatingSystem}"; + return info; + } + + public static string DependenciesInfo() + { + var info = $"\nPython Path: {Constant.PythonPath}" + + $"\nEverything SDK Path: {Constant.EverythingSDKPath}"; + return info; + } } } diff --git a/Wox/Languages/en.xaml b/Wox/Languages/en.xaml index 47e434cd9f..ddc40b2d4f 100644 --- a/Wox/Languages/en.xaml +++ b/Wox/Languages/en.xaml @@ -84,7 +84,12 @@ Version You have activated Wox {0} times Check for Updates - New version {0} is available, please restart Wox + New version {0} is available, please restart Wox. + Check updates failed, please check your connection and proxy settings to api.github.com. + + Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com, + or go to https://github.com/Wox-launcher/Wox/releases to download updates manually. + Release Notes: diff --git a/Wox/Languages/zh-cn.xaml b/Wox/Languages/zh-cn.xaml index cbad578255..d471a41113 100644 --- a/Wox/Languages/zh-cn.xaml +++ b/Wox/Languages/zh-cn.xaml @@ -84,7 +84,7 @@ 版本 你已经激活了Wox {0} 次 检查更新 - 发现新版本 {0} , 请重启 wox + 发现新版本 {0} , 请重启 wox。 更新说明: diff --git a/Wox/Languages/zh-tw.xaml b/Wox/Languages/zh-tw.xaml index 1c9a62031b..b32c925cc1 100644 --- a/Wox/Languages/zh-tw.xaml +++ b/Wox/Languages/zh-tw.xaml @@ -80,7 +80,7 @@ 版本 您已經啟動了 Wox {0} 次 檢查更新 - 發現有新版本 {0} , 請重新啟動 Wox + 發現有新版本 {0}, 請重新啟動 Wox。 更新說明: diff --git a/Wox/ReportWindow.xaml.cs b/Wox/ReportWindow.xaml.cs index 93fbb08cb7..5fe84fe2f9 100644 --- a/Wox/ReportWindow.xaml.cs +++ b/Wox/ReportWindow.xaml.cs @@ -6,6 +6,7 @@ using System.Text; using System.Linq; using System.Windows; using System.Windows.Documents; +using Wox.Helper; using Wox.Infrastructure; using Wox.Infrastructure.Logger; @@ -26,18 +27,14 @@ namespace Wox var directory = new DirectoryInfo(path); var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); - var paragraph = Hyperlink("Please open new issue in: " , Constant.Issue); + var paragraph = Hyperlink("Please open new issue in: ", Constant.Issue); paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); paragraph.Inlines.Add($"2. copy below exception message"); ErrorTextbox.Document.Blocks.Add(paragraph); StringBuilder content = new StringBuilder(); - content.AppendLine($"Wox version: {Constant.Version}"); - content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}"); - content.AppendLine($"IntPtr Length: {IntPtr.Size}"); - content.AppendLine($"x64: {Environment.Is64BitOperatingSystem}"); - content.AppendLine($"Python Path: {Constant.PythonPath}"); - content.AppendLine($"Everything SDK Path: {Constant.EverythingSDKPath}"); + content.AppendLine(ErrorReporting.RuntimeInfo()); + content.AppendLine(ErrorReporting.DependenciesInfo()); content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); content.AppendLine("Exception:"); content.AppendLine(exception.Source); @@ -54,7 +51,7 @@ namespace Wox var paragraph = new Paragraph(); paragraph.Margin = new Thickness(0); - var link = new Hyperlink {IsEnabled = true}; + var link = new Hyperlink { IsEnabled = true }; link.Inlines.Add(url); link.NavigateUri = new Uri(url); link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString()); diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 0e0d8ed60d..35b02cebda 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -384,8 +384,6 @@