Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
958ed692
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,发现更多精彩内容 >>
提交
958ed692
编写于
12月 20, 2016
作者:
A
AlekseyTs
提交者:
GitHub
12月 20, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16029 from AlekseyTs/Bug217718
Don't crash when a win32 resource file is too short.
上级
88a3cf08
710aa0e2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
2 deletion
+73
-2
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
+26
-1
src/Compilers/Core/Portable/Compilation/Compilation.cs
src/Compilers/Core/Portable/Compilation/Compilation.cs
+18
-1
src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
...ompilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
+29
-0
未找到文件。
src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
浏览文件 @
958ed692
...
...
@@ -6728,7 +6728,7 @@ public static int Main()
}
[
Fact
(),
WorkItem
(
546025
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546025"
)]
public
void
TestWin32ResWithBadResFile_CS1583ERR_BadWin32Res
()
public
void
TestWin32ResWithBadResFile_CS1583ERR_BadWin32Res
_01
()
{
string
source
=
Temp
.
CreateFile
(
prefix
:
""
,
extension
:
".cs"
).
WriteAllText
(
@"class Test { static void Main() {} }"
).
Path
;
string
badres
=
Temp
.
CreateFile
().
WriteAllBytes
(
TestResources
.
DiagnosticTests
.
badresfile
).
Path
;
...
...
@@ -6752,6 +6752,31 @@ public void TestWin32ResWithBadResFile_CS1583ERR_BadWin32Res()
CleanupAllGeneratedFiles
(
badres
);
}
[
Fact
(),
WorkItem
(
217718
,
"https://devdiv.visualstudio.com/DevDiv/_workitems?id=217718"
)]
public
void
TestWin32ResWithBadResFile_CS1583ERR_BadWin32Res_02
()
{
string
source
=
Temp
.
CreateFile
(
prefix
:
""
,
extension
:
".cs"
).
WriteAllText
(
@"class Test { static void Main() {} }"
).
Path
;
string
badres
=
Temp
.
CreateFile
().
WriteAllBytes
(
new
byte
[]
{
0
,
0
}).
Path
;
var
baseDir
=
Path
.
GetDirectoryName
(
source
);
var
fileName
=
Path
.
GetFileName
(
source
);
var
outWriter
=
new
StringWriter
(
CultureInfo
.
InvariantCulture
);
int
exitCode
=
new
MockCSharpCompiler
(
null
,
baseDir
,
new
[]
{
"/nologo"
,
"/preferreduilang:en"
,
"/win32res:"
+
badres
,
source
}).
Run
(
outWriter
);
Assert
.
Equal
(
1
,
exitCode
);
Assert
.
Equal
(
"error CS1583: Error reading Win32 resources -- Unrecognized resource file format."
,
outWriter
.
ToString
().
Trim
());
CleanupAllGeneratedFiles
(
source
);
CleanupAllGeneratedFiles
(
badres
);
}
[
Fact
,
WorkItem
(
546114
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546114"
)]
public
void
TestFilterCommandLineDiagnostics
()
{
...
...
src/Compilers/Core/Portable/Compilation/Compilation.cs
浏览文件 @
958ed692
...
...
@@ -1284,8 +1284,25 @@ internal void SetupWin32Resources(CommonPEModuleBuilder moduleBeingBuilt, Stream
if
(
win32Resources
==
null
)
return
;
switch
(
DetectWin32ResourceForm
(
win32Resources
))
Win32ResourceForm
resourceForm
;
try
{
resourceForm
=
DetectWin32ResourceForm
(
win32Resources
);
}
catch
(
EndOfStreamException
)
{
diagnostics
.
Add
(
MessageProvider
.
CreateDiagnostic
(
MessageProvider
.
ERR_BadWin32Resource
,
NoLocation
.
Singleton
,
CodeAnalysisResources
.
UnrecognizedResourceFileFormat
));
return
;
}
catch
(
Exception
ex
)
{
diagnostics
.
Add
(
MessageProvider
.
CreateDiagnostic
(
MessageProvider
.
ERR_BadWin32Resource
,
NoLocation
.
Singleton
,
ex
.
Message
));
return
;
}
switch
(
resourceForm
)
{
case
Win32ResourceForm
.
COFF
:
moduleBeingBuilt
.
Win32ResourceSection
=
MakeWin32ResourcesFromCOFF
(
win32Resources
,
diagnostics
);
break
;
...
...
src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
浏览文件 @
958ed692
...
...
@@ -560,6 +560,35 @@ a.vb
CleanupAllGeneratedFiles
(
tmpFileName
)
End
Sub
<
WorkItem
(
217718
,
"https://devdiv.visualstudio.com/DevDiv/_workitems?id=217718"
)
>
<
Fact
>
Public
Sub
BadWin32Resource
()
Dim
source
=
Temp
.
CreateFile
(
prefix
:
=
""
,
extension
:
=
".vb"
).
WriteAllText
(
"
Module Test
Sub Main()
End Sub
End Module"
).
Path
Dim
badres
=
Temp
.
CreateFile
().
WriteAllBytes
(
New
Byte
()
{
0
,
0
}).
Path
Dim
baseDir
=
Path
.
GetDirectoryName
(
source
)
Dim
fileName
=
Path
.
GetFileName
(
source
)
Dim
outWriter
=
New
StringWriter
(
CultureInfo
.
InvariantCulture
)
Dim
exitCode
=
New
MockVisualBasicCompiler
(
Nothing
,
baseDir
,
{
"/nologo"
,
"/preferreduilang:en"
,
"/win32resource:"
+
badres
,
source
}).
Run
(
outWriter
)
Assert
.
Equal
(
1
,
exitCode
)
Assert
.
Equal
(
"vbc : error BC30136: Error creating Win32 resources: Unrecognized resource file format."
,
outWriter
.
ToString
().
Trim
())
CleanupAllGeneratedFiles
(
source
)
CleanupAllGeneratedFiles
(
badres
)
End
Sub
<
Fact
>
Public
Sub
Win32ResourceOptions_Valid
()
CheckWin32ResourceOptions
({
"/win32resource:a"
},
"a"
,
Nothing
,
Nothing
,
False
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录