-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Fix Stack Trace Explorer for additional documents #77517
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 1 commit
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
using System.Collections.Immutable; | ||
using System.Composition; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.EmbeddedLanguages.StackFrame; | ||
|
@@ -17,15 +18,11 @@ | |
namespace Microsoft.CodeAnalysis.StackTraceExplorer; | ||
|
||
[ExportWorkspaceService(typeof(IStackTraceExplorerService)), Shared] | ||
internal sealed class StackTraceExplorerService : IStackTraceExplorerService | ||
[method: ImportingConstructor] | ||
[method: System.Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
internal sealed class StackTraceExplorerService() : IStackTraceExplorerService | ||
{ | ||
[ImportingConstructor] | ||
[System.Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
public StackTraceExplorerService() | ||
{ | ||
} | ||
|
||
public (Document? document, int line) GetDocumentAndLine(Solution solution, ParsedFrame frame) | ||
public (TextDocument? document, int line) GetDocumentAndLine(Solution solution, ParsedFrame frame) | ||
{ | ||
if (frame is ParsedStackFrame parsedFrame) | ||
{ | ||
|
@@ -73,7 +70,7 @@ public StackTraceExplorerService() | |
return await StackTraceExplorerUtilities.GetDefinitionAsync(solution, parsedFrame.Root, symbolPart, cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
private static ImmutableArray<Document> GetFileMatches(Solution solution, StackFrameCompilationUnit root, out int lineNumber) | ||
private static ImmutableArray<TextDocument> GetFileMatches(Solution solution, StackFrameCompilationUnit root, out int lineNumber) | ||
{ | ||
lineNumber = 0; | ||
if (root.FileInformationExpression is null) | ||
|
@@ -87,11 +84,16 @@ private static ImmutableArray<Document> GetFileMatches(Solution solution, StackF | |
lineNumber = int.Parse(lineString); | ||
|
||
var documentName = Path.GetFileName(fileName); | ||
var potentialMatches = new HashSet<Document>(); | ||
var potentialMatches = new HashSet<TextDocument>(); | ||
|
||
foreach (var project in solution.Projects) | ||
{ | ||
foreach (var document in project.Documents) | ||
// As of writing there is no way to get all the documents for a specific project | ||
// so we need to check both the main and additional documents. If more document types | ||
// get added this likely will need to be updated. | ||
var allDocuments = project.Documents.Concat(project.AdditionalDocuments); | ||
|
||
foreach (var document in allDocuments) | ||
{ | ||
if (document.FilePath == fileName) | ||
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. If matching by an exact file path is always the winner, shouldn't we be calling GetDocumentIdsWithFilePath and only if it doesn't find anything, then falling back to the weaker search? 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. Considering it is returning the first document, I suggested 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.
|
||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.