提交 3d0d5c9f 编写于 作者: J Julien

Merge pull request #8961 from jcouv/fix-4370

Fix issue 4370 - heading hidden sequence points now positioned within document. 
......@@ -5116,5 +5116,66 @@ static void M()
}
#endregion
[Fact, WorkItem(4370, "https://github.com/dotnet/roslyn/issues/4370")]
public void HeadingHiddenSequencePointsPickUpDocumentFromVisibleSequencePoint()
{
var source =
@"#line 1 ""C:\Async.cs""
#pragma checksum ""C:\Async.cs"" ""{ff1816ec-aa5e-4d10-87f7-6f4963833460}"" ""DBEB2A067B2F0E0D678A002C587A2806056C3DCE""
using System.Threading.Tasks;
public class C
{
public async void M1()
{
}
}
";
var tree = SyntaxFactory.ParseSyntaxTree(source, encoding: Encoding.UTF8, path: "HIDDEN.cs");
var c = CSharpCompilation.Create("Compilation", new[] { tree }, new[] { MscorlibRef_v46 }, options: TestOptions.DebugDll.WithDebugPlusMode(true));
c.VerifyPdb(
@"<symbols>
<files>
<file id=""1"" name=""C:\Async.cs"" language=""3f5162f8-07c6-11d3-9053-00c04fa302a1"" languageVendor=""994b45c4-e6e9-11d2-903f-00c04fa302a1"" documentType=""5a869d0b-6611-11d3-bd2a-0000f80849bd"" checkSumAlgorithmId=""ff1816ec-aa5e-4d10-87f7-6f4963833460"" checkSum=""DB, EB, 2A, 6, 7B, 2F, E, D, 67, 8A, 0, 2C, 58, 7A, 28, 6, 5, 6C, 3D, CE, "" />
</files>
<methods>
<method containingType=""C"" name=""M1"">
<customDebugInfo>
<forwardIterator name=""&lt;M1&gt;d__0"" />
</customDebugInfo>
</method>
<method containingType=""C+&lt;M1&gt;d__0"" name=""MoveNext"">
<customDebugInfo>
<using>
<namespace usingCount=""1"" />
</using>
<encLocalSlotMap>
<slot kind=""27"" offset=""0"" />
<slot kind=""temp"" />
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" hidden=""true"" document=""1"" />
<entry offset=""0x7"" startLine=""8"" startColumn=""5"" endLine=""8"" endColumn=""6"" document=""1"" />
<entry offset=""0xa"" hidden=""true"" document=""1"" />
<entry offset=""0x22"" startLine=""9"" startColumn=""5"" endLine=""9"" endColumn=""6"" document=""1"" />
<entry offset=""0x2a"" hidden=""true"" document=""1"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x37"">
<namespace name=""System.Threading.Tasks"" />
</scope>
<asyncInfo>
<catchHandler offset=""0xa"" />
<kickoffMethod declaringType=""C"" methodName=""M1"" />
</asyncInfo>
</method>
</methods>
</symbols>
");
}
}
}
......@@ -125,6 +125,16 @@ public ImmutableArray<Cci.SequencePoint> GetSequencePoints(DebugDocumentProvider
}
ArrayBuilder<Cci.SequencePoint> result = ArrayBuilder<Cci.SequencePoint>.GetInstance(count);
FileLinePositionSpan? firstReal = FindFirstRealSequencePoint(documentProvider);
if (!firstReal.HasValue)
{
return result.ToImmutableAndFree();
}
lastPath = firstReal.Value.Path;
lastPathIsMapped = firstReal.Value.HasMappedPath;
lastDebugDocument = documentProvider(lastPath, basePath: lastPathIsMapped ? this._tree.FilePath : null);
current = this;
while (current != null)
{
......@@ -193,6 +203,34 @@ public ImmutableArray<Cci.SequencePoint> GetSequencePoints(DebugDocumentProvider
return result.ToImmutableAndFree();
}
// Find the document for the first non-hidden sequence point (issue #4370)
// Returns null if a real sequence point was found.
private FileLinePositionSpan? FindFirstRealSequencePoint(DebugDocumentProvider documentProvider)
{
SequencePointList current = this;
while (current != null)
{
foreach (var offsetAndSpan in current._points)
{
TextSpan span = offsetAndSpan.Span;
bool isHidden = span == RawSequencePoint.HiddenSequencePointSpan;
if (!isHidden)
{
FileLinePositionSpan fileLinePositionSpan = this._tree.GetMappedLineSpanAndVisibility(span, out isHidden);
if (!isHidden)
{
return fileLinePositionSpan;
}
}
}
current = current._next;
}
return null;
}
/// <summary>
/// Represents the combination of an IL offset and a source text span.
/// </summary>
......
......@@ -242,24 +242,24 @@ End Class
' Care about the fact that there's a single file element for "line.vb" and it has an absolute path.
' Care about the fact that the path that was already absolute wasn't affected by the base directory.
' Care about the fact that there is no document for b.vb
comp.VerifyPdb("C.M",
<symbols>
<files>
<file id="1" name="b:\base\b.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="ff1816ec-aa5e-4d10-87f7-6f4963833460" checkSum="F9, 90, 0, 9D, 9E, 45, 97, F2, 3D, 67, 1C, D8, 47, A8, 9B, DA, 4A, 91, AA, 7F, "/>
<file id="2" name="b:\base\line.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
<file id="3" name="q:\absolute\line.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
<file id="1" name="b:\base\line.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
<file id="2" name="q:\absolute\line.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
</files>
<methods>
<method containingType="C" name="M">
<sequencePoints>
<entry offset="0x0" hidden="true" document="1"/>
<entry offset="0x1" hidden="true" document="1"/>
<entry offset="0x8" startLine="1" startColumn="9" endLine="1" endColumn="12" document="2"/>
<entry offset="0xf" startLine="2" startColumn="9" endLine="2" endColumn="12" document="2"/>
<entry offset="0x16" startLine="3" startColumn="9" endLine="3" endColumn="12" document="2"/>
<entry offset="0x1d" startLine="4" startColumn="9" endLine="4" endColumn="12" document="2"/>
<entry offset="0x24" startLine="5" startColumn="9" endLine="5" endColumn="12" document="3"/>
<entry offset="0x2b" hidden="true" document="3"/>
<entry offset="0x8" startLine="1" startColumn="9" endLine="1" endColumn="12" document="1"/>
<entry offset="0xf" startLine="2" startColumn="9" endLine="2" endColumn="12" document="1"/>
<entry offset="0x16" startLine="3" startColumn="9" endLine="3" endColumn="12" document="1"/>
<entry offset="0x1d" startLine="4" startColumn="9" endLine="4" endColumn="12" document="1"/>
<entry offset="0x24" startLine="5" startColumn="9" endLine="5" endColumn="12" document="2"/>
<entry offset="0x2b" hidden="true" document="2"/>
</sequencePoints>
<scope startOffset="0x0" endOffset="0x2c">
<currentnamespace name=""/>
......@@ -303,27 +303,27 @@ End Class
Dim comp = CreateCompilationWithChecksums(source, "file.vb", "b:\base")
' Care about the fact that all pragmas are referenced, even though the paths differ before normalization.
' Care about the fact that there is no document reference to b:\base\file.vb
comp.VerifyPdb("C.M",
<symbols>
<files>
<file id="1" name="b:\base\file.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="ff1816ec-aa5e-4d10-87f7-6f4963833460" checkSum="C2, 46, C6, 34, F6, 20, D3, FE, 28, B9, D8, 62, F, A9, FB, 2F, 89, E7, 48, 23, "/>
<file id="2" name="b:\base\a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DA, "/>
<file id="3" name="b:\base\b.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DB, "/>
<file id="4" name="b:\base\c.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DC, "/>
<file id="5" name="b:\base\d.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DD, "/>
<file id="6" name="b:\base\e.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DE, "/>
<file id="1" name="b:\base\a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DA, "/>
<file id="2" name="b:\base\b.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DB, "/>
<file id="3" name="b:\base\c.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DC, "/>
<file id="4" name="b:\base\d.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DD, "/>
<file id="5" name="b:\base\e.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DE, "/>
</files>
<methods>
<method containingType="C" name="M">
<sequencePoints>
<entry offset="0x0" hidden="true" document="1"/>
<entry offset="0x1" hidden="true" document="1"/>
<entry offset="0x8" startLine="1" startColumn="9" endLine="1" endColumn="12" document="2"/>
<entry offset="0xf" startLine="2" startColumn="9" endLine="2" endColumn="12" document="3"/>
<entry offset="0x16" startLine="3" startColumn="9" endLine="3" endColumn="12" document="4"/>
<entry offset="0x1d" startLine="4" startColumn="9" endLine="4" endColumn="12" document="5"/>
<entry offset="0x24" startLine="5" startColumn="9" endLine="5" endColumn="12" document="6"/>
<entry offset="0x2b" hidden="true" document="6"/>
<entry offset="0x8" startLine="1" startColumn="9" endLine="1" endColumn="12" document="1"/>
<entry offset="0xf" startLine="2" startColumn="9" endLine="2" endColumn="12" document="2"/>
<entry offset="0x16" startLine="3" startColumn="9" endLine="3" endColumn="12" document="3"/>
<entry offset="0x1d" startLine="4" startColumn="9" endLine="4" endColumn="12" document="4"/>
<entry offset="0x24" startLine="5" startColumn="9" endLine="5" endColumn="12" document="5"/>
<entry offset="0x2b" hidden="true" document="5"/>
</sequencePoints>
<scope startOffset="0x0" endOffset="0x2c">
<currentnamespace name=""/>
......@@ -357,23 +357,23 @@ End Class
Dim comp = CreateCompilationWithChecksums(source, "file.vb", Nothing)
' Verify that nothing blew up.
' Care about the fact that there is no document reference to file.vb
comp.VerifyPdb("C.M",
<symbols>
<files>
<file id="1" name="file.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="ff1816ec-aa5e-4d10-87f7-6f4963833460" checkSum="23, C1, 6B, 94, B0, D4, 6, 26, C8, D2, 82, 21, 63, 7, 53, 11, 4D, 5A, 2, BC, "/>
<file id="2" name="a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DA, "/>
<file id="3" name="./a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
<file id="4" name="b.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
<file id="1" name="a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="406ea660-64cf-4c82-b6f0-42d48172a79a" checkSum="AB, 0, 7F, 1D, 23, DA, "/>
<file id="2" name="./a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
<file id="3" name="b.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd"/>
</files>
<methods>
<method containingType="C" name="M">
<sequencePoints>
<entry offset="0x0" hidden="true" document="1"/>
<entry offset="0x1" hidden="true" document="1"/>
<entry offset="0x8" startLine="1" startColumn="9" endLine="1" endColumn="12" document="2"/>
<entry offset="0xf" startLine="2" startColumn="9" endLine="2" endColumn="12" document="3"/>
<entry offset="0x16" startLine="3" startColumn="9" endLine="3" endColumn="12" document="4"/>
<entry offset="0x1d" hidden="true" document="4"/>
<entry offset="0x8" startLine="1" startColumn="9" endLine="1" endColumn="12" document="1"/>
<entry offset="0xf" startLine="2" startColumn="9" endLine="2" endColumn="12" document="2"/>
<entry offset="0x16" startLine="3" startColumn="9" endLine="3" endColumn="12" document="3"/>
<entry offset="0x1d" hidden="true" document="3"/>
</sequencePoints>
<scope startOffset="0x0" endOffset="0x1e">
<currentnamespace name=""/>
......
......@@ -133,7 +133,7 @@ public static class PdbValidation
// remove scopes that only contained non-portable elements (namespace scopes)
RemoveEmptyScopes(expectedPdb);
RemoveMethodsWithNoSequencePoints(expectedPdb);
RemoveEmptyMethods(expectedPdb);
}
......@@ -141,6 +141,21 @@ public static class PdbValidation
}
}
private static void RemoveMethodsWithNoSequencePoints(XElement pdb)
{
var methods = (from e in pdb.DescendantsAndSelf()
where e.Name == "method"
select e).ToArray();
foreach(var method in methods)
{
bool hasNoSequencePoints = method.DescendantsAndSelf().Where(node => node.Name == "entry").IsEmpty();
if (hasNoSequencePoints)
{
method.Remove();
}
}
}
private static void RemoveEmptyScopes(XElement pdb)
{
XElement[] emptyScopes;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册