EE doesn't handle methods that span multiple documents correctly #64098
Labels
Area-IDE
Bug
Interactive-Debugging
New Language Feature - File-Local Types
File-local types (file types)
Milestone
MethodDebugInfo.ReadMethodDebugInfo
Incorrectly assumes that a method body spans only a single document:
https://github.com/dotnet/roslyn/blame/main/src/ExpressionEvaluator/Core/Source/ExpressionCompiler/PDB/MethodDebugInfo.Native.cs#L173
This is not the case for methods with
#line
directives, e.g.:Issue introduced by #62812
Solution proposal
We define a new kind of ImportScope, say Containing Document scope (kind 9). The blob of this import scope would encode the row id of the Document that contains the source code associated with this scope.
Import scopes are used to capture usings/Imports available at given LocalScope. Local scopes span a range of IL within a method and point to the ImportScope applicable to that IL range.
These constructs allow the compiler to scope usings to a whole method or a specific IL range. The latter is needed for emitting correct debug information for constructors of partial types spanning multiple files that contain field/property initializers. Each initializer IL can potentially be in scope of different usings. Note that the compiler does not emit this information correctly in this scenario, see #2846.
The EE finds the ImportScope chain associated with the current IL instruction to determine what usings are in scope for that instruction. If the chain contains Containing Document scope, it would use the inner-most one to determine what file types are available in the scope. If no Containing Document scope is present it would use the Document associated with the IL instruction (via the covering sequence point) for resolving file types.
The Containing Document scope is thus optional and the compiler should omit it if it is not needed to reduce the size of the PDB -- i.e. there are no
#line
directives or partial type field/property initializers present in the source file.Relates to test plan #60819 (file-local types)
The text was updated successfully, but these errors were encountered: