-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use operations in our analyzers that need symbols (#17001)
Fixes: #16922 This change updates our analyzers that need access to the symbols to use `IOperation` where possible. Using syntax analysis for this kind of analyzer has worse performance. These analyzers run on generated code, which can include EF migrations, the design of which amplifies these effects. On the path to this, I also added support for a few more cases that operations make easy. Since we're doing this anyway, I want to have confidence that we're checking everything (within reason). In some cases the diagnostic experience changed a bit (including more of the declaration/code) - I felt like all of these were OK changes. Given the kinds of error message reported by the analyzers "don't use that type" it seems like it's still a good enough experience without micro-optimizing all of the locations.
- Loading branch information
Showing
8 changed files
with
232 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
...TestFiles/ComponentInternalUsageDiagnosticsAnalyzerTest/UsesRenderTreeFrameAsParameter.cs
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
...s/test/TestFiles/ComponentInternalUsageDiagnosticsAnalyzerTest/UsesRendererAsBaseClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Components.RenderTree; | ||
|
||
namespace Microsoft.AspNetCore.Components.Analyzers.Tests.TestFiles.ComponentInternalUsageDiagnosticsAnalyzerTest | ||
{ | ||
/*MM*/class UsesRendererAsBaseClass : Renderer | ||
{ | ||
public UsesRendererAsBaseClass() | ||
: base(null, null) | ||
{ | ||
} | ||
|
||
public override Dispatcher Dispatcher => throw new NotImplementedException(); | ||
|
||
protected override void HandleException(Exception exception) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override Task UpdateDisplayAsync(/*M1*/in RenderBatch renderBatch) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...estFiles/ComponentInternalUsageDiagnosticsAnalyzerTest/UsesRendererTypesInDeclarations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Components.RenderTree; | ||
|
||
namespace Microsoft.AspNetCore.Components.Analyzers.Tests.TestFiles.ComponentInternalUsageDiagnosticsAnalyzerTest | ||
{ | ||
/*MMBaseClass*/class UsesRendererTypesInDeclarations : Renderer | ||
{ | ||
private Renderer /*MMField*/_field = null; | ||
|
||
public UsesRendererTypesInDeclarations() | ||
: base(null, null) | ||
{ | ||
} | ||
|
||
public override Dispatcher Dispatcher => throw new NotImplementedException(); | ||
|
||
/*MMProperty*/public Renderer Property { get; set; } | ||
|
||
protected override void HandleException(Exception exception) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/*MMParameter*/protected override Task UpdateDisplayAsync(in RenderBatch renderBatch) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/*MMReturnType*/private Renderer GetRenderer() => _field; | ||
} | ||
} |
Oops, something went wrong.