diff options
author | Kirill Osenkov <github@osenkov.com> | 2019-05-29 02:15:39 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2019-05-29 22:27:43 +0300 |
commit | 0933a498db5cdfdc7c425aa763b8145d801202b8 (patch) | |
tree | 568f29d063e4ca4396985f8b1c317d88aefb22a0 /main/src/addins/MonoDevelop.Refactoring | |
parent | b9a0d445d9fd864a88ff88c426df8ded230bb8f9 (diff) |
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/861121 - "System.NullReferenceException" when closing a solution while a json file is open & the solution doesn't close.
This is the MonoDevelop side of the fix for 861121. For non-C# files they could still be a part of WebEditorRoslynWorkspace, and not MonoDevelopWorkspace, and we need to gracefully deal with that.
Diffstat (limited to 'main/src/addins/MonoDevelop.Refactoring')
-rw-r--r-- | main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs index 3da12a678e..e175ef29fc 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs @@ -145,6 +145,12 @@ namespace MonoDevelop.CodeActions return Task.Run (async delegate { try { var root = await ad.GetSyntaxRootAsync (cancellationToken); + if (root == null) { + // WebEditorRoslynWorkspace adds .json, .css, .html etc. files to the workspace + // but they don't support syntax trees or semantic model + return CodeActionContainer.Empty; + } + if (root.Span.End < span.End) { LoggingService.LogError ($"Error in GetCurrentFixesAsync span {span.Start}/{span.Length} not inside syntax root {root.Span.End} document length {Editor.Length}."); return CodeActionContainer.Empty; |