-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Enc pdb tests #18883
Enc pdb tests #18883
Changes from 2 commits
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 |
---|---|---|
|
@@ -23,6 +23,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.PDB | |
{ | ||
public class PDBTests : CSharpPDBTestBase | ||
{ | ||
private static readonly MetadataReference[] s_valueTupleRefs = new[] { SystemRuntimeFacadeRef, ValueTupleRef }; | ||
|
||
#region General | ||
|
||
[Fact] | ||
|
@@ -5765,6 +5767,197 @@ static void M() | |
|
||
#endregion | ||
|
||
#region Patterns | ||
|
||
public void SyntaxOffset_Parrern() | ||
{ | ||
var source = @"class C { int F(object o) { if (o is 33) { return 44; } if (o is int i) { return i; } if (o is bool) { return 1; } return 0; }}"; | ||
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.
nit: It'd be better to move the pattern declaring the variable to the beginning of the body, so that it's easier to see that the offset is correct. 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. You can also simplify the code like so:
In reply to: 113005390 [](ancestors = 113005390) 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. OK. Thanks! |
||
var c = CreateCompilationWithMscorlibAndSystemCore(source, options: TestOptions.DebugDll); | ||
c.VerifyPdb("C.F", @"<symbols> | ||
<methods> | ||
<method containingType=""C"" name=""F"" parameterNames=""o""> | ||
<customDebugInfo> | ||
<using> | ||
<namespace usingCount=""0"" /> | ||
</using> | ||
<encLocalSlotMap> | ||
<slot kind=""0"" offset=""44"" /> | ||
<slot kind=""1"" offset=""2"" /> | ||
<slot kind=""21"" offset=""0"" /> | ||
<slot kind=""1"" offset=""31"" /> | ||
<slot kind=""temp"" /> | ||
<slot kind=""1"" offset=""61"" /> | ||
</encLocalSlotMap> | ||
</customDebugInfo> | ||
<sequencePoints> | ||
<entry offset=""0x0"" startLine=""1"" startColumn=""27"" endLine=""1"" endColumn=""28"" /> | ||
<entry offset=""0x1"" startLine=""1"" startColumn=""29"" endLine=""1"" endColumn=""41"" /> | ||
<entry offset=""0xf"" hidden=""true"" /> | ||
<entry offset=""0x12"" startLine=""1"" startColumn=""42"" endLine=""1"" endColumn=""43"" /> | ||
<entry offset=""0x13"" startLine=""1"" startColumn=""44"" endLine=""1"" endColumn=""54"" /> | ||
<entry offset=""0x18"" startLine=""1"" startColumn=""58"" endLine=""1"" endColumn=""73"" /> | ||
<entry offset=""0x35"" hidden=""true"" /> | ||
<entry offset=""0x38"" startLine=""1"" startColumn=""74"" endLine=""1"" endColumn=""75"" /> | ||
<entry offset=""0x39"" startLine=""1"" startColumn=""76"" endLine=""1"" endColumn=""85"" /> | ||
<entry offset=""0x3d"" startLine=""1"" startColumn=""88"" endLine=""1"" endColumn=""102"" /> | ||
<entry offset=""0x48"" hidden=""true"" /> | ||
<entry offset=""0x4c"" startLine=""1"" startColumn=""103"" endLine=""1"" endColumn=""104"" /> | ||
<entry offset=""0x4d"" startLine=""1"" startColumn=""105"" endLine=""1"" endColumn=""114"" /> | ||
<entry offset=""0x51"" startLine=""1"" startColumn=""117"" endLine=""1"" endColumn=""126"" /> | ||
<entry offset=""0x55"" startLine=""1"" startColumn=""127"" endLine=""1"" endColumn=""128"" /> | ||
</sequencePoints> | ||
<scope startOffset=""0x0"" endOffset=""0x57""> | ||
<local name=""i"" il_index=""0"" il_start=""0x0"" il_end=""0x57"" attributes=""0"" /> | ||
</scope> | ||
</method> | ||
</methods> | ||
</symbols>"); | ||
} | ||
|
||
#endregion | ||
|
||
#region Tuples | ||
|
||
[Fact] | ||
public void SyntaxOffset_TupleDeconstruction() | ||
{ | ||
var source = @"class C { int F() { (int a, (int b, int c)) = (1, (2, 3)); return a + b + c; } }"; | ||
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.
Perhaps replace 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. OK. Let us try. Thanks! |
||
var c = CreateCompilationWithMscorlibAndSystemCore(source, options: TestOptions.DebugDll, references: s_valueTupleRefs); | ||
|
||
c.VerifyPdb("C.F", @"<symbols> | ||
<methods> | ||
<method containingType=""C"" name=""F""> | ||
<customDebugInfo> | ||
<using> | ||
<namespace usingCount=""0"" /> | ||
</using> | ||
<encLocalSlotMap> | ||
<slot kind=""0"" offset=""7"" /> | ||
<slot kind=""0"" offset=""15"" /> | ||
<slot kind=""0"" offset=""22"" /> | ||
<slot kind=""21"" offset=""0"" /> | ||
</encLocalSlotMap> | ||
</customDebugInfo> | ||
<sequencePoints> | ||
<entry offset=""0x0"" startLine=""1"" startColumn=""19"" endLine=""1"" endColumn=""20"" /> | ||
<entry offset=""0x1"" startLine=""1"" startColumn=""21"" endLine=""1"" endColumn=""59"" /> | ||
<entry offset=""0x7"" startLine=""1"" startColumn=""60"" endLine=""1"" endColumn=""77"" /> | ||
<entry offset=""0xf"" startLine=""1"" startColumn=""78"" endLine=""1"" endColumn=""79"" /> | ||
</sequencePoints> | ||
<scope startOffset=""0x0"" endOffset=""0x11""> | ||
<local name=""a"" il_index=""0"" il_start=""0x0"" il_end=""0x11"" attributes=""0"" /> | ||
<local name=""b"" il_index=""1"" il_start=""0x0"" il_end=""0x11"" attributes=""0"" /> | ||
<local name=""c"" il_index=""2"" il_start=""0x0"" il_end=""0x11"" attributes=""0"" /> | ||
</scope> | ||
</method> | ||
</methods> | ||
</symbols>"); | ||
} | ||
|
||
[Fact] | ||
public void SyntaxOffset_TupleParenthesized() | ||
{ | ||
var source = @"class C { int F() { (int, (int, int)) x = (1, (2, 3)); return x.Item1 + x.Item2.Item1 + x.Item2.Item2; } }"; | ||
var c = CreateCompilationWithMscorlibAndSystemCore(source, options: TestOptions.DebugDll, references: s_valueTupleRefs); | ||
|
||
c.VerifyPdb("C.F", @"<symbols> | ||
<methods> | ||
<method containingType=""C"" name=""F""> | ||
<customDebugInfo> | ||
<using> | ||
<namespace usingCount=""0"" /> | ||
</using> | ||
<encLocalSlotMap> | ||
<slot kind=""0"" offset=""20"" /> | ||
<slot kind=""21"" offset=""0"" /> | ||
</encLocalSlotMap> | ||
</customDebugInfo> | ||
<sequencePoints> | ||
<entry offset=""0x0"" startLine=""1"" startColumn=""19"" endLine=""1"" endColumn=""20"" /> | ||
<entry offset=""0x1"" startLine=""1"" startColumn=""21"" endLine=""1"" endColumn=""55"" /> | ||
<entry offset=""0x10"" startLine=""1"" startColumn=""56"" endLine=""1"" endColumn=""103"" /> | ||
<entry offset=""0x31"" startLine=""1"" startColumn=""104"" endLine=""1"" endColumn=""105"" /> | ||
</sequencePoints> | ||
<scope startOffset=""0x0"" endOffset=""0x33""> | ||
<local name=""x"" il_index=""0"" il_start=""0x0"" il_end=""0x33"" attributes=""0"" /> | ||
</scope> | ||
</method> | ||
</methods> | ||
</symbols>" | ||
); | ||
} | ||
|
||
[Fact] | ||
public void SyntaxOffset_TupleVarDefined() | ||
{ | ||
var source = @"class C { int F() { var x = (1, 2); ; return x.Item1 + x.Item2; } }"; | ||
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.
nit: extra 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. Thanks! |
||
var c = CreateCompilationWithMscorlibAndSystemCore(source, options: TestOptions.DebugDll, references: s_valueTupleRefs); | ||
|
||
c.VerifyPdb("C.F", @"<symbols> | ||
<methods> | ||
<method containingType=""C"" name=""F""> | ||
<customDebugInfo> | ||
<using> | ||
<namespace usingCount=""0"" /> | ||
</using> | ||
<encLocalSlotMap> | ||
<slot kind=""0"" offset=""6"" /> | ||
<slot kind=""21"" offset=""0"" /> | ||
</encLocalSlotMap> | ||
</customDebugInfo> | ||
<sequencePoints> | ||
<entry offset=""0x0"" startLine=""1"" startColumn=""19"" endLine=""1"" endColumn=""20"" /> | ||
<entry offset=""0x1"" startLine=""1"" startColumn=""21"" endLine=""1"" endColumn=""36"" /> | ||
<entry offset=""0xa"" startLine=""1"" startColumn=""37"" endLine=""1"" endColumn=""38"" /> | ||
<entry offset=""0xb"" startLine=""1"" startColumn=""39"" endLine=""1"" endColumn=""64"" /> | ||
<entry offset=""0x1b"" startLine=""1"" startColumn=""65"" endLine=""1"" endColumn=""66"" /> | ||
</sequencePoints> | ||
<scope startOffset=""0x0"" endOffset=""0x1d""> | ||
<local name=""x"" il_index=""0"" il_start=""0x0"" il_end=""0x1d"" attributes=""0"" /> | ||
</scope> | ||
</method> | ||
</methods> | ||
</symbols>"); | ||
} | ||
|
||
[Fact] | ||
public void SyntaxOffset_TupleIgnoreDeconstructionIfVariableDeclared() | ||
{ | ||
var source = @"class C { int F() { (int x, int y) a = (1, 2); ; return a.Item1 + a.Item2; } }"; | ||
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.
nit: extra 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. Thanks! |
||
var c = CreateCompilationWithMscorlibAndSystemCore(source, options: TestOptions.DebugDll, references: s_valueTupleRefs); | ||
|
||
c.VerifyPdb("C.F", @"<symbols> | ||
<methods> | ||
<method containingType=""C"" name=""F""> | ||
<customDebugInfo> | ||
<using> | ||
<namespace usingCount=""0"" /> | ||
</using> | ||
<tupleElementNames> | ||
<local elementNames=""|x|y"" slotIndex=""0"" localName=""a"" scopeStart=""0x0"" scopeEnd=""0x0"" /> | ||
</tupleElementNames> | ||
<encLocalSlotMap> | ||
<slot kind=""0"" offset=""17"" /> | ||
<slot kind=""21"" offset=""0"" /> | ||
</encLocalSlotMap> | ||
</customDebugInfo> | ||
<sequencePoints> | ||
<entry offset=""0x0"" startLine=""1"" startColumn=""19"" endLine=""1"" endColumn=""20"" /> | ||
<entry offset=""0x1"" startLine=""1"" startColumn=""21"" endLine=""1"" endColumn=""47"" /> | ||
<entry offset=""0x9"" startLine=""1"" startColumn=""48"" endLine=""1"" endColumn=""49"" /> | ||
<entry offset=""0xa"" startLine=""1"" startColumn=""50"" endLine=""1"" endColumn=""75"" /> | ||
<entry offset=""0x1a"" startLine=""1"" startColumn=""76"" endLine=""1"" endColumn=""77"" /> | ||
</sequencePoints> | ||
<scope startOffset=""0x0"" endOffset=""0x1c""> | ||
<local name=""a"" il_index=""0"" il_start=""0x0"" il_end=""0x1c"" attributes=""0"" /> | ||
</scope> | ||
</method> | ||
</methods> | ||
</symbols>"); | ||
} | ||
|
||
#endregion | ||
|
||
[Fact, WorkItem(4370, "https://github.com/dotnet/roslyn/issues/4370")] | ||
public void HeadingHiddenSequencePointsPickUpDocumentFromVisibleSequencePoint() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed