-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ignore diagnostics for generated code #2509
Conversation
Ready for review now. |
Hi @Anakael, please restore the CsDiagnosticWorker. Not all users want the added overhead of running analyzers in their editor. The CsDiagnosticWorker exists to provide compiler diagnostics which are less costly. |
I've added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution. I know there are a lot of developers who will appreciate this improvement. To move forward with this please move new logging option to a separate PR as that will take additional time to consider.
public Matcher BuildMatcher() | ||
{ | ||
Matcher matcher = new(); | ||
matcher.AddIncludePatterns(new string[] { "./**/*", "./*" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could open a folder containing a project which has document links to source files which exist outside of the open folder. How can we make this work for that situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed exclude to include.
Now I can get diagnostics from documents outside of current directory.
But now there is opposite problem: documents outside of current directory can not be ignored via options :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason Matcher doesn't work well will relation pathes outside current directory.
But I don't think this is huge problem since ignoring documents outside directory of current solution is not frequent case.
src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticWorkerWithAnalyzers.cs
Outdated
Show resolved
Hide resolved
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears there are some failing tests. Do they pass when you run them locally?
# for testing against mono
./build.sh -T Test
# for testing against dotnet
./build.sh -T Test --use-dotnet-test
src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticWorkerWithAnalyzers.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Joey Robichaud <joseph.robichaud@microsoft.com>
…icWorkerWithAnalyzers.cs Co-authored-by: Joey Robichaud <joseph.robichaud@microsoft.com>
Nope. Now 2 tests are failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took some time to look at the errors and have a few suggestions.
I would also update the OmniSharpEnvironment.cs to always ensure the TargetDirectory contains an ending slash. Otherwise the GetRelativePath call can return some odd results.
if (TargetDirectory[TargetDirectory.Length - 1] != Path.DirectorySeparatorChar)
{
TargetDirectory += Path.DirectorySeparatorChar;
}
var documentIds = GetDocumentIdsFromPaths(documentPaths); | ||
ImmutableArray<DocumentId> documentIds = (await Task.WhenAll( | ||
documentPaths | ||
.Select(docPath => _workspace.GetDocumentsFromFullProjectModelAsync(docPath)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good change. When projects are loaded on demand the documents may not be part of the workspace, since it will be waiting on a design time build.
src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticWorkerBase.cs
Outdated
Show resolved
Hide resolved
src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticWorkerWithAnalyzers.cs
Outdated
Show resolved
Hide resolved
Done. |
After pulling the latest update from this PR I've got 56 tests failed. Most with such error:
|
Still get errors after merge. |
…roslyn into pr/anakael/fix-ignore
…r/anakael/fix-ignore
Now all tests pass success locally. |
@@ -44,20 +44,6 @@ private Task ReadyHost(bool roslynAnalyzersEnabled) | |||
{{"RoslynExtensionsOptions:EnableAnalyzersSupport", roslynAnalyzersEnabled.ToString()}}); | |||
} | |||
|
|||
[Fact] | |||
public async Task CheckAllFilesOnNonAnalyzerReturnImmediatlyAllResults() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now non analyzer diagnostic worker works the same way as analyzer which uses queue. I think this test is not actual anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anakael I appreciate you sticking with this PR. Thanks for the contribution!
Was described in: #2437
UPD:
5) I've also dropped CsDiagnosticWorker as it seems to be strange to have two classes for the same logic. Also, this class wasn't updated for two years.