Use appropriate analyzer category for these analyzers.#26671
Use appropriate analyzer category for these analyzers.#26671sharwell merged 1 commit intodotnet:masterfrom
Conversation
|
Tagging @dotnet/roslyn-ide @sharwell @mavasani @heejaechang |
| public override DiagnosticAnalyzerCategory GetAnalyzerCategory() | ||
| => DiagnosticAnalyzerCategory.SemanticDocumentAnalysis; | ||
| => DiagnosticAnalyzerCategory.SemanticSpanAnalysis; | ||
|
|
There was a problem hiding this comment.
inline decl convert int x; ... out x to out var x, it only need to reanalyze a method when that method body changes.
|
|
||
| public override DiagnosticAnalyzerCategory GetAnalyzerCategory() => DiagnosticAnalyzerCategory.SemanticDocumentAnalysis; | ||
| public override DiagnosticAnalyzerCategory GetAnalyzerCategory() | ||
| => DiagnosticAnalyzerCategory.SemanticSpanAnalysis; |
There was a problem hiding this comment.
this is probably too broad as well. i think this should just be .SyntaxAnalysis.
There was a problem hiding this comment.
SyntaxAnalysis means it registers only syntax tree actions, that never use semantic model (essentially like parse diagnostics).
There was a problem hiding this comment.
yup. i believe that's the case here. but i'm just being paranoid.
|
Commit 516358c looks fine, but marking as Needs Design Review to discuss the indentation guide used in d7f4ea7959967203624aacc756208a99e20ee425. 📝 Alternately, the latter could be removed from this PR to unblock it. |
|
I woudl prefer to not decouple. It pushes people away from always being willing to clean up anything they run into along the way as they do work. Please review at earliest convenience. Hopefully these sorts of changes in teh future do not cause an unnecessarily large impact on PR time. |
|
Tagging @jinujoseph @kuhlenh @sharwell @CyrusNajmabadi - I think both of you are right in your own way, and missing piece here is accurate guidelines here for both the PR reviewers and contributors.
As a start, our team is currently working on a proposed set of guidelines for PR contributions to IDE analyzers/fixers/refactorings (which have most community interaction). We hope to discuss and agree upon these guidelines soon and then open it for public feedback. Once finalized, we will post it on GitHub and try these across few PRs, and iterate towards the optimal set. For this specific concern my take is as follows:
|
|
@mavasani I like a lot of that. I will say this though:
I've seen a lot of projects get to the point where they end up not wanting to do anything about this, and people are dissuaded from any form of cleanup because no decision was made about any sort of preferred style. These codebases end up stagnating heavily with code getting worse and worse because there aren't efforts to keep it tidy. I very much like the approach the IDE has taken since VS2002, which is to always be willing to make safe and simple cleanup changes throughout the codebase toward keeping things continually healthy. |
|
@CyrusNajmabadi - Sure, I understand you. I only meant to recommend separating out the cleanup from functional changes for things that have no agreed upon guidelines or team preferences at PR time. Once we have agreed upon guidelines, I think code style fixup should be done as part of functional changes for files/functions being touched. Ideally, once we have NuGet code style analyzers/code fixes for our rules, these will be enforced via build, but till then we need to find a good balance to ensure we are driving the PR (and hence the functional changes) towards completion and at the same time not letting the code get polluted with many different code styles. Hopefully, the guidelines will provide clarity. |
That's fine. It was a second commit after all :) Now if this needs to be a second PR... that's somewhat of a more aggressive change, which i think will vastly demotivate cleanup from happening. The reason for that is that it's much easier to just roll cleanup into larger work you're doing, whereas going through the entire process that involves a PR is asking a lot. This is esp. true as i expect cleanup PRs to be even lower pri for the team, which effectively means that they won't happen, or will happen so slowly that you'll just be juggling PRs even longer.
This also worries me (a bit). We've been working on codebases for decades. I've seen how long it takes to actually get around to having guidelines and having those guidelines sufficient for all the types of changes that people want to make. This ties into my previous statement htat trying to go this route just seems to rarely bear fruit. Which is why the general approach the IDE has taken (which has actually worked) is to just let cleanup happen and to recognize that trying to make too much process around it is actually what kills it, and there's little issue with allowing it to happen organically. Now, if you can actually great and maintain guidelines expeditiously, then that would change my opinion. Until that point, i would prefer hte status quo be kept. And once a new system has proven itself, we can delegate to that as the mechanism we prfer. However, holding off until that happens is something i would like to avoid at all costs. |
df57ee7 to
516358c
Compare
|
@jinujoseph for approval |
|
@jinujoseph can you approve/merge? Thanks! |
|
Approved to merge for 15.8.preview2 |
|
Note: style changes were rolled back. So this is fine to merge as is. @sharwell will be bringing up what style preferences should be recommended at a future point. |
Noticed while reviewing: #26590
A lot of our built in analyzers use to broad a analyzer-category. This means they will run again, even when edits happen that won't affect them.
Specifically, we have the concept of 'SemanticSpan' analysis. This category can be thought of "do i need to be rerun if a method body i'm contained in changes?" vs. "SemanticDocument" analysis which can be thought of "do i need to be rerun if anything in this document changes?". "Remove unnecessary imports" is a good example of the latter. When you make an edit to any method, you'd have to reconsider if your imports are used or not. However, for something like "use object initializer" you don't need to examine all the methods in a file when one method body is edited.