Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
73c9a098
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,发现更多精彩内容 >>
未验证
提交
73c9a098
编写于
1月 04, 2019
作者:
J
Jared Parsons
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Respond to PR feedback
上级
b3511fcf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
18 deletion
+29
-18
src/Compilers/Core/Portable/Compilation.EmitStream.cs
src/Compilers/Core/Portable/Compilation.EmitStream.cs
+25
-8
src/Compilers/Core/Portable/Compilation/Compilation.cs
src/Compilers/Core/Portable/Compilation/Compilation.cs
+4
-8
src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs
...ers/Core/Portable/StrongName/DesktopStrongNameProvider.cs
+0
-2
未找到文件。
src/Compilers/Core/Portable/Compilation.EmitStream.cs
浏览文件 @
73c9a098
...
...
@@ -3,6 +3,8 @@
using
System
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Reflection.PortableExecutable
;
using
Microsoft.CodeAnalysis.Interop
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis
...
...
@@ -16,7 +18,20 @@ public abstract partial class Compilation
internal
enum
EmitStreamSignKind
{
None
,
/// <summary>
/// This form of signing occurs in memory using the <see cref="PEBuilder"/> APIs. This is the default
/// form of signing and will be used when a strong name key is provided in a file on disk.
/// </summary>
SignedWithBulider
,
/// <summary>
/// This form of signing occurs using the <see cref="IClrStrongName"/> COM APIs. This form of signing
/// requires the unsigned PE to be written to disk before it can be signed (typically by writing it
/// out to the %TEMP% folder). This signing is used when the key in a key container, the signing
/// requires a counter signature or customers opted in via the UseLegacyStrongNameProvider feature
/// flag.
/// </summary>
SignedWithFile
,
}
...
...
@@ -34,7 +49,7 @@ internal sealed class EmitStream
/// <summary>
/// The <see cref="Stream"/> that is being emitted into. This value should _never_ be
///
Dispose
. It is either returned from the <see cref="EmitStreamProvider"/> instance in
///
disposed
. It is either returned from the <see cref="EmitStreamProvider"/> instance in
/// which case it is owned by that. Or it is just an alias for the value that is stored
/// in <see cref="_tempInfo"/> in which case it will be disposed from there.
/// </summary>
...
...
@@ -83,7 +98,6 @@ private Stream CreateStream(DiagnosticBag diagnostics)
_stream
=
_emitStreamProvider
.
GetOrCreateStream
(
diagnostics
);
if
(
_stream
==
null
)
{
Debug
.
Assert
(
diagnostics
.
HasAnyErrors
());
return
null
;
}
...
...
@@ -95,22 +109,24 @@ private Stream CreateStream(DiagnosticBag diagnostics)
{
Debug
.
Assert
(
_strongNameProvider
!=
null
);
Stream
tempStream
;
string
tempFilePath
;
try
{
var
fileSystem
=
_strongNameProvider
.
FileSystem
;
Func
<
string
,
Stream
>
streamConstructor
=
path
=>
fileSystem
.
CreateFileStream
(
path
,
FileMode
.
Create
,
FileAccess
.
ReadWrite
,
FileShare
.
ReadWrite
);
var
tempDir
=
fileSystem
.
GetTempPath
();
var
tempFilePath
=
Path
.
Combine
(
tempDir
,
Guid
.
NewGuid
().
ToString
(
"N"
));
var
tempStream
=
FileUtilities
.
CreateFileStreamChecked
(
streamConstructor
,
tempFilePath
);
_tempInfo
=
(
tempStream
,
tempFilePath
);
return
tempStream
;
tempFilePath
=
Path
.
Combine
(
tempDir
,
Guid
.
NewGuid
().
ToString
(
"N"
));
tempStream
=
FileUtilities
.
CreateFileStreamChecked
(
streamConstructor
,
tempFilePath
);
}
catch
(
IOException
e
)
{
throw
new
Cci
.
PeWritingException
(
e
);
}
_tempInfo
=
(
tempStream
,
tempFilePath
);
return
tempStream
;
}
else
{
...
...
@@ -121,11 +137,12 @@ private Stream CreateStream(DiagnosticBag diagnostics)
internal
bool
Complete
(
StrongNameKeys
strongNameKeys
,
CommonMessageProvider
messageProvider
,
DiagnosticBag
diagnostics
)
{
Debug
.
Assert
(
_stream
!=
null
);
Debug
.
Assert
(
_emitStreamSignKind
!=
EmitStreamSignKind
.
SignedWithFile
||
_tempInfo
.
HasValue
);
if
(
_tempInfo
.
HasValue
)
{
Debug
.
Assert
(
_emitStreamSignKind
==
EmitStreamSignKind
.
SignedWithFile
);
var
(
tempStream
,
tempFilePath
)
=
_tempInfo
.
Value
;
var
(
tempStream
,
tempFilePath
)
=
_tempInfo
.
GetValueOrDefault
()
;
try
{
...
...
src/Compilers/Core/Portable/Compilation/Compilation.cs
浏览文件 @
73c9a098
...
...
@@ -1658,7 +1658,7 @@ internal void SetupWin32Resources(CommonPEModuleBuilder moduleBeingBuilt, Stream
/// 2. Write the unsigned PE to disk and use CLR COM APIs to sign.
/// The preferred method is #1 as it's more efficient and more resilient (no reliance on %TEMP%). But
/// we must continue to support #2 as it's the only way to do the following:
/// - Access private keys stored in a key
/// - Access private keys stored in a key
container
/// - Do proper counter signature verification for AssemblySignatureKey attributes
/// </summary>
internal
bool
SignUsingBuilder
=>
...
...
@@ -2732,11 +2732,9 @@ internal void EnsureAnonymousTypeTemplates(CancellationToken cancellationToken)
return
false
;
}
if
(!
emitPeStream
.
Complete
(
StrongNameKeys
,
MessageProvider
,
diagnostics
)
||
emitMetadataStream
?.
Complete
(
StrongNameKeys
,
MessageProvider
,
diagnostics
)
==
false
)
{
return
false
;
}
return
emitPeStream
.
Complete
(
StrongNameKeys
,
MessageProvider
,
diagnostics
)
&&
(
emitMetadataStream
?.
Complete
(
StrongNameKeys
,
MessageProvider
,
diagnostics
)
??
true
);
}
finally
{
...
...
@@ -2746,8 +2744,6 @@ internal void EnsureAnonymousTypeTemplates(CancellationToken cancellationToken)
pdbBag
?.
Free
();
metadataDiagnostics
?.
Free
();
}
return
true
;
}
private
static
Stream
ConditionalGetOrCreateStream
(
EmitStreamProvider
metadataPEStreamProvider
,
DiagnosticBag
metadataDiagnostics
)
...
...
src/Compilers/Core/Portable/StrongName/DesktopStrongNameProvider.cs
浏览文件 @
73c9a098
...
...
@@ -29,7 +29,6 @@ public class DesktopStrongNameProvider : StrongNameProvider
// so there's no chance of an API consumer seeing it.
internal
sealed
class
ClrStrongNameMissingException
:
Exception
{
}
private
readonly
ImmutableArray
<
string
>
_keyFileSearchPaths
;
...
...
@@ -37,7 +36,6 @@ internal sealed class ClrStrongNameMissingException : Exception
public
DesktopStrongNameProvider
(
ImmutableArray
<
string
>
keyFileSearchPaths
)
:
this
(
keyFileSearchPaths
,
StrongNameFileSystem
.
Instance
)
{
}
/// <summary>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录