-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Simplify internal analyzer api #78070
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,6 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| #nullable disable | ||
|
|
||
| using System.Collections.Immutable; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
@@ -17,30 +15,15 @@ namespace Microsoft.CodeAnalysis.Xaml.Diagnostics.Analyzers; | |
| internal sealed class XamlDocumentDiagnosticAnalyzer : DocumentDiagnosticAnalyzer | ||
| { | ||
| public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics | ||
| { | ||
| get | ||
| { | ||
| return XamlProjectService.AnalyzerService?.SupportedDiagnostics ?? []; | ||
| } | ||
| } | ||
|
|
||
| public override async Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) | ||
| { | ||
| if (XamlProjectService.AnalyzerService == null) | ||
| { | ||
| return []; | ||
| } | ||
|
|
||
| return await XamlProjectService.AnalyzerService.AnalyzeSyntaxAsync(document, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| => XamlProjectService.AnalyzerService?.SupportedDiagnostics ?? []; | ||
|
|
||
| public override async Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) | ||
| { | ||
| if (XamlProjectService.AnalyzerService == null) | ||
| { | ||
| return []; | ||
| } | ||
| public override async Task<ImmutableArray<Diagnostic>> AnalyzeSyntaxAsync(TextDocument textDocument, SyntaxTree? tree, CancellationToken cancellationToken) | ||
| => XamlProjectService.AnalyzerService is null || textDocument is not Document document | ||
| ? [] | ||
| : await XamlProjectService.AnalyzerService.AnalyzeSyntaxAsync(document, cancellationToken).ConfigureAwait(false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. because on different paths we return different values.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making sure we're thinking of the same change:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CyrusNajmabadi -- not a deal breaker, just curious why the suggested code wouldn't work
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would work... Or just the code already there :-)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not huge on avoiding async/await personally. |
||
|
|
||
| return await XamlProjectService.AnalyzerService.AnalyzeSemanticsAsync(document, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| public override async Task<ImmutableArray<Diagnostic>> AnalyzeSemanticsAsync(TextDocument textDocument, SyntaxTree? tree, CancellationToken cancellationToken) | ||
| => XamlProjectService.AnalyzerService is null || textDocument is not Document document | ||
| ? [] | ||
| : await XamlProjectService.AnalyzerService.AnalyzeSemanticsAsync(document, cancellationToken).ConfigureAwait(false); | ||
| } | ||
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.
no need to check for it being a Document?
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.
No. This is just text code