Include source files w/o method bodies in the PDB documents#39136
Include source files w/o method bodies in the PDB documents#39136ivanbasov merged 9 commits intodotnet:masterfrom
Conversation
| } | ||
|
|
||
| nativePdbWriterOpt.WriteRemainingEmbeddedDocuments(mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments); | ||
| nativePdbWriterOpt.WriteRemainingDebugDocuments(mdWriter.Module.DebugDocumentsBuilder.GetAllDebugDocuments()); |
There was a problem hiding this comment.
Nit: this boxes the ImmutableArray<T> into IEnumerable<T>. Given both these APIs are new consider changing the type of one to avoid the box. #Resolved
| } | ||
|
|
||
| /// <summary> | ||
| /// Add document entries for all debug documents that does not yet have an entry. |
There was a problem hiding this comment.
does [](start = 62, length = 4)
typo: do #Resolved
|
@tmat PDB tests have been fixed. |
| { | ||
| GetOrAddDocument(document, _documentIndex); | ||
| } | ||
| } |
There was a problem hiding this comment.
Why do we need two methods? They seem to be doing the same thing. #Resolved
| } | ||
|
|
||
| internal ImmutableArray<Cci.DebugSourceDocument> GetAllDebugDocuments() | ||
| => _debugDocuments.Values.ToImmutableArray(); |
There was a problem hiding this comment.
_debugDocuments.Values.ToImmutableArray(); [](start = 15, length = 42)
This will result in non-deterministic PDB. We need to order the documents somehow. #Resolved
There was a problem hiding this comment.
We could also optimize this to avoid allocations and extra work. Return IReadOnlyDictionary from this method. Enumerate the dictionary in AddRemainingDebugDocuments to filter out documents that are already indexed. Sort the remaining and add them.
In reply to: 333275492 [](ancestors = 333275492)
There was a problem hiding this comment.
Sounds good. I just think that filtering is not necessary because we add only item not yet added.
In reply to: 333278515 [](ancestors = 333278515,333275492)
There was a problem hiding this comment.
The filtering is an optimization, so that we don't need to sort all the documents upfront just to realize we only need to add a few. #Resolved
There was a problem hiding this comment.
| @@ -104,6 +104,7 @@ internal static bool WritePeToStream( | |||
| } | |||
|
|
|||
| nativePdbWriterOpt.WriteRemainingEmbeddedDocuments(mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments); | |||
There was a problem hiding this comment.
WriteRemainingEmbeddedDocuments [](start = 35, length = 31)
I don't think this is necessary anymore - embedded sources are added to the set of all debug documents on the document builder in CreateDebugDocuments. If we make sure we add an entry for each document then it follows that all embedded documents will also be added.
Also, once we remove this call we can remove EmbeddedDocuments array from DebugDocumentsBuilder. #Resolved
| { | ||
| Debug.Assert(document.GetSourceInfo().EmbeddedTextBlob != null); | ||
| GetOrAddDocument(document, _documentIndex); | ||
| GetOrAddDocument(kvp.Value, _documentIndex); |
There was a problem hiding this comment.
GetOrAddDocument [](start = 16, length = 16)
Nit: we could factor out AddDocument method - here we don't need to check again that the document is in the index. #Resolved
| } | ||
| } | ||
|
|
||
| [ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] |
There was a problem hiding this comment.
[ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] [](start = 8, length = 102)
Is there a reason to limit the test to Win desktop? This should work on all platforms. #Resolved
There was a problem hiding this comment.
@tmat , neighbor tests apply these restrictions. And in the previous iteration, those tests failed in Linux and Mac only: https://dev.azure.com/dnceng/public/_build/results?buildId=383581&view=ms.vss-test-web.build-test-results-tab #Resolved
There was a problem hiding this comment.
The C# ones did not fail. The VB ones failed because VB PDB tests don't normalize line endings yet (WithWindowsLineBreaks). #Resolved
| "); | ||
| } | ||
|
|
||
| [ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] |
There was a problem hiding this comment.
[ConditionalFact(typeof(WindowsDesktopOnly), Reason = ConditionalSkipReason.NativePdbRequiresDesktop)] [](start = 8, length = 102)
The same here. #Resolved
Please mark that test as skipped for now and file an issue to follow up. |
| } | ||
|
|
||
| [Fact] | ||
| [Fact(Skip = "https://github.com/dotnet/roslyn/issues/39271")] |
There was a problem hiding this comment.
Is this just because the test was implicitly assuming the old behavior and we need some new way to write the test? (The filed bug doesn't make it clear if we understand the issue here.)
| foreach (var document in embeddedDocuments) | ||
| foreach (var kvp in documents | ||
| .Where(kvp => !_documentIndex.ContainsKey(kvp.Value)) | ||
| .OrderBy(kvp => kvp.Key)) |
There was a problem hiding this comment.
OrderBy [](start = 17, length = 7)
I didn't understand why we need ordering. There are other methods that invoke AddDocumentIndex and don't seem to do so in any particular order (namely GetDocumentIndex).
There was a problem hiding this comment.
This is to resolve #39136 (comment)
I think there is some kind of ordering in documents for ones having sequence points likely governed by sequence points ordering. And we want to have some consistence for the order of documents without sequence points. Let them be ordered by file names. @tmat may want to comment more.
There was a problem hiding this comment.
Any time we produce output based on dictionary enumeration we need to order the results in order to achieve determinism.
Fixes #38954
Currently the compiler does not list source files in the debug documents in the PDB that are part of the compilation but do not have any method body. These documents are only added in order to support sequence points.