[Refactoring] Switch to Roslyn CodeFixService#3636
Conversation
ca059f9 to
0841be7
Compare
|
Seems like a file was not removed from the csproj. |
|
@mkrueger any idea why this would cause an unit test failure? |
|
This will conflict once #3668 is in. |
|
Too much work to do that, I'll just rebase on top of newer editorFeatures once #3677 is in. |
5d9b236 to
51b4483
Compare
0b5a747 to
30e1a90
Compare
|
Some code actions depend on #3699 beign merged. |
|
Test failures unrelated. (They were broken during editorFeatures dev) |
|
Looking at that "Pick members" UI, I'm curious how usable it is with the keyboard alone. |
mhutch
left a comment
There was a problem hiding this comment.
Looks good. I had a bunch of comments but nothing blocking.
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| //// |
There was a problem hiding this comment.
Not sure how to hook up nuget packages analyzers. They certainly don't belong in the host diagnostics provider
There was a problem hiding this comment.
Yeah. I don't think they belong in the NuGet extension either...
Looking at
https://github.com/dotnet/roslyn/blob/48d978fbfc4a4437d3a5da60c4d823e2e593b491/src/VisualStudio/Core/SolutionExplorerShim/DiagnosticItem/CpsDiagnosticItemSource.cs, it looks like it just mirrors AnalyzerReference MSBuild items into AnalyzerReferences on the roslyn projects.
NuGet simply adds those MSBuild items into the project (SDK style projects will have this automatically, for classic projects we'll need to implement it). These items could also exist in a project file, or come from targets etc.
| currentSmartTag.ShowPopup += CurrentSmartTag_ShowPopup; | ||
| currentSmartTag.Tag = fixes; | ||
| currentSmartTag.IsVisible = fixes.CodeFixActions.Count > 0; | ||
| currentSmartTag.IsVisible = fixes.CodeFixActions.Sum (x => x.Fixes.Length) > 0; |
There was a problem hiding this comment.
Minor nitpick, wonder whether .Any(x=>x.Fixes.Length > 0) would be better as it short circuits
| static IEnumerable<CodeDiagnosticDescriptor> diagnostics; | ||
| static Dictionary<string, CodeDiagnosticDescriptor> diagnosticTable; | ||
| static SemaphoreSlim diagnosticLock = new SemaphoreSlim (1, 1); | ||
| static MonoDevelopWorkspaceDiagnosticAnalyzerProviderService.OptionsTable options = |
There was a problem hiding this comment.
Given there are so many of these, maybe move to a single MonoDevelopWorkspaceDiagnosticAnalyzerProviderService.Instance member?
There was a problem hiding this comment.
I made many copies because it's a long name. :p
| <Assembly file="RefactoringEssentials.dll"/> | ||
| </Extension> | ||
|
|
||
| <ExtensionPoint path="/MonoDevelop/Refactoring/AnalyzerAssemblies"> |
There was a problem hiding this comment.
Awesome, extensions will finally be able to cleanly add analyzers 🎉 🎉 🎉
| var providers = new List<DiagnosticAnalyzer> (); | ||
| var alreadyAdded = new HashSet<Type> (); | ||
| var diagnostics = await CodeRefactoringService.GetCodeDiagnosticsAsync (new EmptyDocumentContext (project), LanguageNames.CSharp, default (CancellationToken)); | ||
| var diagnostics = options.AllDiagnostics.Where (x => x.Languages.Contains (LanguageNames.CSharp)); |
There was a problem hiding this comment.
This pattern seems to come up a bit, maybe a options.GetDiagnostics(string language) would be better
There was a problem hiding this comment.
Also, wondering whether we can stop hardcoding C# everywhere?
There was a problem hiding this comment.
When we have a language mapping in the project model, sure.
|
|
||
| void LoadAnalyzerAssemblies() | ||
| { | ||
| RuntimeEnabledAssemblies = AddinManager.GetExtensionNodes<AssemblyExtensionNode> (extensionPath).Select (b => b.FileName).ToArray (); |
There was a problem hiding this comment.
Would be nice to subscribe to extension changes so analyzers from newly installed extensions can load without a restart.
There was a problem hiding this comment.
Roslyn doesn't re-query that. It's not a workspace service
There was a problem hiding this comment.
Oh, that's a shame :(
I guess we could always add them as workspace AnalyzerReferences if we wanted to support this. Probably safest just to add a forced restart after installing or uninstalling extensions though.
| { | ||
| internal class OptionsTable | ||
| { | ||
| Dictionary<string, CodeDiagnosticDescriptor> diagnosticTable = new Dictionary<string, CodeDiagnosticDescriptor> (); |
There was a problem hiding this comment.
It'll be nice when we finally get rid of these wrapper classes
There was a problem hiding this comment.
Yeah, right now, we have to keep our UI usable.
|
@Therzok can you fix the conflicts? |
…kspace provider Also fix refactorings taking into account options UI.
|
Done! |

No description provided.