Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
105a1300
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,发现更多精彩内容 >>
提交
105a1300
编写于
3月 21, 2014
作者:
A
AlekseyTs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stop using Compilationoptions.Features to enable test-only code paths. (changeset 1211317)
上级
92c67f82
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
27 deletion
+62
-27
Src/Compilers/CSharp/Source/Compilation/CSharpCompilation.cs
Src/Compilers/CSharp/Source/Compilation/CSharpCompilation.cs
+40
-0
Src/Compilers/CSharp/Source/Symbols/Compilation_WellKnownMembers.cs
...ers/CSharp/Source/Symbols/Compilation_WellKnownMembers.cs
+1
-2
Src/Compilers/CSharp/Source/Symbols/Source/SourceAssemblySymbol.cs
...lers/CSharp/Source/Symbols/Source/SourceAssemblySymbol.cs
+1
-2
Src/Compilers/CSharp/Test/Symbol/Symbols/MissingSpecialMember.cs
...pilers/CSharp/Test/Symbol/Symbols/MissingSpecialMember.cs
+20
-23
未找到文件。
Src/Compilers/CSharp/Source/Compilation/CSharpCompilation.cs
浏览文件 @
105a1300
...
...
@@ -57,6 +57,11 @@ public sealed partial class CSharpCompilation : Compilation
// NOTE: Presently, we do not cache the per-tree diagnostics.
private
ImmutableArray
<
Diagnostic
>
lazyClsComplianceDiagnostics
;
/// <summary>
/// Used for test purposes only to immulate missing members.
/// </summary>
private
SmallDictionary
<
int
,
bool
>
lazyMakeMemberMissingMap
;
private
Conversions
conversions
;
internal
Conversions
Conversions
{
...
...
@@ -3035,5 +3040,40 @@ internal override int CompareSourceLocations(Location loc1, Location loc2)
}
#
endregion
internal
void
MakeMemberMissing
(
WellKnownMember
member
)
{
MakeMemberMissing
((
int
)
member
);
}
internal
void
MakeMemberMissing
(
SpecialMember
member
)
{
MakeMemberMissing
(-(
int
)
member
-
1
);
}
internal
bool
IsMemberMissing
(
WellKnownMember
member
)
{
return
IsMemberMissing
((
int
)
member
);
}
internal
bool
IsMemberMissing
(
SpecialMember
member
)
{
return
IsMemberMissing
(-(
int
)
member
-
1
);
}
private
void
MakeMemberMissing
(
int
member
)
{
if
(
lazyMakeMemberMissingMap
==
null
)
{
lazyMakeMemberMissingMap
=
new
SmallDictionary
<
int
,
bool
>();
}
lazyMakeMemberMissingMap
[
member
]
=
true
;
}
private
bool
IsMemberMissing
(
int
member
)
{
return
lazyMakeMemberMissingMap
!=
null
&&
lazyMakeMemberMissingMap
.
ContainsKey
(
member
);
}
}
}
Src/Compilers/CSharp/Source/Symbols/Compilation_WellKnownMembers.cs
浏览文件 @
105a1300
...
...
@@ -44,8 +44,7 @@ internal Symbol GetWellKnownTypeMember(WellKnownMember member)
Debug
.
Assert
(
member
>=
0
&&
member
<
WellKnownMember
.
Count
);
// if this member is to be forced "missing", return null
var
makeMissingMember
=
this
.
Feature
(
"MakeMissingMember"
);
if
(
makeMissingMember
!=
null
&&
makeMissingMember
==
member
.
ToString
())
return
null
;
if
(
IsMemberMissing
(
member
))
return
null
;
if
(
lazyWellKnownTypeMembers
==
null
||
ReferenceEquals
(
lazyWellKnownTypeMembers
[(
int
)
member
],
ErrorTypeSymbol
.
UnknownResultType
))
{
...
...
Src/Compilers/CSharp/Source/Symbols/Source/SourceAssemblySymbol.cs
浏览文件 @
105a1300
...
...
@@ -185,8 +185,7 @@ public override AssemblyIdentity Identity
internal
override
Symbol
GetSpecialTypeMember
(
SpecialMember
member
)
{
var
makeMissingMember
=
compilation
.
Feature
(
"MakeMissingMember"
);
return
makeMissingMember
!=
null
&&
makeMissingMember
==
member
.
ToString
()
?
null
:
base
.
GetSpecialTypeMember
(
member
);
return
compilation
.
IsMemberMissing
(
member
)
?
null
:
base
.
GetSpecialTypeMember
(
member
);
}
private
string
GetWellKnownAttributeDataStringField
(
Func
<
CommonAssemblyWellKnownAttributeData
,
string
>
fieldGetter
,
string
missingValue
=
null
)
...
...
Src/Compilers/CSharp/Test/Symbol/Symbols/MissingSpecialMember.cs
浏览文件 @
105a1300
...
...
@@ -11,25 +11,6 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
public
class
MissingSpecialMember
:
CSharpTestBase
{
private
CSharpCompilationOptions
WithMissingMember
(
WellKnownMember
wm
)
{
return
WithMissingMember
(
wm
.
ToString
());
}
private
CSharpCompilationOptions
WithMissingMember
(
SpecialMember
sm
)
{
return
WithMissingMember
(
sm
.
ToString
());
}
private
CSharpCompilationOptions
WithMissingMember
(
string
memberKey
)
{
var
compOptions
=
TestOptions
.
Dll
.
WithOptimizations
(
true
).
WithFeatures
(
new
[]
{
"MakeMissingMember:"
+
memberKey
});
if
(
System
.
Diagnostics
.
Debugger
.
IsAttached
)
{
// Using single-threaded build if debugger attached, to simplify debugging.
compOptions
=
compOptions
.
WithConcurrentBuild
(
false
);
}
return
compOptions
;
}
[
Fact
]
public
void
Missing_System_Collections_Generic_IEnumerable_T__GetEnumerator
()
{
...
...
@@ -48,7 +29,11 @@ public IEnumerable<int> M()
yield return 1;
}
}"
;
CreateCompilationWithMscorlib
(
source
,
compOptions
:
WithMissingMember
(
SpecialMember
.
System_Collections_Generic_IEnumerable_T__GetEnumerator
)).
VerifyEmitDiagnostics
(
var
comp
=
CreateCompilationWithMscorlib
(
source
,
compOptions
:
TestOptions
.
Dll
.
WithOptimizations
(
true
));
comp
.
MakeMemberMissing
(
SpecialMember
.
System_Collections_Generic_IEnumerable_T__GetEnumerator
);
comp
.
VerifyEmitDiagnostics
(
// (10,5): error CS0656: Missing compiler required member 'System.Collections.Generic.IEnumerable`1.GetEnumerator'
// {
Diagnostic
(
ErrorCode
.
ERR_MissingPredefinedMember
,
@"{
...
...
@@ -76,7 +61,11 @@ public IEnumerable<int> M()
yield return 1;
}
}"
;
CreateCompilationWithMscorlib
(
source
,
compOptions
:
WithMissingMember
(
SpecialMember
.
System_IDisposable__Dispose
)).
VerifyEmitDiagnostics
(
var
comp
=
CreateCompilationWithMscorlib
(
source
,
compOptions
:
TestOptions
.
Dll
.
WithOptimizations
(
true
));
comp
.
MakeMemberMissing
(
SpecialMember
.
System_IDisposable__Dispose
);
comp
.
VerifyEmitDiagnostics
(
// (10,5): error CS0656: Missing compiler required member 'System.IDisposable.Dispose'
// {
Diagnostic
(
ErrorCode
.
ERR_MissingPredefinedMember
,
@"{
...
...
@@ -104,7 +93,11 @@ public IEnumerable<int> M()
yield return 1;
}
}"
;
CreateCompilationWithMscorlib
(
source
,
compOptions
:
WithMissingMember
(
WellKnownMember
.
System_Diagnostics_DebuggerHiddenAttribute__ctor
)).
VerifyEmitDiagnostics
(
var
comp
=
CreateCompilationWithMscorlib
(
source
,
compOptions
:
TestOptions
.
Dll
.
WithOptimizations
(
true
));
comp
.
MakeMemberMissing
(
WellKnownMember
.
System_Diagnostics_DebuggerHiddenAttribute__ctor
);
comp
.
VerifyEmitDiagnostics
(
// the DebuggerHidden attribute is optional.
);
}
...
...
@@ -123,7 +116,11 @@ public static void Main(string[] args)
public static void Extension(this string x) {}
}"
;
CreateCompilationWithMscorlib
(
source
,
compOptions
:
WithMissingMember
(
WellKnownMember
.
System_Diagnostics_DebuggerHiddenAttribute__ctor
)).
VerifyEmitDiagnostics
(
var
comp
=
CreateCompilationWithMscorlib
(
source
,
compOptions
:
TestOptions
.
Dll
.
WithOptimizations
(
true
));
comp
.
MakeMemberMissing
(
WellKnownMember
.
System_Diagnostics_DebuggerHiddenAttribute__ctor
);
comp
.
VerifyEmitDiagnostics
(
// (9,34): error CS1110: Cannot define a new extension method because the compiler required type 'System.Runtime.CompilerServices.ExtensionAttribute' cannot be found. Are you missing a reference to System.Core.dll?
// public static void Extension(this string x) {}
Diagnostic
(
ErrorCode
.
ERR_ExtensionAttrNotFound
,
"this"
).
WithArguments
(
"System.Runtime.CompilerServices.ExtensionAttribute"
).
WithLocation
(
9
,
34
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录