Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
999cba8b
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,发现更多精彩内容 >>
提交
999cba8b
编写于
3月 04, 2016
作者:
J
Jason Malinowski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include the underlying exception when giving ERR_PeWritingFailure
上级
67f9831e
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
68 addition
and
26 deletion
+68
-26
src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
+9
-0
src/Compilers/CSharp/Portable/CSharpResources.resx
src/Compilers/CSharp/Portable/CSharpResources.resx
+1
-1
src/Compilers/CSharp/Test/Emit/Attributes/EmitTestStrongNameProvider.cs
...CSharp/Test/Emit/Attributes/EmitTestStrongNameProvider.cs
+7
-3
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs
+6
-6
src/Compilers/Core/Portable/Compilation/Compilation.cs
src/Compilers/Core/Portable/Compilation/Compilation.cs
+1
-1
src/Compilers/VisualBasic/Portable/VBResources.Designer.vb
src/Compilers/VisualBasic/Portable/VBResources.Designer.vb
+9
-0
src/Compilers/VisualBasic/Portable/VBResources.resx
src/Compilers/VisualBasic/Portable/VBResources.resx
+1
-1
src/Compilers/VisualBasic/Test/Emit/Attributes/EmitTestStrongNameProvider.vb
...lBasic/Test/Emit/Attributes/EmitTestStrongNameProvider.vb
+6
-3
src/Compilers/VisualBasic/Test/Emit/Emit/CompilationEmitTests.vb
...pilers/VisualBasic/Test/Emit/Emit/CompilationEmitTests.vb
+4
-4
src/Test/Utilities/Shared/Pe/BrokenStream.cs
src/Test/Utilities/Shared/Pe/BrokenStream.cs
+24
-7
未找到文件。
src/Compilers/CSharp/Portable/CSharpResources.Designer.cs
浏览文件 @
999cba8b
...
...
@@ -7045,6 +7045,15 @@ internal class CSharpResources {
}
}
/// <summary>
/// Looks up a localized string similar to An error occurred while writing the output file: {0}.
/// </summary>
internal static string ERR_PeWritingFailure {
get {
return ResourceManager.GetString("ERR_PeWritingFailure", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Neither 'is' nor 'as' is valid on pointer types.
/// </summary>
...
...
src/Compilers/CSharp/Portable/CSharpResources.resx
浏览文件 @
999cba8b
...
...
@@ -4676,6 +4676,6 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<value>
Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals.
</value>
</data>
<data
name=
"ERR_PeWritingFailure"
xml:space=
"preserve"
>
<value>
An error occurred while writing the output file
.
</value>
<value>
An error occurred while writing the output file
: {0}
</value>
</data>
</root>
src/Compilers/CSharp/Test/Emit/Attributes/EmitTestStrongNameProvider.cs
浏览文件 @
999cba8b
...
...
@@ -16,6 +16,9 @@ public partial class InternalsVisibleToAndStrongNameTests : CSharpTestBase
private
class
StrongNameProviderWithBadInputStream
:
StrongNameProvider
{
private
StrongNameProvider
_underlyingProvider
;
public
Exception
ThrownException
;
public
StrongNameProviderWithBadInputStream
(
StrongNameProvider
underlyingProvider
)
{
_underlyingProvider
=
underlyingProvider
;
...
...
@@ -27,7 +30,8 @@ public StrongNameProviderWithBadInputStream(StrongNameProvider underlyingProvide
internal
override
Stream
CreateInputStream
()
{
throw
new
IOException
(
"This is a test IOException"
);
ThrownException
=
new
IOException
(
"This is a test IOException"
);
throw
ThrownException
;
}
internal
override
StrongNameKeys
CreateKeys
(
string
keyFilePath
,
string
keyContainerName
,
CommonMessageProvider
messageProvider
)
=>
...
...
@@ -53,9 +57,9 @@ class C
var
comp
=
CreateCompilationWithMscorlib
(
src
,
options
:
options
);
comp
.
VerifyEmitDiagnostics
(
comp
.
Emit
(
new
MemoryStream
()).
Diagnostics
.
Verify
(
// error CS8104: An error occurred while writing the Portable Executable file.
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
"This is a test IOException"
).
WithLocation
(
1
,
1
));
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
testProvider
.
ThrownException
.
ToString
()
).
WithLocation
(
1
,
1
));
}
}
}
src/Compilers/CSharp/Test/Emit/Emit/CompilationEmitTests.cs
浏览文件 @
999cba8b
...
...
@@ -2701,13 +2701,13 @@ public void BrokenOutStream()
var
result
=
compilation
.
Emit
(
output
);
result
.
Diagnostics
.
Verify
(
// error CS8104: An error occurred while writing the Portable Executable file.
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
"I/O error occurred."
).
WithLocation
(
1
,
1
));
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
output
.
ThrownException
.
ToString
()
).
WithLocation
(
1
,
1
));
output
.
BreakHow
=
1
;
output
.
BreakHow
=
BrokenStream
.
BreakHowType
.
ThrowOnSetPosition
;
result
=
compilation
.
Emit
(
output
);
result
.
Diagnostics
.
Verify
(
// error CS8104: An error occurred while writing the Portable Executable file.
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
"Specified method is not supported."
).
WithLocation
(
1
,
1
));
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
output
.
ThrownException
.
ToString
()
).
WithLocation
(
1
,
1
));
// disposed stream is not writable
var
outReal
=
new
MemoryStream
();
...
...
@@ -2723,7 +2723,7 @@ public void BrokenPDBStream()
var
output
=
new
MemoryStream
();
var
pdb
=
new
BrokenStream
();
pdb
.
BreakHow
=
2
;
pdb
.
BreakHow
=
BrokenStream
.
BreakHowType
.
ThrowOnSetLength
;
var
result
=
compilation
.
Emit
(
output
,
pdb
);
// error CS0041: Unexpected error writing debug information -- 'Exception from HRESULT: 0x806D0004'
...
...
@@ -2969,12 +2969,12 @@ public static void Main()
}"
;
var
compilation
=
CreateCompilationWithMscorlib
(
source
);
var
broken
=
new
BrokenStream
();
broken
.
BreakHow
=
0
;
broken
.
BreakHow
=
BrokenStream
.
BreakHowType
.
ThrowOnWrite
;
var
result
=
compilation
.
Emit
(
broken
);
Assert
.
False
(
result
.
Success
);
result
.
Diagnostics
.
Verify
(
// error CS8104: An error occurred while writing the Portable Executable file.
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
"I/O error occurred."
).
WithLocation
(
1
,
1
));
Diagnostic
(
ErrorCode
.
ERR_PeWritingFailure
).
WithArguments
(
broken
.
ThrownException
.
ToString
()
).
WithLocation
(
1
,
1
));
}
}
}
src/Compilers/Core/Portable/Compilation/Compilation.cs
浏览文件 @
999cba8b
...
...
@@ -1908,7 +1908,7 @@ private static EmitResult ToEmitResultAndFree(DiagnosticBag diagnostics, bool su
}
catch
(
Cci
.
PeWritingException
e
)
{
diagnostics
.
Add
(
MessageProvider
.
CreateDiagnostic
(
MessageProvider
.
ERR_PeWritingFailure
,
Location
.
None
,
e
.
Message
));
diagnostics
.
Add
(
MessageProvider
.
CreateDiagnostic
(
MessageProvider
.
ERR_PeWritingFailure
,
Location
.
None
,
e
.
InnerException
.
ToString
()
));
return
false
;
}
catch
(
ResourceException
e
)
...
...
src/Compilers/VisualBasic/Portable/VBResources.Designer.vb
浏览文件 @
999cba8b
...
...
@@ -9009,6 +9009,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
'''<summary>
''' Looks up a localized string similar to An error occurred while writing the output file: {0}.
'''</summary>
Friend ReadOnly Property ERR_PeWritingFailure() As String
Get
Return ResourceManager.GetString("ERR_PeWritingFailure", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Cannot embed interop types from assembly '{0}' because it is missing the '{1}' attribute..
'''</summary>
...
...
src/Compilers/VisualBasic/Portable/VBResources.resx
浏览文件 @
999cba8b
...
...
@@ -5348,6 +5348,6 @@
<value>
Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string or XML literals.
</value>
</data>
<data
name=
"ERR_PeWritingFailure"
xml:space=
"preserve"
>
<value>
An error occurred while writing the output file
.
</value>
<value>
An error occurred while writing the output file
: {0}
</value>
</data>
</root>
src/Compilers/VisualBasic/Test/Emit/Attributes/EmitTestStrongNameProvider.vb
浏览文件 @
999cba8b
...
...
@@ -11,6 +11,8 @@ Partial Public Class InternalsVisibleToAndStrongNameTests
Private
Class
StrongNameProviderWithBadInputStream
Inherits
StrongNameProvider
Private
_underlyingProvider
As
StrongNameProvider
Public
Property
ThrownException
As
Exception
Public
Sub
New
(
underlyingProvider
As
StrongNameProvider
)
_underlyingProvider
=
underlyingProvider
End
Sub
...
...
@@ -25,7 +27,8 @@ Partial Public Class InternalsVisibleToAndStrongNameTests
End
Function
Friend
Overrides
Function
CreateInputStream
()
As
Stream
Throw
New
IOException
(
"This is a test IOException"
)
ThrownException
=
New
IOException
(
"This is a test IOException"
)
Throw
ThrownException
End
Function
Friend
Overrides
Function
CreateKeys
(
keyFilePath
As
String
,
keyContainerName
As
String
,
messageProvider
As
CommonMessageProvider
)
As
StrongNameKeys
...
...
@@ -53,8 +56,8 @@ End Class
</
file
>
</
compilation
>
,
options
:
=
options
)
comp
.
VerifyEmitDiagnostics
(
Diagnostic
(
ERRID
.
ERR_PeWritingFailure
).
WithArguments
(
"This is a test IOException"
).
WithLocation
(
1
,
1
))
comp
.
Emit
(
New
MemoryStream
()).
Diagnostics
.
Verify
(
Diagnostic
(
ERRID
.
ERR_PeWritingFailure
).
WithArguments
(
testProvider
.
ThrownException
.
ToString
()
).
WithLocation
(
1
,
1
))
End
Sub
...
...
src/Compilers/VisualBasic/Test/Emit/Emit/CompilationEmitTests.vb
浏览文件 @
999cba8b
...
...
@@ -2939,14 +2939,14 @@ End Module
Dim
emitResult
As
EmitResult
Using
output
=
New
BrokenStream
()
output
.
BreakHow
=
0
output
.
BreakHow
=
BrokenStream
.
BreakHowType
.
ThrowOnWrite
emitResult
=
compilation
.
Emit
(
output
,
Nothing
,
Nothing
,
Nothing
)
End
Using
CompilationUtils
.
AssertTheseDiagnostics
(
emitResult
.
Diagnostics
,
CompilationUtils
.
AssertTheseDiagnostics
(
emitResult
.
Diagnostics
,
<
expected
>
BC37256
:
An
error
occurred
while
writing
the
output
file
.
BC37256
:
An
error
occurred
while
writing
the
output
file
:
<
%
=
output
.
ThrownException
.
ToString
()
%
>
</
expected
>
)
End
Using
End
Sub
End
Class
End
Namespace
src/Test/Utilities/Shared/Pe/BrokenStream.cs
浏览文件 @
999cba8b
...
...
@@ -7,7 +7,15 @@ namespace Roslyn.Test.Utilities
{
internal
class
BrokenStream
:
Stream
{
public
int
BreakHow
;
public
enum
BreakHowType
{
ThrowOnSetPosition
,
ThrowOnWrite
,
ThrowOnSetLength
}
public
BreakHowType
BreakHow
;
public
Exception
ThrownException
{
get
;
private
set
;
}
public
override
bool
CanRead
{
...
...
@@ -44,8 +52,11 @@ public override long Position
}
set
{
if
(
BreakHow
==
1
)
throw
new
NotSupportedException
();
if
(
BreakHow
==
BreakHowType
.
ThrowOnSetPosition
)
{
ThrownException
=
new
NotSupportedException
();
throw
ThrownException
;
}
}
}
...
...
@@ -61,14 +72,20 @@ public override long Seek(long offset, SeekOrigin origin)
public
override
void
SetLength
(
long
value
)
{
if
(
BreakHow
==
2
)
throw
new
IOException
();
if
(
BreakHow
==
BreakHowType
.
ThrowOnSetLength
)
{
ThrownException
=
new
IOException
();
throw
ThrownException
;
}
}
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
count
)
{
if
(
BreakHow
==
0
)
throw
new
IOException
();
if
(
BreakHow
==
BreakHowType
.
ThrowOnWrite
)
{
ThrownException
=
new
IOException
();
throw
ThrownException
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录