Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
af3c6740
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,发现更多精彩内容 >>
提交
af3c6740
编写于
9月 23, 2015
作者:
T
Ty Overby
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5398 from TyOverby/4578-wildcard-deterministic
Ban assembly versions with wildcards in deterministic builds
上级
50b4086b
dff44c36
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
2 deletion
+37
-2
src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs
...rs/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs
+1
-1
src/Compilers/CSharp/Test/Emit/Emit/DeterministicTests.cs
src/Compilers/CSharp/Test/Emit/Emit/DeterministicTests.cs
+15
-0
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceAssemblySymbol.vb
...sualBasic/Portable/Symbols/Source/SourceAssemblySymbol.vb
+1
-1
src/Compilers/VisualBasic/Test/Emit/Emit/DeterministicTests.vb
...ompilers/VisualBasic/Test/Emit/Emit/DeterministicTests.vb
+20
-0
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs
浏览文件 @
af3c6740
...
...
@@ -2073,7 +2073,7 @@ private void DecodeWellKnownAttribute(ref DecodeWellKnownAttributeArguments<Attr
{
string
verString
=
(
string
)
attribute
.
CommonConstructorArguments
[
0
].
Value
;
Version
version
;
if
(!
VersionHelper
.
TryParseAssemblyVersion
(
verString
,
allowWildcard
:
true
,
version
:
out
version
))
if
(!
VersionHelper
.
TryParseAssemblyVersion
(
verString
,
allowWildcard
:
!
_compilation
.
IsEmitDeterministic
,
version
:
out
version
))
{
Location
attributeArgumentSyntaxLocation
=
attribute
.
GetAttributeArgumentSyntaxLocation
(
0
,
arguments
.
AttributeSyntaxOpt
);
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_InvalidVersionFormat
,
attributeArgumentSyntaxLocation
);
...
...
src/Compilers/CSharp/Test/Emit/Emit/DeterministicTests.cs
浏览文件 @
af3c6740
...
...
@@ -51,6 +51,21 @@ private ImmutableArray<byte> EmitDeterministic(string source, Platform platform,
return
compilation
.
EmitToArray
(
EmitOptions
.
Default
.
WithDebugInformationFormat
(
pdbFormat
),
pdbStream
:
new
MemoryStream
());
}
[
Fact
,
WorkItem
(
4578
,
"https://github.com/dotnet/roslyn/issues/4578"
)]
public
void
BanVersionWildcards
()
{
string
source
=
@"[assembly: System.Reflection.AssemblyVersion(""10101.0.*"")] public class C {}"
;
var
compilationDeterministic
=
CreateCompilation
(
source
,
assemblyName
:
"DeterminismTest"
,
references
:
new
[]
{
MscorlibRef
},
parseOptions
:
TestOptions
.
Regular
.
WithFeature
(
"deterministic"
,
"true"
));
var
compilationNonDeterministic
=
CreateCompilation
(
source
,
assemblyName
:
"DeterminismTest"
,
references
:
new
[]
{
MscorlibRef
});
var
resultDeterministic
=
compilationDeterministic
.
Emit
(
Stream
.
Null
,
Stream
.
Null
);
var
resultNonDeterministic
=
compilationNonDeterministic
.
Emit
(
Stream
.
Null
,
Stream
.
Null
);
Assert
.
False
(
resultDeterministic
.
Success
);
Assert
.
True
(
resultNonDeterministic
.
Success
);
}
[
Fact
,
WorkItem
(
372
,
"https://github.com/dotnet/roslyn/issues/372"
)]
public
void
Simple
()
{
...
...
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceAssemblySymbol.vb
浏览文件 @
af3c6740
...
...
@@ -998,7 +998,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
ElseIf
attrData
.
IsTargetAttribute
(
Me
,
AttributeDescription
.
AssemblyVersionAttribute
)
Then
Dim
verString
=
DirectCast
(
attrData
.
CommonConstructorArguments
(
0
).
Value
,
String
)
Dim
version
As
Version
=
Nothing
If
Not
VersionHelper
.
TryParseAssemblyVersion
(
verString
,
allowWildcard
:
=
True
,
version
:
=
version
)
Then
If
Not
VersionHelper
.
TryParseAssemblyVersion
(
verString
,
allowWildcard
:
=
Not
_compilation
.
IsEmitDeterministic
,
version
:
=
version
)
Then
arguments
.
Diagnostics
.
Add
(
ERRID
.
ERR_InvalidVersionFormat
,
GetAssemblyAttributeFirstArgumentLocation
(
arguments
.
AttributeSyntaxOpt
))
End
If
arguments
.
GetOrCreateData
(
Of
CommonAssemblyWellKnownAttributeData
)().
AssemblyVersionAttributeSetting
=
version
...
...
src/Compilers/VisualBasic/Test/Emit/Emit/DeterministicTests.vb
浏览文件 @
af3c6740
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports
System
Imports
System.IO
Imports
System.Collections.Generic
Imports
System.Collections.Immutable
Imports
System.Threading
...
...
@@ -25,6 +26,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Emit
Return
compilation
.
EmitToArray
()
End
Function
<
Fact
>
Public
Sub
BanVersionWildcards
()
Dim
source
=
"<assembly: System.Reflection.AssemblyVersion(
""
10101.0.*
""
)>
Class C
Shared Sub Main()
End Sub
End Class"
Dim
compilationDeterministic
=
CreateCompilationWithMscorlib
({
source
},
assemblyName
:
=
"DeterminismTest"
,
parseOptions
:
=
TestOptions
.
Regular
.
WithFeature
(
"deterministic"
,
"true"
))
Dim
compilationNonDeterministic
=
CreateCompilationWithMscorlib
({
source
},
assemblyName
:
=
"DeterminismTest"
)
Dim
resultDeterministic
=
compilationDeterministic
.
Emit
(
Stream
.
Null
,
Stream
.
Null
)
Dim
resultNonDeterministic
=
compilationNonDeterministic
.
Emit
(
Stream
.
Null
,
Stream
.
Null
)
Assert
.
False
(
resultDeterministic
.
Success
)
Assert
.
True
(
resultNonDeterministic
.
Success
)
End
Sub
<
Fact
>
Public
Sub
CompareAllBytesEmitted_Release
()
Dim
source
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录