Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

[Refactoring] Switch to Roslyn CodeFixService#3636

Merged
Therzok merged 9 commits intoeditorFeaturesfrom
codefix
Feb 23, 2018
Merged

[Refactoring] Switch to Roslyn CodeFixService#3636
Therzok merged 9 commits intoeditorFeaturesfrom
codefix

Conversation

@Therzok
Copy link
Contributor

@Therzok Therzok commented Jan 12, 2018

No description provided.

@Therzok Therzok force-pushed the codefix branch 2 times, most recently from ca059f9 to 0841be7 Compare January 12, 2018 14:31
Copy link
Contributor

@mkrueger mkrueger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I <3 removing code :)

@Therzok
Copy link
Contributor Author

Therzok commented Jan 15, 2018

Seems like a file was not removed from the csproj.

@Therzok
Copy link
Contributor Author

Therzok commented Jan 15, 2018

@mkrueger any idea why this would cause an unit test failure?

@Therzok
Copy link
Contributor Author

Therzok commented Jan 16, 2018

This will conflict once #3668 is in.

@Therzok
Copy link
Contributor Author

Therzok commented Jan 16, 2018

I'll refactor this PR and split stuff which doesn't directly affect code fixes into master.

Too much work to do that, I'll just rebase on top of newer editorFeatures once #3677 is in.

@Therzok Therzok force-pushed the codefix branch 4 times, most recently from 5d9b236 to 51b4483 Compare January 18, 2018 14:59
@Therzok
Copy link
Contributor Author

Therzok commented Jan 18, 2018

Feedback from vaclav on the pick members UI. Will probably need to backport these fixes to the implement interface members UI.

image

@Therzok
Copy link
Contributor Author

Therzok commented Feb 15, 2018

Some code actions depend on #3699 beign merged.

@Therzok
Copy link
Contributor Author

Therzok commented Feb 15, 2018

Test failures unrelated.

(They were broken during editorFeatures dev)

@mhutch
Copy link
Contributor

mhutch commented Feb 16, 2018

Looking at that "Pick members" UI, I'm curious how usable it is with the keyboard alone.

Copy link
Contributor

@mhutch mhutch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
////
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why's this disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to hook up nuget packages analyzers. They certainly don't belong in the host diagnostics provider

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick, wonder whether .Any(x=>x.Fixes.Length > 0) would be better as it short circuits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point!

static IEnumerable<CodeDiagnosticDescriptor> diagnostics;
static Dictionary<string, CodeDiagnosticDescriptor> diagnosticTable;
static SemaphoreSlim diagnosticLock = new SemaphoreSlim (1, 1);
static MonoDevelopWorkspaceDiagnosticAnalyzerProviderService.OptionsTable options =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given there are so many of these, maybe move to a single MonoDevelopWorkspaceDiagnosticAnalyzerProviderService.Instance member?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made many copies because it's a long name. :p

<Assembly file="RefactoringEssentials.dll"/>
</Extension>

<ExtensionPoint path="/MonoDevelop/Refactoring/AnalyzerAssemblies">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern seems to come up a bit, maybe a options.GetDiagnostics(string language) would be better

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, wondering whether we can stop hardcoding C# everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have a language mapping in the project model, sure.


void LoadAnalyzerAssemblies()
{
RuntimeEnabledAssemblies = AddinManager.GetExtensionNodes<AssemblyExtensionNode> (extensionPath).Select (b => b.FileName).ToArray ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to subscribe to extension changes so analyzers from newly installed extensions can load without a restart.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roslyn doesn't re-query that. It's not a workspace service

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be nice when we finally get rid of these wrapper classes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, right now, we have to keep our UI usable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know :)

@slluis
Copy link
Member

slluis commented Feb 22, 2018

@Therzok can you fix the conflicts?

@Therzok
Copy link
Contributor Author

Therzok commented Feb 22, 2018

Done!

@Therzok Therzok merged commit 1ba94df into editorFeatures Feb 23, 2018
@Therzok Therzok deleted the codefix branch February 23, 2018 14:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants