Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bd0d7b7d
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd0d7b7d
编写于
9月 07, 2017
作者:
I
Ivan Basov
提交者:
GitHub
9月 07, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CSharpSymbolMatcher update and PDB tests to support local functions
上级
7b1d0159
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
1252 addition
and
59 deletion
+1252
-59
src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs
...p/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs
+5
-5
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs
.../Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs
+655
-54
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/SymbolMatcherTests.cs
...harp/Test/Emit/Emit/EditAndContinue/SymbolMatcherTests.cs
+45
-0
src/Compilers/CSharp/Test/Emit/PDB/PDBLocalFunctionTests.cs
src/Compilers/CSharp/Test/Emit/PDB/PDBLocalFunctionTests.cs
+450
-0
src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
+97
-0
未找到文件。
src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs
浏览文件 @
bd0d7b7d
...
@@ -652,12 +652,12 @@ private Symbol VisitNamedTypeMember<T>(T member, Func<T, T, bool> predicate)
...
@@ -652,12 +652,12 @@ private Symbol VisitNamedTypeMember<T>(T member, Func<T, T, bool> predicate)
private
T
FindMatchingNamedTypeMember
<
T
>(
NamedTypeSymbol
otherType
,
T
sourceMember
,
Func
<
T
,
T
,
bool
>
predicate
)
private
T
FindMatchingNamedTypeMember
<
T
>(
NamedTypeSymbol
otherType
,
T
sourceMember
,
Func
<
T
,
T
,
bool
>
predicate
)
where
T
:
Symbol
where
T
:
Symbol
{
{
Debug
.
Assert
(!
string
.
IsNullOrEmpty
(
sourceMember
.
Name
));
Debug
.
Assert
(!
string
.
IsNullOrEmpty
(
sourceMember
.
Metadata
Name
));
var
otherMembersByName
=
_otherTypeMembers
.
GetOrAdd
(
otherType
,
GetOtherTypeMembers
);
var
otherMembersByName
=
_otherTypeMembers
.
GetOrAdd
(
otherType
,
GetOtherTypeMembers
);
ImmutableArray
<
Cci
.
ITypeDefinitionMember
>
otherMembers
;
ImmutableArray
<
Cci
.
ITypeDefinitionMember
>
otherMembers
;
if
(
otherMembersByName
.
TryGetValue
(
sourceMember
.
Name
,
out
otherMembers
))
if
(
otherMembersByName
.
TryGetValue
(
sourceMember
.
Metadata
Name
,
out
otherMembers
))
{
{
foreach
(
var
otherMember
in
otherMembers
)
foreach
(
var
otherMember
in
otherMembers
)
{
{
...
@@ -741,7 +741,7 @@ private bool AreNamedTypesEqual(NamedTypeSymbol type, NamedTypeSymbol other)
...
@@ -741,7 +741,7 @@ private bool AreNamedTypesEqual(NamedTypeSymbol type, NamedTypeSymbol other)
private
bool
AreParametersEqual
(
ParameterSymbol
parameter
,
ParameterSymbol
other
)
private
bool
AreParametersEqual
(
ParameterSymbol
parameter
,
ParameterSymbol
other
)
{
{
Debug
.
Assert
(
parameter
.
Ordinal
==
other
.
Ordinal
);
Debug
.
Assert
(
parameter
.
Ordinal
==
other
.
Ordinal
);
return
StringOrdinalComparer
.
Equals
(
parameter
.
Name
,
other
.
Name
)
&&
return
StringOrdinalComparer
.
Equals
(
parameter
.
MetadataName
,
other
.
Metadata
Name
)
&&
(
parameter
.
RefKind
==
other
.
RefKind
)
&&
(
parameter
.
RefKind
==
other
.
RefKind
)
&&
_comparer
.
Equals
(
parameter
.
Type
,
other
.
Type
);
_comparer
.
Equals
(
parameter
.
Type
,
other
.
Type
);
}
}
...
@@ -757,7 +757,7 @@ private bool ArePointerTypesEqual(PointerTypeSymbol type, PointerTypeSymbol othe
...
@@ -757,7 +757,7 @@ private bool ArePointerTypesEqual(PointerTypeSymbol type, PointerTypeSymbol othe
private
bool
ArePropertiesEqual
(
PropertySymbol
property
,
PropertySymbol
other
)
private
bool
ArePropertiesEqual
(
PropertySymbol
property
,
PropertySymbol
other
)
{
{
Debug
.
Assert
(
StringOrdinalComparer
.
Equals
(
property
.
Name
,
other
.
Name
));
Debug
.
Assert
(
StringOrdinalComparer
.
Equals
(
property
.
MetadataName
,
other
.
Metadata
Name
));
return
_comparer
.
Equals
(
property
.
Type
,
other
.
Type
)
&&
return
_comparer
.
Equals
(
property
.
Type
,
other
.
Type
)
&&
property
.
RefKind
.
Equals
(
other
.
RefKind
)
&&
property
.
RefKind
.
Equals
(
other
.
RefKind
)
&&
property
.
Parameters
.
SequenceEqual
(
other
.
Parameters
,
AreParametersEqual
);
property
.
Parameters
.
SequenceEqual
(
other
.
Parameters
,
AreParametersEqual
);
...
@@ -820,7 +820,7 @@ private bool AreTypesEqual(TypeSymbol type, TypeSymbol other)
...
@@ -820,7 +820,7 @@ private bool AreTypesEqual(TypeSymbol type, TypeSymbol other)
members
.
AddRange
(
synthesizedMembers
);
members
.
AddRange
(
synthesizedMembers
);
}
}
var
result
=
members
.
ToDictionary
(
s
=>
((
Symbol
)
s
).
Name
,
StringOrdinalComparer
.
Instance
);
var
result
=
members
.
ToDictionary
(
s
=>
((
Symbol
)
s
).
Metadata
Name
,
StringOrdinalComparer
.
Instance
);
members
.
Free
();
members
.
Free
();
return
result
;
return
result
;
}
}
...
...
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs
浏览文件 @
bd0d7b7d
此差异已折叠。
点击以展开。
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/SymbolMatcherTests.cs
浏览文件 @
bd0d7b7d
...
@@ -945,5 +945,50 @@ struct S
...
@@ -945,5 +945,50 @@ struct S
// If a type changes, we do not expect types to match.
// If a type changes, we do not expect types to match.
Assert
.
Null
(
other
);
Assert
.
Null
(
other
);
}
}
[
Fact
]
public
void
Property_CompilationVsPE
()
{
var
source
=
@"
using System;
interface I<T, S>
{
int this[int index] { set; }
}
class C : I<int, bool>
{
int _current;
int I<int, bool>.this[int anotherIndex]
{
set { _current = anotherIndex + value; }
}
}"
;
var
compilation0
=
CreateStandardCompilation
(
source
,
options
:
TestOptions
.
DebugDll
);
var
peRef0
=
compilation0
.
EmitToImageReference
();
var
peAssemblySymbol0
=
(
PEAssemblySymbol
)
CreateStandardCompilation
(
""
,
new
[]
{
peRef0
}).
GetReferencedAssemblySymbol
(
peRef0
);
var
compilation1
=
CreateStandardCompilation
(
source
,
options
:
TestOptions
.
DebugDll
);
var
testData
=
new
CompilationTestData
();
compilation1
.
EmitToArray
(
testData
:
testData
);
var
peAssemblyBuilder
=
(
PEAssemblyBuilder
)
testData
.
Module
;
var
c
=
compilation1
.
GetMember
<
NamedTypeSymbol
>(
"C"
);
var
property
=
c
.
GetMember
<
PropertySymbol
>(
"I<System.Int32,System.Boolean>.this[]"
);
var
parameters
=
property
.
GetParameters
().
ToArray
();
Assert
.
Equal
(
1
,
parameters
.
Length
);
Assert
.
Equal
(
"anotherIndex"
,
parameters
[
0
].
Name
);
var
emitContext
=
new
EmitContext
(
peAssemblyBuilder
,
null
,
new
DiagnosticBag
(),
metadataOnly
:
false
,
includePrivateMembers
:
true
);
var
matcher
=
new
CSharpSymbolMatcher
(
null
,
compilation1
.
SourceAssembly
,
emitContext
,
peAssemblySymbol0
);
var
mappedProperty
=
(
Cci
.
IPropertyDefinition
)
matcher
.
MapDefinition
(
property
);
Assert
.
Equal
(
"I<System.Int32,System.Boolean>.Item"
,
((
PropertySymbol
)
mappedProperty
).
MetadataName
);
}
}
}
}
}
src/Compilers/CSharp/Test/Emit/PDB/PDBLocalFunctionTests.cs
0 → 100644
浏览文件 @
bd0d7b7d
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests.PDB
{
public
class
PDBLocalFunctionTests
:
CSharpPDBTestBase
{
[
Fact
]
public
void
ClosuresInCtor
()
{
var
source
=
@"
using System;
class B
{
public B(Func<int> f) { }
}
class C : B
{
int r;
public C(int a, int b) : base(() => a)
{
int c = 1;
int f() => b;
int g() => f();
int h() => c;
r = g() + h();
}
}
"
;
var
c
=
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyDiagnostics
();
c
.
VerifyPdb
(
@"
<symbols>
<methods>
<method containingType=""B"" name="".ctor"" parameterNames=""f"">
<customDebugInfo>
<using>
<namespace usingCount=""1"" />
</using>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""6"" startColumn=""5"" endLine=""6"" endColumn=""26"" />
<entry offset=""0x7"" startLine=""6"" startColumn=""27"" endLine=""6"" endColumn=""28"" />
<entry offset=""0x8"" startLine=""6"" startColumn=""29"" endLine=""6"" endColumn=""30"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x9"">
<namespace name=""System"" />
</scope>
</method>
<method containingType=""C"" name="".ctor"" parameterNames=""a, b"">
<customDebugInfo>
<forward declaringType=""B"" methodName="".ctor"" parameterNames=""f"" />
<encLocalSlotMap>
<slot kind=""30"" offset=""-1"" />
<slot kind=""30"" offset=""0"" />
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<closure offset=""-1"" />
<closure offset=""0"" />
<lambda offset=""-2"" closure=""0"" />
<lambda offset=""42"" closure=""0"" />
<lambda offset=""65"" closure=""0"" />
<lambda offset=""90"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" hidden=""true"" />
<entry offset=""0x14"" startLine=""13"" startColumn=""30"" endLine=""13"" endColumn=""43"" />
<entry offset=""0x27"" startLine=""14"" startColumn=""5"" endLine=""14"" endColumn=""6"" />
<entry offset=""0x28"" startLine=""15"" startColumn=""9"" endLine=""15"" endColumn=""19"" />
<entry offset=""0x33"" startLine=""19"" startColumn=""9"" endLine=""19"" endColumn=""23"" />
<entry offset=""0x47"" startLine=""20"" startColumn=""5"" endLine=""20"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x48"">
<local name=""CS$<>8__locals0"" il_index=""0"" il_start=""0x0"" il_end=""0x48"" attributes=""0"" />
<scope startOffset=""0x27"" endOffset=""0x48"">
<local name=""CS$<>8__locals1"" il_index=""1"" il_start=""0x27"" il_end=""0x48"" attributes=""0"" />
</scope>
</scope>
</method>
<method containingType=""C"" name=""<.ctor>g__h|1_3"">
<customDebugInfo>
<forward declaringType=""B"" methodName="".ctor"" parameterNames=""f"" />
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""18"" startColumn=""20"" endLine=""18"" endColumn=""21"" />
</sequencePoints>
</method>
<method containingType=""C+<>c__DisplayClass1_0"" name=""<.ctor>b__0"">
<customDebugInfo>
<forward declaringType=""B"" methodName="".ctor"" parameterNames=""f"" />
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""13"" startColumn=""41"" endLine=""13"" endColumn=""42"" />
</sequencePoints>
</method>
<method containingType=""C+<>c__DisplayClass1_0"" name=""<.ctor>g__f|1"">
<customDebugInfo>
<forward declaringType=""B"" methodName="".ctor"" parameterNames=""f"" />
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""16"" startColumn=""20"" endLine=""16"" endColumn=""21"" />
</sequencePoints>
</method>
<method containingType=""C+<>c__DisplayClass1_0"" name=""<.ctor>g__g|2"">
<customDebugInfo>
<forward declaringType=""B"" methodName="".ctor"" parameterNames=""f"" />
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""17"" startColumn=""20"" endLine=""17"" endColumn=""23"" />
</sequencePoints>
</method>
</methods>
</symbols>"
);
}
[
Fact
]
public
void
ForEachStatement_Array
()
{
string
source
=
@"
using System;
class C
{
void G(Func<int, int> f) {}
void F()
{
foreach (int x0 in new[] { 1 }) // Group #0
{ // Group #1
int x1 = 0;
int f0(int a) => x0;
int f1(int a) => x1;
G(f0);
G(f1);
}
}
}"
;
var
c
=
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyDiagnostics
();
// note that the two closures have a different syntax offset
c
.
VerifyPdb
(
"C.F"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""F"">
<customDebugInfo>
<forward declaringType=""C"" methodName=""G"" parameterNames=""f"" />
<encLocalSlotMap>
<slot kind=""6"" offset=""41"" />
<slot kind=""8"" offset=""41"" />
<slot kind=""30"" offset=""41"" />
<slot kind=""30"" offset=""108"" />
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<closure offset=""41"" />
<closure offset=""108"" />
<lambda offset=""226"" closure=""0"" />
<lambda offset=""260"" closure=""1"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""9"" startColumn=""5"" endLine=""9"" endColumn=""6"" />
<entry offset=""0x1"" startLine=""10"" startColumn=""9"" endLine=""10"" endColumn=""16"" />
<entry offset=""0x2"" startLine=""10"" startColumn=""28"" endLine=""10"" endColumn=""39"" />
<entry offset=""0xf"" hidden=""true"" />
<entry offset=""0x11"" hidden=""true"" />
<entry offset=""0x17"" startLine=""10"" startColumn=""18"" endLine=""10"" endColumn=""24"" />
<entry offset=""0x20"" hidden=""true"" />
<entry offset=""0x26"" startLine=""11"" startColumn=""9"" endLine=""11"" endColumn=""10"" />
<entry offset=""0x27"" startLine=""12"" startColumn=""13"" endLine=""12"" endColumn=""24"" />
<entry offset=""0x30"" startLine=""15"" startColumn=""13"" endLine=""15"" endColumn=""19"" />
<entry offset=""0x43"" startLine=""16"" startColumn=""13"" endLine=""16"" endColumn=""19"" />
<entry offset=""0x56"" startLine=""17"" startColumn=""9"" endLine=""17"" endColumn=""10"" />
<entry offset=""0x57"" hidden=""true"" />
<entry offset=""0x5b"" startLine=""10"" startColumn=""25"" endLine=""10"" endColumn=""27"" />
<entry offset=""0x61"" startLine=""18"" startColumn=""5"" endLine=""18"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x62"">
<scope startOffset=""0x11"" endOffset=""0x57"">
<local name=""CS$<>8__locals0"" il_index=""2"" il_start=""0x11"" il_end=""0x57"" attributes=""0"" />
<scope startOffset=""0x20"" endOffset=""0x57"">
<local name=""CS$<>8__locals1"" il_index=""3"" il_start=""0x20"" il_end=""0x57"" attributes=""0"" />
</scope>
</scope>
</scope>
</method>
</methods>
</symbols>
"
);
}
[
Fact
]
public
void
ForStatement1
()
{
string
source
=
@"
using System;
class C
{
bool G(Func<int, int> f) => true;
void F()
{
for (int x0 = 0, x1 = 0; G(a => x0) && G(a => x1);)
{
int x2 = 0;
int f(int a) => x2;
G(f);
}
}
}"
;
var
c
=
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyDiagnostics
();
// note that the two closures have a different syntax offset
c
.
VerifyPdb
(
"C.F"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""F"">
<customDebugInfo>
<forward declaringType=""C"" methodName=""G"" parameterNames=""f"" />
<encLocalSlotMap>
<slot kind=""30"" offset=""41"" />
<slot kind=""30"" offset=""102"" />
<slot kind=""1"" offset=""41"" />
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<closure offset=""41"" />
<closure offset=""102"" />
<lambda offset=""158"" closure=""1"" />
<lambda offset=""73"" closure=""0"" />
<lambda offset=""87"" closure=""0"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""9"" startColumn=""5"" endLine=""9"" endColumn=""6"" />
<entry offset=""0x1"" hidden=""true"" />
<entry offset=""0x7"" startLine=""10"" startColumn=""14"" endLine=""10"" endColumn=""24"" />
<entry offset=""0xe"" startLine=""10"" startColumn=""26"" endLine=""10"" endColumn=""32"" />
<entry offset=""0x15"" hidden=""true"" />
<entry offset=""0x17"" hidden=""true"" />
<entry offset=""0x1d"" startLine=""11"" startColumn=""9"" endLine=""11"" endColumn=""10"" />
<entry offset=""0x1e"" startLine=""12"" startColumn=""13"" endLine=""12"" endColumn=""24"" />
<entry offset=""0x26"" startLine=""14"" startColumn=""13"" endLine=""14"" endColumn=""18"" />
<entry offset=""0x39"" startLine=""15"" startColumn=""9"" endLine=""15"" endColumn=""10"" />
<entry offset=""0x3a"" startLine=""10"" startColumn=""34"" endLine=""10"" endColumn=""58"" />
<entry offset=""0x64"" hidden=""true"" />
<entry offset=""0x67"" startLine=""16"" startColumn=""5"" endLine=""16"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x68"">
<scope startOffset=""0x1"" endOffset=""0x67"">
<local name=""CS$<>8__locals0"" il_index=""0"" il_start=""0x1"" il_end=""0x67"" attributes=""0"" />
<scope startOffset=""0x17"" endOffset=""0x3a"">
<local name=""CS$<>8__locals1"" il_index=""1"" il_start=""0x17"" il_end=""0x3a"" attributes=""0"" />
</scope>
</scope>
</scope>
</method>
</methods>
</symbols>
"
);
}
[
Fact
]
public
void
SwitchStatement1
()
{
var
source
=
@"
using System;
class C
{
bool G(Func<int> f) => true;
int a = 1;
void F()
{
int x2 = 1;
int f2() => x2;
G(f2);
switch (a)
{
case 1:
int x0 = 1;
int f0() => x0;
G(f0);
break;
case 2:
int x1 = 1;
int f1() => x1;
G(f1);
break;
}
}
}
"
;
var
c
=
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyDiagnostics
();
c
.
VerifyPdb
(
"C.F"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""F"">
<customDebugInfo>
<forward declaringType=""C"" methodName=""G"" parameterNames=""f"" />
<encLocalSlotMap>
<slot kind=""30"" offset=""0"" />
<slot kind=""30"" offset=""105"" />
<slot kind=""1"" offset=""105"" />
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>2</methodOrdinal>
<closure offset=""0"" />
<closure offset=""105"" />
<lambda offset=""52"" closure=""0"" />
<lambda offset=""206"" closure=""1"" />
<lambda offset=""339"" closure=""1"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" hidden=""true"" />
<entry offset=""0x6"" startLine=""11"" startColumn=""5"" endLine=""11"" endColumn=""6"" />
<entry offset=""0x7"" startLine=""12"" startColumn=""9"" endLine=""12"" endColumn=""20"" />
<entry offset=""0xf"" startLine=""14"" startColumn=""9"" endLine=""14"" endColumn=""15"" />
<entry offset=""0x22"" startLine=""16"" startColumn=""9"" endLine=""16"" endColumn=""19"" />
<entry offset=""0x2f"" hidden=""true"" />
<entry offset=""0x3b"" startLine=""19"" startColumn=""17"" endLine=""19"" endColumn=""28"" />
<entry offset=""0x43"" startLine=""21"" startColumn=""17"" endLine=""21"" endColumn=""23"" />
<entry offset=""0x56"" startLine=""22"" startColumn=""17"" endLine=""22"" endColumn=""23"" />
<entry offset=""0x58"" startLine=""25"" startColumn=""17"" endLine=""25"" endColumn=""28"" />
<entry offset=""0x60"" startLine=""27"" startColumn=""17"" endLine=""27"" endColumn=""23"" />
<entry offset=""0x73"" startLine=""28"" startColumn=""17"" endLine=""28"" endColumn=""23"" />
<entry offset=""0x75"" startLine=""30"" startColumn=""5"" endLine=""30"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x76"">
<local name=""CS$<>8__locals0"" il_index=""0"" il_start=""0x0"" il_end=""0x76"" attributes=""0"" />
<scope startOffset=""0x22"" endOffset=""0x75"">
<local name=""CS$<>8__locals1"" il_index=""1"" il_start=""0x22"" il_end=""0x75"" attributes=""0"" />
</scope>
</scope>
</method>
</methods>
</symbols>
"
);
}
[
Fact
]
public
void
UsingStatement1
()
{
string
source
=
@"
using System;
class C
{
static bool G<T>(Func<T> f) => true;
static int F(object a, object b) => 1;
static IDisposable D() => null;
static void F()
{
using (IDisposable x0 = D(), y0 = D())
{
int x1 = 1;
object f0() => x0;
object f1() => x1;
object g0() => y0;
G(f0);
G(g0);
G(f1);
}
}
}"
;
var
c
=
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyDiagnostics
();
// note that the two closures have a different syntax offset
c
.
VerifyPdb
(
"C.F"
,
@"
<symbols>
<methods>
<method containingType=""C"" name=""F"" parameterNames=""a, b"">
<customDebugInfo>
<forward declaringType=""C"" methodName=""G"" parameterNames=""f"" />
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""7"" startColumn=""41"" endLine=""7"" endColumn=""42"" />
</sequencePoints>
</method>
<method containingType=""C"" name=""F"">
<customDebugInfo>
<forward declaringType=""C"" methodName=""G"" parameterNames=""f"" />
<encLocalSlotMap>
<slot kind=""30"" offset=""41"" />
<slot kind=""30"" offset=""89"" />
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>3</methodOrdinal>
<closure offset=""41"" />
<closure offset=""89"" />
<lambda offset=""154"" closure=""0"" />
<lambda offset=""186"" closure=""1"" />
<lambda offset=""218"" closure=""0"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""11"" startColumn=""5"" endLine=""11"" endColumn=""6"" />
<entry offset=""0x1"" hidden=""true"" />
<entry offset=""0x7"" startLine=""12"" startColumn=""16"" endLine=""12"" endColumn=""36"" />
<entry offset=""0x12"" startLine=""12"" startColumn=""38"" endLine=""12"" endColumn=""46"" />
<entry offset=""0x1d"" hidden=""true"" />
<entry offset=""0x23"" startLine=""13"" startColumn=""9"" endLine=""13"" endColumn=""10"" />
<entry offset=""0x24"" startLine=""14"" startColumn=""13"" endLine=""14"" endColumn=""24"" />
<entry offset=""0x2e"" startLine=""19"" startColumn=""13"" endLine=""19"" endColumn=""19"" />
<entry offset=""0x40"" startLine=""20"" startColumn=""13"" endLine=""20"" endColumn=""19"" />
<entry offset=""0x52"" startLine=""21"" startColumn=""13"" endLine=""21"" endColumn=""19"" />
<entry offset=""0x64"" startLine=""22"" startColumn=""9"" endLine=""22"" endColumn=""10"" />
<entry offset=""0x67"" hidden=""true"" />
<entry offset=""0x7b"" hidden=""true"" />
<entry offset=""0x7c"" hidden=""true"" />
<entry offset=""0x7e"" hidden=""true"" />
<entry offset=""0x92"" hidden=""true"" />
<entry offset=""0x93"" startLine=""23"" startColumn=""5"" endLine=""23"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x94"">
<scope startOffset=""0x1"" endOffset=""0x93"">
<local name=""CS$<>8__locals0"" il_index=""0"" il_start=""0x1"" il_end=""0x93"" attributes=""0"" />
<scope startOffset=""0x1d"" endOffset=""0x65"">
<local name=""CS$<>8__locals1"" il_index=""1"" il_start=""0x1d"" il_end=""0x65"" attributes=""0"" />
</scope>
</scope>
</scope>
</method>
</methods>
</symbols>
"
);
}
}
}
src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
浏览文件 @
bd0d7b7d
...
@@ -3079,6 +3079,103 @@ class Student : Person { public double GPA; }
...
@@ -3079,6 +3079,103 @@ class Student : Person { public double GPA; }
</symbols>"
);
</symbols>"
);
}
}
[
Fact
]
public
void
SwitchWithPatternAndLocalFunctions
()
{
string
source
=
@"
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
private static List<List<int>> l = new List<List<int>>();
static void Main(string[] args)
{
Student s = new Student();
s.Name = ""Bozo"";
s.GPA = 2.3;
Operate(s);
}
static System.Func<string> Operate(Person p)
{
switch (p)
{
case Student s when s.GPA > 3.5:
string f1() => $""Student {s.Name} ({s.GPA:N1})"";
return f1;
case Student s:
string f2() => $""Student {s.Name} ({s.GPA:N1})"";
return f2;
case Teacher t:
string f3() => $""Teacher {t.Name} of {t.Subject}"";
return f3;
default:
string f4() => $""Person {p.Name}"";
return f4;
}
}
}
class Person { public string Name; }
class Teacher : Person { public string Subject; }
class Student : Person { public double GPA; }
"
;
// we just want this to compile without crashing/asserting
var
c
=
CreateCompilationWithMscorlibAndSystemCore
(
source
,
options
:
TestOptions
.
DebugDll
);
c
.
VerifyPdb
(
"Program.Operate"
,
@"<symbols>
<methods>
<method containingType=""Program"" name=""Operate"" parameterNames=""p"">
<customDebugInfo>
<forward declaringType=""Program"" methodName=""Main"" parameterNames=""args"" />
<encLocalSlotMap>
<slot kind=""30"" offset=""0"" />
<slot kind=""30"" offset=""475"" />
<slot kind=""35"" offset=""11"" />
<slot kind=""35"" offset=""11"" />
<slot kind=""35"" offset=""11"" />
<slot kind=""1"" offset=""11"" />
<slot kind=""21"" offset=""0"" />
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>2</methodOrdinal>
<closure offset=""0"" />
<closure offset=""475"" />
<lambda offset=""111"" closure=""1"" />
<lambda offset=""234"" closure=""1"" />
<lambda offset=""357"" closure=""1"" />
<lambda offset=""475"" closure=""0"" />
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" hidden=""true"" />
<entry offset=""0xd"" startLine=""19"" startColumn=""5"" endLine=""19"" endColumn=""6"" />
<entry offset=""0xe"" hidden=""true"" />
<entry offset=""0x1c"" hidden=""true"" />
<entry offset=""0x41"" hidden=""true"" />
<entry offset=""0x48"" startLine=""22"" startColumn=""28"" endLine=""22"" endColumn=""44"" />
<entry offset=""0x61"" startLine=""24"" startColumn=""17"" endLine=""24"" endColumn=""27"" />
<entry offset=""0x71"" hidden=""true"" />
<entry offset=""0x7b"" startLine=""27"" startColumn=""17"" endLine=""27"" endColumn=""27"" />
<entry offset=""0x8b"" hidden=""true"" />
<entry offset=""0x96"" startLine=""30"" startColumn=""17"" endLine=""30"" endColumn=""27"" />
<entry offset=""0xa7"" startLine=""33"" startColumn=""17"" endLine=""33"" endColumn=""27"" />
<entry offset=""0xb7"" startLine=""35"" startColumn=""5"" endLine=""35"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0xba"">
<local name=""CS$<>8__locals0"" il_index=""0"" il_start=""0x0"" il_end=""0xba"" attributes=""0"" />
<scope startOffset=""0xe"" endOffset=""0xb7"">
<local name=""CS$<>8__locals1"" il_index=""1"" il_start=""0xe"" il_end=""0xb7"" attributes=""0"" />
</scope>
</scope>
</method>
</methods>
</symbols>"
);
}
[
Fact
,
WorkItem
(
17090
,
"https://github.com/dotnet/roslyn/issues/17090"
),
WorkItem
(
19731
,
"https://github.com/dotnet/roslyn/issues/19731"
)]
[
Fact
,
WorkItem
(
17090
,
"https://github.com/dotnet/roslyn/issues/17090"
),
WorkItem
(
19731
,
"https://github.com/dotnet/roslyn/issues/19731"
)]
public
void
SwitchWithConstantPattern
()
public
void
SwitchWithConstantPattern
()
{
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录