-
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
Disable cake diagnostics endpoint for requests that don't specify a file #1107
Conversation
Cake's diagnostics engine calls the generic CodeCheckService, which generates all diagnostics for the solution if called without a specific file path. This results in duplicate errors in C# projects when VS Code requests project level diagnostics. The solution is to only compute diagnostics for specified files. Fixes dotnet/vscode-csharp#1830
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.
Don't think it's necessary to introduce a new virtual
method in CakeRequestHandler
since Handle
is already virtual.
|
||
return await TranslateResponse(response, request); | ||
} | ||
|
||
public virtual Task<TResponse> HandleCore(TRequest request, IRequestHandler<TRequest, TResponse> service) |
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.
Is it necessary to introduce this? Task<TResponse> Handle(TRequest request)
is already virtual
.
@@ -14,5 +15,15 @@ public class CodeCheckHandler : CakeRequestHandler<CodeCheckRequest, QuickFixRes | |||
: base(workspace) | |||
{ | |||
} | |||
|
|||
public override Task<QuickFixResponse> HandleCore(CodeCheckRequest request, IRequestHandler<CodeCheckRequest, QuickFixResponse> service) |
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.
Override Task<TResponse> Handle(TRequest request)
instead.
return Task.FromResult(new QuickFixResponse()); | ||
} | ||
|
||
return service.Handle(request); |
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.
Override Task Handle(TRequest request) and call base.Handle(request)
instead?
@mholo65 It seems like Handle() does a bunch of pre- and post-processing on the request and result type that every overrider shouldn't have to be concerned with. I therefore added HandleCore where endpoints only have to be concerned with the actual call to the underlying service. Thoughts? |
@rchande that’s a valid point. Instead of adding a new |
@mholo65 Good idea, I'll do that. |
var diagnostics = await FindDiagnostics(input, includeFileName: false); | ||
Assert.Null(diagnostics); | ||
} | ||
private async Task<QuickFixResponse> FindDiagnostics(string contents, bool includeFileName) |
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.
blank line above
@@ -54,11 +54,15 @@ protected CakeRequestHandler(OmniSharpWorkspace workspace) | |||
|
|||
request = await TranslateRequestAsync(request); | |||
|
|||
var response = await service.Handle(request); | |||
var response = IsValid(request) |
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.
Maybe check validity before TranslateRequest
?
Cake's diagnostics engine calls the generic CodeCheckService, which generates all diagnostics for the solution if called without a specific file path. This results in duplicate errors in C# projects when VS Code requests project level diagnostics. The solution is to only compute diagnostics for specified files.
Fixes dotnet/vscode-csharp#1830
Diagnostics window in VS Code now looks like:
cc @mholo65