Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9fbd6658
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,发现更多精彩内容 >>
提交
9fbd6658
编写于
7月 17, 2019
作者:
I
Ivan Basov
提交者:
Tomáš Matoušek
7月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EnC support of static local functions (#36800)
* EnC support of static local functions * code review feedback
上级
661d5e7e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
148 addition
and
0 deletion
+148
-0
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs
.../Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs
+62
-0
src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs
...tures/CSharpTest/EditAndContinue/StatementEditingTests.cs
+86
-0
未找到文件。
src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs
浏览文件 @
9fbd6658
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
using
System.Linq
;
using
System.Linq
;
using
System.Reflection.Metadata.Ecma335
;
using
System.Reflection.Metadata.Ecma335
;
using
Microsoft.CodeAnalysis.CodeGen
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.CSharp.UnitTests
;
using
Microsoft.CodeAnalysis.CSharp.UnitTests
;
...
@@ -172,6 +173,67 @@ void F()
...
@@ -172,6 +173,67 @@ void F()
Row
(
5
,
TableIndex
.
CustomAttribute
,
EditAndContinueOperation
.
Default
));
Row
(
5
,
TableIndex
.
CustomAttribute
,
EditAndContinueOperation
.
Default
));
}
}
[
Fact
]
public
void
MethodWithStaticLocalFunction_ChangeStatic
()
{
var
source0
=
MarkedSource
(
@"
using System;
class C
{
void F()
{
<N:0>int x() => 1;</N:0>
}
}"
);
var
source1
=
MarkedSource
(
@"
using System;
class C
{
void F()
{
<N:0>static int x() => 1;</N:0>
}
}"
);
var
compilation0
=
CreateCompilation
(
source0
.
Tree
,
options
:
ComSafeDebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
));
var
compilation1
=
compilation0
.
WithSource
(
source1
.
Tree
);
var
v0
=
CompileAndVerify
(
compilation0
);
var
md0
=
ModuleMetadata
.
CreateFromImage
(
v0
.
EmittedAssemblyData
);
var
reader0
=
md0
.
MetadataReader
;
var
f0
=
compilation0
.
GetMember
<
MethodSymbol
>(
"C.F"
);
var
f1
=
compilation1
.
GetMember
<
MethodSymbol
>(
"C.F"
);
var
generation0
=
EmitBaseline
.
CreateInitialBaseline
(
md0
,
v0
.
CreateSymReader
().
GetEncMethodDebugInfo
);
var
diff1
=
compilation1
.
EmitDifference
(
generation0
,
ImmutableArray
.
Create
(
new
SemanticEdit
(
SemanticEditKind
.
Update
,
f0
,
f1
,
GetSyntaxMapFromMarkers
(
source0
,
source1
),
preserveLocalVariables
:
true
)));
diff1
.
VerifySynthesizedMembers
(
"C: {<F>g__x|0_0}"
);
var
md1
=
diff1
.
GetMetadata
();
var
reader1
=
md1
.
Reader
;
// Method updates
CheckEncLogDefinitions
(
reader1
,
Row
(
1
,
TableIndex
.
MethodDef
,
EditAndContinueOperation
.
Default
),
Row
(
3
,
TableIndex
.
MethodDef
,
EditAndContinueOperation
.
Default
),
Row
(
5
,
TableIndex
.
CustomAttribute
,
EditAndContinueOperation
.
Default
));
var
testData0
=
new
CompilationTestData
();
var
bytes0
=
compilation0
.
EmitToArray
(
testData
:
testData0
);
var
localFunction0
=
testData0
.
GetMethodData
(
"C.<F>g__x|0_0"
).
Method
;
Assert
.
True
(
localFunction0
.
IsStatic
);
var
localFunction1
=
diff1
.
TestData
.
GetMethodData
(
"C.<F>g__x|0_0"
).
Method
;
Assert
.
True
(
localFunction1
.
IsStatic
);
}
[
Fact
]
[
Fact
]
public
void
MethodWithStaticLambdaGeneric1
()
public
void
MethodWithStaticLambdaGeneric1
()
{
{
...
...
src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs
浏览文件 @
9fbd6658
...
@@ -6816,6 +6816,92 @@ static void F()
...
@@ -6816,6 +6816,92 @@ static void F()
});
});
}
}
[
Fact
]
public
void
LocalFunction_AddStatic
()
{
var
src1
=
@"class Test { void M() { int local() { throw null; } } }"
;
var
src2
=
@"class Test { void M() { static int local() { throw null; } } }"
;
var
edits
=
GetTopEdits
(
src1
,
src2
,
CSharpParseOptions
.
Default
.
WithLanguageVersion
(
LanguageVersion
.
Preview
));
edits
.
VerifyEdits
(
"Update [void M() { int local() { throw null; } }]@13 -> [void M() { static int local() { throw null; } }]@13"
);
edits
.
VerifyRudeDiagnostics
();
}
[
Fact
]
public
void
LocalFunction_RemoveStatic
()
{
var
src1
=
@"class Test { void M() { static int local() { throw null; } } }"
;
var
src2
=
@"class Test { void M() { int local() { throw null; } } }"
;
var
edits
=
GetTopEdits
(
src1
,
src2
,
CSharpParseOptions
.
Default
.
WithLanguageVersion
(
LanguageVersion
.
Preview
));
edits
.
VerifyEdits
(
"Update [void M() { static int local() { throw null; } }]@13 -> [void M() { int local() { throw null; } }]@13"
);
edits
.
VerifyRudeDiagnostics
();
}
[
Fact
]
public
void
LocalFunction_AddUnsafe
()
{
var
src1
=
@"class Test { void M() { int local() { throw null; } } }"
;
var
src2
=
@"class Test { void M() { unsafe int local() { throw null; } } }"
;
var
edits
=
GetTopEdits
(
src1
,
src2
,
CSharpParseOptions
.
Default
.
WithLanguageVersion
(
LanguageVersion
.
Preview
));
edits
.
VerifyEdits
(
"Update [void M() { int local() { throw null; } }]@13 -> [void M() { unsafe int local() { throw null; } }]@13"
);
edits
.
VerifyRudeDiagnostics
();
}
[
Fact
]
public
void
LocalFunction_RemoveUnsafe
()
{
var
src1
=
@"class Test { void M() { unsafe int local() { throw null; } } }"
;
var
src2
=
@"class Test { void M() { int local() { throw null; } } }"
;
var
edits
=
GetTopEdits
(
src1
,
src2
,
CSharpParseOptions
.
Default
.
WithLanguageVersion
(
LanguageVersion
.
Preview
));
edits
.
VerifyEdits
(
"Update [void M() { unsafe int local() { throw null; } }]@13 -> [void M() { int local() { throw null; } }]@13"
);
edits
.
VerifyRudeDiagnostics
();
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/37054"
)]
public
void
LocalFunction_AddAsync
()
{
var
src1
=
@"class Test { void M() { int local() { throw null; } } }"
;
var
src2
=
@"class Test { void M() { async int local() { throw null; } } }"
;
var
edits
=
GetTopEdits
(
src1
,
src2
,
CSharpParseOptions
.
Default
.
WithLanguageVersion
(
LanguageVersion
.
Preview
));
edits
.
VerifyEdits
(
"Update [void M() { int local() { throw null; } }]@13 -> [void M() { async int local() { throw null; } }]@13"
);
edits
.
VerifyRudeDiagnostics
(
Diagnostic
(
RudeEditKind
.
ModifiersUpdate
,
"async int local() "
,
FeaturesResources
.
method
));
}
[
Fact
(
Skip
=
"https://github.com/dotnet/roslyn/issues/37054"
)]
public
void
LocalFunction_RemoveAsync
()
{
var
src1
=
@"class Test { void M() { async int local() { throw null; } } }"
;
var
src2
=
@"class Test { void M() { int local() { throw null; } } }"
;
var
edits
=
GetTopEdits
(
src1
,
src2
,
CSharpParseOptions
.
Default
.
WithLanguageVersion
(
LanguageVersion
.
Preview
));
edits
.
VerifyEdits
(
"Update [void M() { async int local() { throw null; } }]@13 -> [void M() { int local() { throw null; } }]@13"
);
edits
.
VerifyRudeDiagnostics
(
Diagnostic
(
RudeEditKind
.
ModifiersUpdate
,
"int local() "
,
FeaturesResources
.
method
));
}
#
endregion
#
endregion
#
region
Queries
#
region
Queries
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录