-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use WellKnownTypeProvider + KnownSymbols pattern to simplify analyzers (
#245) Change adds two related types and refactors the analyzers such that the string-based `WellKnownMockTypes` can be deleted. These changes unlock additional refactoring, but I stopped to get feedback. The main changes are: ## WellKnownTypeProvider WellKnownTypeProvider comes from [roslyn-analyzers](https://github.com/[dotnet/roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers)). It caches `ISymbol` lookups for a given `Compilation` to amortize costs across all the analyzers running for a given compilation. It also enforces some best practices when looking for "well known" symbols in the cases of name collisions. ## KnownSymbols KnownSymbols comes from [typeshape-csharp](https://github.com/eiriktsarpalis/typeshape-csharp) to simplify looking up types in the WellKnownTypeProvider. In this change only types are cached, the member lookups (methods, fields, etc.) are not. However, Roslyn internally caches, so it isn't clear that's needed. Using the KnownSymbols pattern cleans up the code quite a bit. It does push us away from SyntaxNodes and towards Symbols, however I don't think that's a bad thing because we also want to migrate to the IOperation-based analysis, which already has the corresponding ISymbol available at the start of analysis. The existing benchmarks show the new and old code (v0.1.0) to be within the margin of error. --------- Co-authored-by: Richard Murillo <[email protected]>
- Loading branch information
1 parent
aabe3d1
commit d25b4de
Showing
32 changed files
with
864 additions
and
338 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<Project> | ||
<ItemGroup> | ||
<PackageVersion Include="PolySharp" Version="1.14.1" /> | ||
</ItemGroup> | ||
<PackageVersion Include="Polyfill" Version="7.1.2" /> | ||
</ItemGroup> | ||
</Project> |
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
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
Oops, something went wrong.