From 0f33ee4ab1256d368a5ac1379166d3e3a0d904da Mon Sep 17 00:00:00 2001 From: Mathias Pius Damm-Pedersen Date: Sat, 6 May 2017 12:32:54 +0200 Subject: [PATCH 1/3] Cargo build feedback does not always contain a message component Building Visual Rust projects would cause MSBuild to break when attempting to access members of a null message --- VisualRust.Build/Rustc.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VisualRust.Build/Rustc.cs b/VisualRust.Build/Rustc.cs index b93ce2af..dbc43b48 100644 --- a/VisualRust.Build/Rustc.cs +++ b/VisualRust.Build/Rustc.cs @@ -373,6 +373,10 @@ public static void LogRustcMessage(RustcMessageJson msg, string rootPath, TaskLo // todo all other fields // todo mb help key word is code.explanation + // cargo build json messages don't always contain a message component + if (msg == null) + return; + var type = msg.GetLevelAsEnum(); var primarySpan = msg.GetPrimarySpan(); var code = msg.GetErrorCodeAsString(); From 4b18f7b92f17ac677e6b043d0c68591899c58e99 Mon Sep 17 00:00:00 2001 From: Mathias Pius Damm-Pedersen Date: Sat, 6 May 2017 12:39:13 +0200 Subject: [PATCH 2/3] Saving files in open projects caused FileSystemMirroring to throw a Win32Exception The core FileSystem.ToShortPath function would throw an exception when the file whose path it was trying to shorten no longer existed, which happens when saving a file under Visual Studio 2017, and a temporary file is created and deleted before the FileSystemWatcher can shorten the path of it --- .../IO/MsBuildFileSystemWatcher.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/VisualRust.ProjectSystem.FileSystemMirroring/IO/MsBuildFileSystemWatcher.cs b/VisualRust.ProjectSystem.FileSystemMirroring/IO/MsBuildFileSystemWatcher.cs index 0bd3e593..b0d48770 100644 --- a/VisualRust.ProjectSystem.FileSystemMirroring/IO/MsBuildFileSystemWatcher.cs +++ b/VisualRust.ProjectSystem.FileSystemMirroring/IO/MsBuildFileSystemWatcher.cs @@ -13,6 +13,7 @@ using System.IO.Abstractions; using NotifyFilters = System.IO.NotifyFilters; using IOException = System.IO.IOException; +using Win32Exception = System.ComponentModel.Win32Exception; using ErrorEventArgs = System.IO.ErrorEventArgs; #if VS14 @@ -222,10 +223,14 @@ private static bool IsFileAllowed(string rootDirectory, string fullPath, shortRelativePath = null; if (fullPath.StartsWithIgnoreCase(rootDirectory)) { relativePath = PathHelper.MakeRelative(rootDirectory, fullPath); - try { + try + { shortRelativePath = fileSystem.ToShortRelativePath(fullPath, rootDirectory); return !string.IsNullOrEmpty(shortRelativePath) && filter.IsFileAllowed(relativePath, fileSystem.FileInfo.FromFileName(fullPath).Attributes); - } catch (IOException) { } catch (UnauthorizedAccessException) { } // File isn't allowed if it isn't accessible + } + catch (IOException) { } + catch (UnauthorizedAccessException) { } // File isn't allowed if it isn't accessible + catch (Win32Exception) { } // ToShortPath can throw a Win32Exception if the file doesn't exist anymore, which isn't exceptional } return false; } From 3b81fca53dec1ef105eabb0d0d3b4ae8356d66e7 Mon Sep 17 00:00:00 2001 From: Mathias Pius Damm-Pedersen Date: Sat, 6 May 2017 14:07:39 +0200 Subject: [PATCH 3/3] Mark projects as dirty before reevaluating them If projects aren't explicitly marked dirty, loading existing projects would yield empty project structures in the solution explorer, and require the user to unload and reload the project in order to see the file structure. --- .../Project/FileSystemMirroringProject.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/VisualRust.ProjectSystem.FileSystemMirroring/Project/FileSystemMirroringProject.cs b/VisualRust.ProjectSystem.FileSystemMirroring/Project/FileSystemMirroringProject.cs index dd6a51e5..131813ab 100644 --- a/VisualRust.ProjectSystem.FileSystemMirroring/Project/FileSystemMirroringProject.cs +++ b/VisualRust.ProjectSystem.FileSystemMirroring/Project/FileSystemMirroringProject.cs @@ -137,6 +137,7 @@ private async Task ReevaluateLoadedConfiguredProjects(CancellationToken cancella foreach (var configuredProject in _unconfiguredProject.LoadedConfiguredProjects) { try { var jsproj = await access.GetProjectAsync(configuredProject, cancellationToken); + jsproj.MarkDirty(); jsproj.ReevaluateIfNecessary(); } catch (Exception ex) { System.Diagnostics.Debug.Fail("We were unable to mark a configuration as dirty" + ex.Message, ex.StackTrace);