Open Zastai opened 2 years ago
Of course, a document could be unused at write time because Cecil was used to remove some code and/or sequence points. In that case, those should probably be discarded. But ones that were present in the PDB before reaching Cecil should probably be retained (especially when source code is embedded as well).
One approach might be to:
ModuleDebugInformation
to be able to expose some of the top-level metadata, like the documents tableDocument
would need to be tied to that, so that it could have methods that determine whether it's used (and by which sequence points, assuming only sequence points refer to documents)DocumentCollection
that manages documents
RemovedUnusedEntries()
methodDocument
from the target moduleThat sounds like a lot of work to make sure it's all tracked correctly, with a potentially major impact.
That sounds like a lot of work to make sure it's all tracked correctly, with a potentially major impact.
Yeah, that one is not going to be fun. Need to think about how best to approach it.
Compilation output will include all sources involved in the build as
Document
entries in the (portable) PDB.This includes non-code sources, such as the
AssemblyInfo.cs
files generated by the build, for assembly/module attributes.After loading an assembly with Mono.Cecil with symbol processing enabled and then writing it back, I observe that this has been reduced to a smaller set, presumably discarding any document that is not used by any sequence points.
I don't mind having methods like
DiscardUnusedDocuments()
available to "trim" debug info if I want to do so, but I would not expect that to happen by default. This discards potentially useful information.