-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Improved User Experience with "Navigate to decompiled sources" #29149
Improved User Experience with "Navigate to decompiled sources" #29149
Conversation
…arp.EditorFeatures * Add Microsoft.CodeAnalysis.Editor.IDecompiledSourceService * Add basic implementation of the IDecompiledSourceService for C#: CSharpDecompiledSourceService * Move decompilation feature from MetadataAsSourceFileService to CSharpDecompiledSourceService
…ts in decompilation.
|
||
namespace Microsoft.CodeAnalysis.Editor.CSharp.DecompiledSource | ||
{ | ||
// This is a copy of CSharpMetadataAsSourceService.DocCommentConverter |
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.
I know that this is bad, because it essentially is code duplication, but I am not sure whether it's possible to make the CSharpMetadataAsSourceService.DocCommentConverter
accessible for the new CSharpDecompiledSourceService
.
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.
Feel free to just move the code around in features to make it more accessible; that's totally fine!
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.
I moved it to Microsoft.CodeAnalysis.CSharp.DocumentationComments
in MS.CA.CS.Features. I hope that's a suitable location.
Wow. Thanks so much! :) <3 |
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
using Microsoft.CodeAnalysis.Text; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.Editor.CSharp.DecompiledSource |
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.
technically, does this need to live at the editor layer? are there any actual editor dependencies? could this live at the C# workspace layer?
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.
➡️ Will file as a follow-up issue.
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharp/DecompiledSource/CSharpDecompiledSourceService.cs
Outdated
Show resolved
Hide resolved
} | ||
while (ns != null && !ns.IsGlobalNamespace); | ||
|
||
return string.Join(".", stack); |
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.
nit. my preference would be that we just use a SymbolDisplayFormat here. But i may be wrong given that you're using the .MetadataName. Is that necessary? can you document why?
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.
The method is called GetFullReflectionName
.... I wonder, isn't that enough documentation? As for the reason: Well... the decompiler API expects the reflection name. :)
[ExportLanguageServiceFactory(typeof(IDecompiledSourceService), LanguageNames.CSharp), Shared] | ||
internal partial class CSharpDecompiledSourceServiceFactory : ILanguageServiceFactory | ||
{ | ||
public ILanguageService CreateLanguageService(HostLanguageServices provider) |
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.
@sharwell has some patterns he'd like you do use here. Sam, can you point him at the current pattern for mef types wrt Obsolete and whatnot?
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.
➡️ Will file as a follow-up issue.
Is there anything wrong with disabling the feature for VB? I am open to discussion. However, I would really like to move the feature to a language-specific part of Roslyn. |
src/EditorFeatures/Core/Implementation/MetadataAsSource/MetadataAsSourceFileService.cs
Outdated
Show resolved
Hide resolved
src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs
Outdated
Show resolved
Hide resolved
I will check. It seems the main benefit of moving it is the formatting support. |
I'm not sure i understand your last statement. Why would it matter here? Note: it's unclear to me why the StructureProviders are not working. If this document was properly created and added to the MetadataAsSource workspace, then we should be activating and lighting up the appropriate structure/outlining helpers. You shouldn't need to do anything. |
The UI only allows for one plus/minus sign per line. That space is currently occupied by the fold for the documentation comment (it extends to the first keyword of the method declaration). So there is no more room.
roslyn/src/Features/Core/Portable/Structure/Syntax/AbstractSyntaxNodeStructureProvider.cs Lines 49 to 53 in 312b115
That's why... |
Thanks! |
But we also have: Lines 51 to 54 in 312b115
:) So that should be working here. that was the point of these structure providers. :) |
Oh, i think i get what you're saying. Effectively, for decompiled source, we want both the MetadataAsSource view for the comments on a member (that way, someone can collapse everything, and the view is very much like MAS). However, you also want to be able to collapse substructure. There are a few ways we could solve this. One would be to create a new workspace kind for this. i.e. DecompiledSource instead of MetadataAsSource. The other would be to have all the statement/expression structure providers work in a MetadataAsSource workspace. For normal MAS, this won't matter (since you don't get statements/expressions). But for DecompiledSource, it would light up structure outlining inside methods. |
As far as I understood the implementation, the MAS structure providers exist only to make the comments collapsible right to the start of the declaration and not only to the end of the comment line. |
Rigth. I misunderstood what you were saying. I thought you were saying that that functionality wasn't working. Which would def seem like a bug. It sounds like you're saying that that functionality works, but we also want to be able to collapse the substructure of a method. in that case, we likely need to light up certain other structure providers so they work in DecompiledSource. -- There's also the user-experience issue of: If i collapse the comments and i collapse an entire method body, i'll end up with effectively: /* ... */ public void Foo() /* ... */ How does a user effectively interact with this? Technically, with a mouse, i think they can expand either section by double clicking on it. but if they interact just with the margin Perhaps we can get the editor to treat multiple region s on hte same line as being controlled by a single glyph. So if you expand, you expand both. If you collapse, you collapse both. |
This went to a design review today, and we determined that the proposed changes are a clear improvement for the C# developer's experience, and the VB side can be resolved later either by allowing decompilation in those cases or by implementing the more complete experience described in #24349. |
|
||
namespace Microsoft.CodeAnalysis.Editor.CSharp.DecompiledSource | ||
{ | ||
internal class AssemblyResolver : IAssemblyResolver |
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.
📝 This was moved here without changes from MetadataAsSourceFileService.cs
using Microsoft.CodeAnalysis.Text; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.Editor.CSharp.DecompiledSource |
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.
➡️ Will file as a follow-up issue.
[ExportLanguageServiceFactory(typeof(IDecompiledSourceService), LanguageNames.CSharp), Shared] | ||
internal partial class CSharpDecompiledSourceServiceFactory : ILanguageServiceFactory | ||
{ | ||
public ILanguageService CreateLanguageService(HostLanguageServices provider) |
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.
➡️ Will file as a follow-up issue.
This pull request is intended as suggestion and should serve as basis for further discussion of the "Navigate to decompiled sources" feature.
This pull request implements the following changes:
Why
Points for further discussion
AbstractSyntaxNodeStructureProvider
to further improve the experience by completely hiding the source code when the source file is first opened. However I am not sure how to implement this, because there can only be one fold per line.