-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add dotPeek-style navigation and dependency features #4199
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
Closed
+9,941
−27
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
afc8a84
Add Navigate menu slot and resources for dotPeek-style navigation
pieroviano 7d23307
Add assembly dependency navigation: Referenced By, Dependent Code, di…
pieroviano a266880
Add dotPeek-style go-to commands and Navigate To popup
pieroviano b7fe082
Add recent files/locations, Go to Line, caret highlighting, rename pr…
pieroviano 65a4a28
Add Type Hierarchy and File Structure panes and Go to File Member
pieroviano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
ICSharpCode.ILSpyX/Analyzers/Builtin/ModuleDependentCodeAnalyzer.cs
This file contains hidden or 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,68 @@ | ||
| // Copyright (c) 2026 Piero Viano | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
| // software and associated documentation files (the "Software"), to deal in the Software | ||
| // without restriction, including without limitation the rights to use, copy, modify, merge, | ||
| // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | ||
| // to whom the Software is furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in all copies or | ||
| // substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
| // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| // DEALINGS IN THE SOFTWARE. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Composition; | ||
|
|
||
| using ICSharpCode.Decompiler.Metadata; | ||
| using ICSharpCode.Decompiler.TypeSystem; | ||
| using ICSharpCode.ILSpyX.Dependencies; | ||
|
|
||
| namespace ICSharpCode.ILSpyX.Analyzers.Builtin | ||
| { | ||
| /// <summary> | ||
| /// For an assembly, lists the code in the other assemblies of the list that depends on it: every | ||
| /// type or member whose signature, base types, attributes or body uses a type or member of the | ||
| /// analyzed assembly. Results are grouped by referencing assembly (assemblies in list order). | ||
| /// </summary> | ||
| [ExportAnalyzer(Header = ModuleAnalyzerHeaders.DependentCode, Order = 20)] | ||
| [Shared] | ||
| class ModuleDependentCodeAnalyzer : IAnalyzer | ||
| { | ||
| public bool Show(ISymbol? symbol) => symbol is IModule { MetadataFile.IsAssembly: true }; | ||
|
|
||
| public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(analyzedSymbol); | ||
| ArgumentNullException.ThrowIfNull(context); | ||
| if (analyzedSymbol is not IModule { MetadataFile: { } target }) | ||
| throw new ArgumentException("A module with metadata is required.", nameof(analyzedSymbol)); | ||
| return AnalyzeCore(target, context); | ||
| } | ||
|
|
||
| static IEnumerable<ISymbol> AnalyzeCore(MetadataFile target, AnalyzerContext context) | ||
| { | ||
| var ct = context.CancellationToken; | ||
| var assemblies = context.AssemblyList.GetAllAssemblies().GetAwaiter().GetResult(); | ||
| foreach (var assembly in assemblies) | ||
| { | ||
| ct.ThrowIfCancellationRequested(); | ||
| var module = assembly.GetMetadataFileOrNull(); | ||
| if (module == null || module.IsMetadataOnly || ReferenceEquals(module, target)) | ||
| continue; | ||
| var references = DependentCodeScanner.FindReferencesTo(module, target); | ||
| if (references.Count == 0) | ||
| continue; | ||
| var typeSystem = context.GetOrCreateTypeSystem(module); | ||
| foreach (var symbol in DependentCodeScanner.FindDependentSymbols(module, typeSystem, references, ct)) | ||
| yield return symbol; | ||
| } | ||
| } | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
ICSharpCode.ILSpyX/Analyzers/Builtin/ModuleReferencedByAnalyzer.cs
This file contains hidden or 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,59 @@ | ||
| // Copyright (c) 2026 Piero Viano | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
| // software and associated documentation files (the "Software"), to deal in the Software | ||
| // without restriction, including without limitation the rights to use, copy, modify, merge, | ||
| // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | ||
| // to whom the Software is furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in all copies or | ||
| // substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
| // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| // DEALINGS IN THE SOFTWARE. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Composition; | ||
|
|
||
| using ICSharpCode.Decompiler.Metadata; | ||
| using ICSharpCode.Decompiler.TypeSystem; | ||
| using ICSharpCode.ILSpyX.Dependencies; | ||
|
|
||
| namespace ICSharpCode.ILSpyX.Analyzers.Builtin | ||
| { | ||
| /// <summary> | ||
| /// For an assembly, lists the assemblies of the list that reference it (by name and public key | ||
| /// token; the referenced version may differ). Each result is itself a module, so it can be | ||
| /// expanded to follow the chain of referencing assemblies further. | ||
| /// </summary> | ||
| [ExportAnalyzer(Header = ModuleAnalyzerHeaders.ReferencedBy, Order = 10)] | ||
| [Shared] | ||
| class ModuleReferencedByAnalyzer : IAnalyzer | ||
| { | ||
| public bool Show(ISymbol? symbol) => symbol is IModule { MetadataFile.IsAssembly: true }; | ||
|
|
||
| public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(analyzedSymbol); | ||
| ArgumentNullException.ThrowIfNull(context); | ||
| if (analyzedSymbol is not IModule { MetadataFile: { } target }) | ||
| throw new ArgumentException("A module with metadata is required.", nameof(analyzedSymbol)); | ||
| return AnalyzeCore(target, context); | ||
| } | ||
|
|
||
| static IEnumerable<ISymbol> AnalyzeCore(MetadataFile target, AnalyzerContext context) | ||
| { | ||
| var assemblies = context.AssemblyList.GetAllAssemblies().GetAwaiter().GetResult(); | ||
| foreach (var referencing in ReferencedByFinder.FindReferencingAssemblies(assemblies, target, context.CancellationToken)) | ||
| { | ||
| context.CancellationToken.ThrowIfCancellationRequested(); | ||
| yield return context.GetOrCreateTypeSystem(referencing.Module).MainModule; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,30 @@ | ||
| // Copyright (c) 2026 Piero Viano | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
| // software and associated documentation files (the "Software"), to deal in the Software | ||
| // without restriction, including without limitation the rights to use, copy, modify, merge, | ||
| // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | ||
| // to whom the Software is furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in all copies or | ||
| // substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
| // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| // DEALINGS IN THE SOFTWARE. | ||
|
|
||
| namespace ICSharpCode.ILSpyX.Analyzers | ||
| { | ||
| /// <summary> | ||
| /// Headers of the built-in analyzers that apply to whole modules, so hosts can locate the | ||
| /// matching analyzer row of an analyzed module. | ||
| /// </summary> | ||
| public static class ModuleAnalyzerHeaders | ||
| { | ||
| public const string ReferencedBy = "Referenced By"; | ||
| public const string DependentCode = "Dependent Code"; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
unnecessary bloat, please remove, if you need constants you can add them closer to the actual use sites.