Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
5a259513
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,发现更多精彩内容 >>
提交
5a259513
编写于
4月 13, 2017
作者:
J
Julien Couvreur
提交者:
GitHub
4月 13, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Filter "missing method body" error when emitting metadata-only (#18542)
上级
8e6cfc0f
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
40 addition
and
15 deletion
+40
-15
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+8
-1
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs
+24
-11
src/Compilers/Core/Portable/Compilation/Compilation.cs
src/Compilers/Core/Portable/Compilation/Compilation.cs
+7
-2
src/Compilers/VisualBasic/Portable/Compilation/VisualBasicCompilation.vb
...isualBasic/Portable/Compilation/VisualBasicCompilation.vb
+1
-1
未找到文件。
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
5a259513
...
...
@@ -2311,7 +2311,14 @@ internal override StrongNameKeys StrongNameKeys
{
// The diagnostics should include syntax and declaration errors. We insert these before calling Emitter.Emit, so that the emitter
// does not attempt to emit if there are declaration errors (but we do insert all errors from method body binding...)
bool
hasDeclarationErrors
=
!
FilterAndAppendDiagnostics
(
diagnostics
,
GetDiagnostics
(
CompilationStage
.
Declare
,
true
,
cancellationToken
));
PooledHashSet
<
int
>
excludeDiagnostics
=
null
;
if
(
emitMetadataOnly
)
{
excludeDiagnostics
=
PooledHashSet
<
int
>.
GetInstance
();
excludeDiagnostics
.
Add
((
int
)
ErrorCode
.
ERR_ConcreteMissingBody
);
}
bool
hasDeclarationErrors
=
!
FilterAndAppendDiagnostics
(
diagnostics
,
GetDiagnostics
(
CompilationStage
.
Declare
,
true
,
cancellationToken
),
excludeDiagnostics
);
excludeDiagnostics
?.
Free
();
// TODO (tomat): NoPIA:
// EmbeddedSymbolManager.MarkAllDeferredSymbolsAsReferenced(this)
...
...
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs
浏览文件 @
5a259513
...
...
@@ -321,7 +321,6 @@ public void RefAssembly_ReferenceAssemblyAttributeAlsoInSource()
[
InlineData
(
"public struct S { private int i; }"
,
"public struct S { }"
,
Match
.
Different
)]
[
InlineData
(
"private int i;"
,
""
,
Match
.
RefOut
)]
[
InlineData
(
"public C() { }"
,
""
,
Match
.
BothMetadataAndRefOut
)]
//[InlineData("public int NoBody();", "public int NoBody() { }", Match.BothMetadataAndRefOut)] // PROTOTYPE(refout) Further refinement https://github.com/dotnet/roslyn/issues/17612
public
void
RefAssembly_InvariantToSomeChanges
(
string
left
,
string
right
,
Match
expectedMatch
)
{
string
sourceTemplate
=
@"
...
...
@@ -569,26 +568,40 @@ private static void VerifyRefAssemblyClient(string lib_cs, string source, Action
[
Theory
]
[
InlineData
(
"public int M() { error(); }"
,
true
)]
[
InlineData
(
"public int M() { error() }"
,
false
)]
// Should be true. See follow-up issue https://github.com/dotnet/roslyn/issues/17612
[
InlineData
(
"public int M() { error() }"
,
false
)]
// This may get relaxed. See follow-up issue https://github.com/dotnet/roslyn/issues/17612
[
InlineData
(
"public int M();"
,
true
)]
[
InlineData
(
"public int M() { int Local(); }"
,
true
)]
[
InlineData
(
"public C();"
,
true
)]
[
InlineData
(
"~ C();"
,
true
)]
[
InlineData
(
"public Error M() { return null; }"
,
false
)]
// This may get relaxed. See follow-up issue https://github.com/dotnet/roslyn/issues/17612
[
InlineData
(
"public static explicit operator C(int i);"
,
true
)]
[
InlineData
(
"public async Task M();"
,
false
)]
[
InlineData
(
"partial void M(); partial void M();"
,
false
)]
// This may get relaxed. See follow-up issue https://github.com/dotnet/roslyn/issues/17612
public
void
RefAssembly_IgnoresSomeDiagnostics
(
string
change
,
bool
expectSuccess
)
{
string
sourceTemplate
=
@"
public class C
using System.Threading.Tasks;
public partial class C
{
CHANGE
}
"
;
VerifyIgnoresDiagnostics
(
EmitOptions
.
Default
.
WithEmitMetadataOnly
(
false
).
WithTolerateErrors
(
false
),
success
:
false
);
VerifyIgnoresDiagnostics
(
EmitOptions
.
Default
.
WithEmitMetadataOnly
(
true
).
WithTolerateErrors
(
false
),
success
:
expectSuccess
);
void
VerifyIgnoresDiagnostics
(
EmitOptions
emitOptions
,
bool
success
)
{
string
source
=
sourceTemplate
.
Replace
(
"CHANGE"
,
change
);
string
name
=
GetUniqueName
();
CSharpCompilation
comp1
=
CreateCompilationWithMscorlib
(
Parse
(
source
),
CSharpCompilation
comp
=
CreateCompilationWithMscorlib
(
Parse
(
source
),
options
:
TestOptions
.
DebugDll
.
WithDeterministic
(
true
),
assemblyName
:
name
);
using
(
var
output
=
new
MemoryStream
())
{
var
emitResult
=
comp1
.
Emit
(
output
,
options
:
EmitOptions
.
Default
.
WithEmitMetadataOnly
(
true
));
Assert
.
Equal
(
expectSuccess
,
emitResult
.
Success
);
Assert
.
Equal
(!
expectSuccess
,
emitResult
.
Diagnostics
.
Any
());
var
emitResult
=
comp
.
Emit
(
output
,
options
:
emitOptions
);
Assert
.
Equal
(!
success
,
emitResult
.
Diagnostics
.
HasAnyErrors
());
Assert
.
Equal
(
success
,
emitResult
.
Success
);
}
}
}
...
...
src/Compilers/Core/Portable/Compilation/Compilation.cs
浏览文件 @
5a259513
...
...
@@ -1151,7 +1151,7 @@ internal void CompleteCompilationEventQueue_NoLock()
/// <returns>True if there were no errors or warnings-as-errors.</returns>
internal
bool
FilterAndAppendAndFreeDiagnostics
(
DiagnosticBag
accumulator
,
ref
DiagnosticBag
incoming
)
{
bool
result
=
FilterAndAppendDiagnostics
(
accumulator
,
incoming
.
AsEnumerableWithoutResolution
());
bool
result
=
FilterAndAppendDiagnostics
(
accumulator
,
incoming
.
AsEnumerableWithoutResolution
()
,
exclude
:
null
);
incoming
.
Free
();
incoming
=
null
;
return
result
;
...
...
@@ -1161,13 +1161,18 @@ internal bool FilterAndAppendAndFreeDiagnostics(DiagnosticBag accumulator, ref D
/// Filter out warnings based on the compiler options (/nowarn, /warn and /warnaserror) and the pragma warning directives.
/// </summary>
/// <returns>True when there is no error.</returns>
internal
bool
FilterAndAppendDiagnostics
(
DiagnosticBag
accumulator
,
IEnumerable
<
Diagnostic
>
incoming
)
internal
bool
FilterAndAppendDiagnostics
(
DiagnosticBag
accumulator
,
IEnumerable
<
Diagnostic
>
incoming
,
HashSet
<
int
>
exclude
)
{
bool
hasError
=
false
;
bool
reportSuppressedDiagnostics
=
Options
.
ReportSuppressedDiagnostics
;
foreach
(
Diagnostic
d
in
incoming
)
{
if
(
exclude
?.
Contains
(
d
.
Code
)
==
true
)
{
continue
;
}
var
filtered
=
Options
.
FilterDiagnostic
(
d
);
if
(
filtered
==
null
||
(!
reportSuppressedDiagnostics
&&
filtered
.
IsSuppressed
))
...
...
src/Compilers/VisualBasic/Portable/Compilation/VisualBasicCompilation.vb
浏览文件 @
5a259513
...
...
@@ -2221,7 +2221,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' The diagnostics should include syntax and declaration errors. We insert these before calling Emitter.Emit, so that we don't emit
' metadata if there are declaration errors or method body errors (but we do insert all errors from method body binding...)
Dim
hasDeclarationErrors
=
Not
FilterAndAppendDiagnostics
(
diagnostics
,
GetDiagnostics
(
CompilationStage
.
Declare
,
True
,
cancellationToken
))
Dim
hasDeclarationErrors
=
Not
FilterAndAppendDiagnostics
(
diagnostics
,
GetDiagnostics
(
CompilationStage
.
Declare
,
True
,
cancellationToken
)
,
exclude
:
=
Nothing
)
Dim
moduleBeingBuilt
=
DirectCast
(
moduleBuilder
,
PEModuleBuilder
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录