Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
0195188e
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,发现更多精彩内容 >>
提交
0195188e
编写于
5月 31, 2016
作者:
V
VSadov
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11629 from VSadov/deprecatedWithString
Port two Update3 changes to stabilization.
上级
62243e23
a99616b7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
625 addition
and
12 deletion
+625
-12
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs
...est/Emit/Attributes/AttributeTests_WellKnownAttributes.cs
+90
-1
src/Compilers/Core/Portable/MetadataReader/PEModule.cs
src/Compilers/Core/Portable/MetadataReader/PEModule.cs
+1
-0
src/Compilers/Core/Portable/Symbols/Attributes/AttributeDescription.cs
.../Core/Portable/Symbols/Attributes/AttributeDescription.cs
+3
-1
src/Compilers/Core/Portable/Symbols/Attributes/CommonAttributeData.cs
...s/Core/Portable/Symbols/Attributes/CommonAttributeData.cs
+1
-0
src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.vb
...rtable/Lowering/LocalRewriter/LocalRewriter_Conversion.vb
+85
-10
src/Compilers/VisualBasic/Test/Emit/ExpressionTrees/CodeGenExprLambda.vb
...isualBasic/Test/Emit/ExpressionTrees/CodeGenExprLambda.vb
+445
-0
未找到文件。
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.cs
浏览文件 @
0195188e
...
...
@@ -7702,7 +7702,7 @@ int P1
}
[
Fact
]
public
void
TestDeprecatedAttribute1
()
public
void
TestDeprecatedAttribute
TH
1
()
{
var
source1
=
@"
using System;
...
...
@@ -7717,6 +7717,8 @@ public DeprecatedAttribute(System.String message, DeprecationType type, System.U
{
}
// this signature is only used in TH1 metadata
// see: https://github.com/dotnet/roslyn/issues/10630
public DeprecatedAttribute(System.String message, DeprecationType type, System.UInt32 version, Type contract)
{
}
...
...
@@ -7760,6 +7762,93 @@ static void Main(string[] args)
}
"
;
var
compilation2
=
CreateCompilationWithMscorlibAndSystemCore
(
source2
,
new
[]
{
compilation1
.
EmitToImageReference
()
});
compilation2
.
VerifyDiagnostics
(
// (8,13): warning CS0618: 'Test.Foo()' is obsolete: 'hello'
// Test.Foo();
Diagnostic
(
ErrorCode
.
WRN_DeprecatedSymbolStr
,
"Test.Foo()"
).
WithArguments
(
"Test.Foo()"
,
"hello"
).
WithLocation
(
8
,
13
),
// (9,13): warning CS0618: 'Test.Bar()' is obsolete: 'hi'
// Test.Bar();
Diagnostic
(
ErrorCode
.
WRN_DeprecatedSymbolStr
,
"Test.Bar()"
).
WithArguments
(
"Test.Bar()"
,
"hi"
).
WithLocation
(
9
,
13
)
);
var
compilation3
=
CreateCompilationWithMscorlibAndSystemCore
(
source2
,
new
[]
{
new
CSharpCompilationReference
(
compilation1
)
});
compilation3
.
VerifyDiagnostics
(
// (8,13): warning CS0618: 'Test.Foo()' is obsolete: 'hello'
// Test.Foo();
Diagnostic
(
ErrorCode
.
WRN_DeprecatedSymbolStr
,
"Test.Foo()"
).
WithArguments
(
"Test.Foo()"
,
"hello"
).
WithLocation
(
8
,
13
),
// (9,13): warning CS0618: 'Test.Bar()' is obsolete: 'hi'
// Test.Bar();
Diagnostic
(
ErrorCode
.
WRN_DeprecatedSymbolStr
,
"Test.Bar()"
).
WithArguments
(
"Test.Bar()"
,
"hi"
).
WithLocation
(
9
,
13
)
);
}
[
Fact
]
public
void
TestDeprecatedAttributeTH2
()
{
var
source1
=
@"
using System;
using Windows.Foundation.Metadata;
namespace Windows.Foundation.Metadata
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = true)]
public sealed class DeprecatedAttribute : Attribute
{
public DeprecatedAttribute(System.String message, DeprecationType type, System.UInt32 version)
{
}
// this signature is only used in TH2 metadata and onwards
// see: https://github.com/dotnet/roslyn/issues/10630
public DeprecatedAttribute(System.String message, DeprecationType type, System.UInt32 version, String contract)
{
}
}
public enum DeprecationType
{
Deprecate = 0,
Remove = 1
}
}
public class Test
{
[Deprecated(""hello"", DeprecationType.Deprecate, 1, ""hello"")]
public static void Foo()
{
}
[Deprecated(""hi"", DeprecationType.Deprecate, 1)]
public static void Bar()
{
}
}
"
;
var
compilation1
=
CreateCompilationWithMscorlibAndSystemCore
(
source1
);
var
source2
=
@"
namespace ConsoleApplication74
{
class Program
{
static void Main(string[] args)
{
Test.Foo();
Test.Bar();
}
}
}
"
;
var
compilation2
=
CreateCompilationWithMscorlibAndSystemCore
(
source2
,
new
[]
{
compilation1
.
EmitToImageReference
()
});
...
...
src/Compilers/Core/Portable/MetadataReader/PEModule.cs
浏览文件 @
0195188e
...
...
@@ -1154,6 +1154,7 @@ private bool TryExtractDeprecatedDataFromAttribute(AttributeInfo attributeInfo,
case
0
:
// DeprecatedAttribute(String, DeprecationType, UInt32)
case
1
:
// DeprecatedAttribute(String, DeprecationType, UInt32, Platform)
case
2
:
// DeprecatedAttribute(String, DeprecationType, UInt32, Type)
case
3
:
// DeprecatedAttribute(String, DeprecationType, UInt32, String)
return
TryExtractValueFromAttribute
(
attributeInfo
.
Handle
,
out
obsoleteData
,
s_attributeDeprecatedDataExtractor
);
default
:
...
...
src/Compilers/Core/Portable/Symbols/Attributes/AttributeDescription.cs
浏览文件 @
0195188e
...
...
@@ -189,6 +189,7 @@ static AttributeDescription()
private
static
readonly
byte
[]
s_signature_HasThis_Void_String_DeprecationType_UInt32
=
new
byte
[]
{
(
byte
)
SignatureAttributes
.
Instance
,
3
,
Void
,
String
,
TypeHandle
,
(
byte
)
TypeHandleTarget
.
DeprecationType
,
UInt32
};
private
static
readonly
byte
[]
s_signature_HasThis_Void_String_DeprecationType_UInt32_Platform
=
new
byte
[]
{
(
byte
)
SignatureAttributes
.
Instance
,
4
,
Void
,
String
,
TypeHandle
,
(
byte
)
TypeHandleTarget
.
DeprecationType
,
UInt32
,
TypeHandle
,
(
byte
)
TypeHandleTarget
.
Platform
};
private
static
readonly
byte
[]
s_signature_HasThis_Void_String_DeprecationType_UInt32_Type
=
new
byte
[]
{
(
byte
)
SignatureAttributes
.
Instance
,
4
,
Void
,
String
,
TypeHandle
,
(
byte
)
TypeHandleTarget
.
DeprecationType
,
UInt32
,
TypeHandle
,
(
byte
)
TypeHandleTarget
.
SystemType
};
private
static
readonly
byte
[]
s_signature_HasThis_Void_String_DeprecationType_UInt32_String
=
new
byte
[]
{
(
byte
)
SignatureAttributes
.
Instance
,
4
,
Void
,
String
,
TypeHandle
,
(
byte
)
TypeHandleTarget
.
DeprecationType
,
UInt32
,
String
};
// TODO: We should reuse the byte arrays for well-known attributes with same signatures.
...
...
@@ -386,7 +387,8 @@ static AttributeDescription()
{
s_signature_HasThis_Void_String_DeprecationType_UInt32
,
s_signature_HasThis_Void_String_DeprecationType_UInt32_Platform
,
s_signature_HasThis_Void_String_DeprecationType_UInt32_Type
s_signature_HasThis_Void_String_DeprecationType_UInt32_Type
,
s_signature_HasThis_Void_String_DeprecationType_UInt32_String
,
};
// early decoded attributes:
...
...
src/Compilers/Core/Portable/Symbols/Attributes/CommonAttributeData.cs
浏览文件 @
0195188e
...
...
@@ -239,6 +239,7 @@ internal ObsoleteAttributeData DecodeDeprecatedAttribute()
{
// DeprecatedAttribute(String, DeprecationType, UInt32)
// DeprecatedAttribute(String, DeprecationType, UInt32, Platform)
// DeprecatedAttribute(String, DeprecationType, UInt32, String)
message
=
(
string
)
args
[
0
].
Value
;
isError
=
((
int
)
args
[
1
].
Value
==
1
);
...
...
src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.vb
浏览文件 @
0195188e
...
...
@@ -96,10 +96,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
If
If
node
.
RelaxationLambdaOpt
IsNot
Nothing
Then
returnValue
=
node
.
Update
(
VisitExpressionNode
(
node
.
RelaxationLambdaOpt
),
node
.
ConversionKind
,
node
.
Checked
,
node
.
ExplicitCastInCode
,
node
.
ConstantValueOpt
,
node
.
ConstructorOpt
,
relaxationLambdaOpt
:
=
Nothing
,
relaxationReceiverPlaceholderOpt
:
=
Nothing
,
type
:
=
node
.
Type
)
returnValue
=
RewriteLambdaRelaxationConversion
(
node
)
ElseIf
node
.
ConversionKind
=
ConversionKind
.
InterpolatedString
Then
returnValue
=
RewriteInterpolatedStringConversion
(
node
)
...
...
@@ -115,6 +112,88 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return
returnValue
End
Function
Private
Function
RewriteLambdaRelaxationConversion
(
node
As
BoundConversion
)
As
BoundNode
Dim
returnValue
As
BoundNode
If
_inExpressionLambda
AndAlso
NoParameterRelaxation
(
node
.
Operand
,
node
.
RelaxationLambdaOpt
.
LambdaSymbol
)
Then
' COMPAT: skip relaxation in this case. ET can drop the return value of the inner lambda.
returnValue
=
MyBase
.
VisitConversion
(
node
.
Update
(
node
.
Operand
,
node
.
ConversionKind
,
node
.
Checked
,
node
.
ExplicitCastInCode
,
node
.
ConstantValueOpt
,
node
.
ConstructorOpt
,
relaxationLambdaOpt
:
=
Nothing
,
relaxationReceiverPlaceholderOpt
:
=
Nothing
,
type
:
=
node
.
Type
))
returnValue
=
TransformRewrittenConversion
(
DirectCast
(
returnValue
,
BoundConversion
))
Else
returnValue
=
node
.
Update
(
VisitExpressionNode
(
node
.
RelaxationLambdaOpt
),
node
.
ConversionKind
,
node
.
Checked
,
node
.
ExplicitCastInCode
,
node
.
ConstantValueOpt
,
node
.
ConstructorOpt
,
relaxationLambdaOpt
:
=
Nothing
,
relaxationReceiverPlaceholderOpt
:
=
Nothing
,
type
:
=
node
.
Type
)
End
If
Return
returnValue
End
Function
Private
Function
RewriteLambdaRelaxationConversion
(
node
As
BoundDirectCast
)
As
BoundNode
Dim
returnValue
As
BoundNode
If
_inExpressionLambda
AndAlso
NoParameterRelaxation
(
node
.
Operand
,
node
.
RelaxationLambdaOpt
.
LambdaSymbol
)
Then
' COMPAT: skip relaxation in this case. ET can drop the return value of the inner lambda.
returnValue
=
MyBase
.
VisitDirectCast
(
node
.
Update
(
node
.
Operand
,
node
.
ConversionKind
,
node
.
SuppressVirtualCalls
,
node
.
ConstantValueOpt
,
relaxationLambdaOpt
:
=
Nothing
,
type
:
=
node
.
Type
))
Else
returnValue
=
node
.
Update
(
VisitExpressionNode
(
node
.
RelaxationLambdaOpt
),
node
.
ConversionKind
,
node
.
SuppressVirtualCalls
,
node
.
ConstantValueOpt
,
relaxationLambdaOpt
:
=
Nothing
,
type
:
=
node
.
Type
)
End
If
Return
returnValue
End
Function
Private
Function
RewriteLambdaRelaxationConversion
(
node
As
BoundTryCast
)
As
BoundNode
Dim
returnValue
As
BoundNode
If
_inExpressionLambda
AndAlso
NoParameterRelaxation
(
node
.
Operand
,
node
.
RelaxationLambdaOpt
.
LambdaSymbol
)
Then
' COMPAT: skip relaxation in this case. ET can drop the return value of the inner lambda.
returnValue
=
MyBase
.
VisitTryCast
(
node
.
Update
(
node
.
Operand
,
node
.
ConversionKind
,
node
.
ConstantValueOpt
,
relaxationLambdaOpt
:
=
Nothing
,
type
:
=
node
.
Type
))
Else
returnValue
=
node
.
Update
(
VisitExpressionNode
(
node
.
RelaxationLambdaOpt
),
node
.
ConversionKind
,
node
.
ConstantValueOpt
,
relaxationLambdaOpt
:
=
Nothing
,
type
:
=
node
.
Type
)
End
If
Return
returnValue
End
Function
Private
Shared
Function
NoParameterRelaxation
(
from
As
BoundExpression
,
toLambda
As
LambdaSymbol
)
As
Boolean
Dim
fromLambda
As
LambdaSymbol
=
TryCast
(
from
,
BoundLambda
)
?
.
LambdaSymbol
' are we are relaxing for the purpose of dropping return?
Return
fromLambda
IsNot
Nothing
AndAlso
Not
fromLambda
.
IsSub
AndAlso
toLambda
.
IsSub
AndAlso
MethodSignatureComparer
.
HaveSameParameterTypes
(
fromLambda
.
Parameters
,
Nothing
,
toLambda
.
Parameters
,
Nothing
,
considerByRef
:
=
True
,
considerCustomModifiers
:
=
False
)
End
Function
' Rewrite Anonymous Delegate conversion into a delegate creation
Private
Function
RewriteAnonymousDelegateConversion
(
node
As
BoundConversion
)
As
BoundNode
Debug
.
Assert
(
Not
Conversions
.
IsIdentityConversion
(
node
.
ConversionKind
))
...
...
@@ -1198,9 +1277,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If
node
.
RelaxationLambdaOpt
Is
Nothing
Then
returnValue
=
MyBase
.
VisitDirectCast
(
node
)
Else
returnValue
=
node
.
Update
(
VisitExpressionNode
(
node
.
RelaxationLambdaOpt
),
node
.
ConversionKind
,
node
.
SuppressVirtualCalls
,
node
.
ConstantValueOpt
,
relaxationLambdaOpt
:
=
Nothing
,
type
:
=
node
.
Type
)
returnValue
=
RewriteLambdaRelaxationConversion
(
node
)
End
If
_inExpressionLambda
=
wasInExpressionlambda
...
...
@@ -1250,9 +1327,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
If
Else
returnValue
=
node
.
Update
(
VisitExpressionNode
(
node
.
RelaxationLambdaOpt
),
node
.
ConversionKind
,
node
.
ConstantValueOpt
,
relaxationLambdaOpt
:
=
Nothing
,
type
:
=
node
.
Type
)
returnValue
=
RewriteLambdaRelaxationConversion
(
node
)
End
If
_inExpressionLambda
=
wasInExpressionlambda
...
...
src/Compilers/VisualBasic/Test/Emit/ExpressionTrees/CodeGenExprLambda.vb
浏览文件 @
0195188e
...
...
@@ -2807,6 +2807,451 @@ Lambda(
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation01
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
C0
)
End
Sub
End
Module
Class
C0
Public
Function
Process
()
As
Boolean
Return
False
End
Function
Public
Sub
ProcessSub
()
End
Sub
End
Class
Class
C1
(
Of
T
As
{
New
,
C0
})
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
Sub
(
c
)
c
.
ProcessSub
())
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
Function
(
c
)
c
.
Process
)
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
T
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
new
T
())
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
c
=>
c
.
ProcessSub
()
c
=>
c
.
Process
()
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation02
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
End
Sub
End
Module
Class
C0
Public
Shared
Function
Process
(
x
As
Integer
)
As
Boolean
Return
False
End
Function
Public
Shared
Sub
ProcessSub
(
x
As
Integer
)
End
Sub
End
Class
Class
C1
(
Of
T
)
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
Sub
(
c
As
String
)
C0
.
ProcessSub
(
c
))
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
Function
(
c
)
C0
.
Process
(
c
))
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
String
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
1
)
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
c
=>
ProcessSub
(
ConvertChecked
(
c
))
c
=>
Process
(
ConvertChecked
(
c
))
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation03
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
End
Sub
End
Module
Class
C0
Public
Shared
Function
Process
()
As
Boolean
Return
False
End
Function
Public
Shared
Sub
ProcessSub
()
End
Sub
End
Class
Class
C1
(
Of
T
)
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
Sub
(
c
As
String
)
C0
.
ProcessSub
())
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
Function
(
c
As
String
)
C0
.
Process
())
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
String
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
"qq"
)
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
c
=>
ProcessSub
()
c
=>
Process
()
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation04
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
End
Sub
End
Module
Class
C0
Public
Shared
Function
Process
()
As
Boolean
Return
False
End
Function
Public
Shared
Sub
ProcessSub
()
End
Sub
End
Class
Class
C1
(
Of
T
)
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
Sub
()
C0
.
ProcessSub
())
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
Function
()
C0
.
Process
())
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
Integer
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
1
)
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
a0
=>
Invoke
(()
=>
ProcessSub
())
a0
=>
Invoke
(()
=>
Process
())
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation05
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
End
Sub
End
Module
Class
C0
Public
Shared
Function
Process
(
arg
As
Action
(
Of
Integer
))
As
Boolean
Return
False
End
Function
Public
Shared
Sub
ProcessSub
(
arg
As
Action
(
Of
Integer
))
End
Sub
End
Class
Class
C1
(
Of
T
)
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
Sub
(
t
As
Integer
)
C0
.
ProcessSub
(
Sub
(
tt
As
Integer
)
C0
.
ProcessSub
(
Nothing
)))
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
Function
(
t
As
Integer
)
C0
.
Process
(
Function
(
tt
As
Integer
)
C0
.
Process
(
Nothing
)))
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
Integer
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
Nothing
)
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
t
=>
ProcessSub
(
tt
=>
ProcessSub
(
null
))
t
=>
Process
(
tt
=>
Process
(
null
))
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation05ET
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
End
Sub
End
Module
Class
C0
Public
Shared
Function
Process
(
arg
As
Expression
(
Of
Action
(
Of
Integer
)))
As
Boolean
Return
False
End
Function
Public
Shared
Sub
ProcessSub
(
arg
As
Expression
(
Of
Action
(
Of
Integer
)))
End
Sub
End
Class
Class
C1
(
Of
T
)
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
Sub
(
t
As
Integer
)
C0
.
ProcessSub
(
Sub
(
tt
As
Integer
)
C0
.
ProcessSub
(
Nothing
)))
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
Function
(
t
As
Integer
)
C0
.
Process
(
Function
(
tt
As
Integer
)
C0
.
Process
(
Nothing
)))
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
Integer
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
Nothing
)
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
t
=>
ProcessSub
(
tt
=>
ProcessSub
(
null
))
t
=>
Process
(
tt
=>
Process
(
null
))
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation06
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
End
Sub
End
Module
Class
C0
Public
Shared
Function
Process
(
arg
As
Action
(
Of
Integer
))
As
Boolean
Return
False
End
Function
Public
Shared
Sub
ProcessSub
(
arg
As
Action
(
Of
Integer
))
End
Sub
End
Class
Class
C1
(
Of
T
)
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
DirectCast
(
Sub
(
t
As
Integer
)
C0
.
ProcessSub
(
Sub
(
tt
As
Integer
)
C0
.
ProcessSub
(
Nothing
)),
Expression
(
Of
Action
(
Of
Integer
))))
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
DirectCast
(
Function
(
t
As
Integer
)
C0
.
Process
(
Function
(
tt
As
Integer
)
C0
.
Process
(
Nothing
)),
Expression
(
Of
Action
(
Of
Integer
))))
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
Integer
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
Nothing
)
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
t
=>
ProcessSub
(
tt
=>
ProcessSub
(
null
))
t
=>
Process
(
tt
=>
Process
(
null
))
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation07
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
End
Sub
End
Module
Class
C0
Public
Shared
Function
Process
(
arg
As
Action
(
Of
Integer
))
As
Boolean
Return
False
End
Function
Public
Shared
Sub
ProcessSub
(
arg
As
Action
(
Of
Integer
))
End
Sub
End
Class
Class
C1
(
Of
T
)
Public
ProcessMethodSub
As
MethodInfo
=
RegisterMethod
(
TryCast
(
Sub
(
t
As
Integer
)
C0
.
ProcessSub
(
Sub
(
tt
As
Integer
)
C0
.
ProcessSub
(
Nothing
)),
Expression
(
Of
Action
(
Of
Integer
))))
Public
ProcessMethod
As
MethodInfo
=
RegisterMethod
(
TryCast
(
Function
(
t
As
Integer
)
C0
.
Process
(
Function
(
tt
As
Integer
)
C0
.
Process
(
Nothing
)),
Expression
(
Of
Action
(
Of
Integer
))))
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
(
Of
Integer
)))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()(
Nothing
)
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
t
=>
ProcessSub
(
tt
=>
ProcessSub
(
null
))
t
=>
Process
(
tt
=>
Process
(
null
))
]]
>
)
End
Sub
<
Fact
()
>
Public
Sub
Relaxation08
()
Dim
file
=
<
file
name
=
"expr.vb"
><
!
[
CDATA
[
Imports
System
Imports
System.Linq.Expressions
Imports
System.Reflection
Module
Module1
Sub
Main
()
Dim
o
As
New
C1
(
Of
String
)
o
.
Test
()
End
Sub
End
Module
Class
C1
(
Of
T
)
Sub
Test
()
Dim
anonymousDelegate
=
Function
(
x
As
Integer
)
x
RegisterMethod
(
Sub
()
M1
(
anonymousDelegate
))
End
Sub
Shared
Sub
M1
(
y
As
Action
(
Of
Integer
))
End
Sub
Public
Function
RegisterMethod
(
methodLambdaExpression
As
Expression
(
Of
Action
))
As
MethodInfo
System
.
Console
.
WriteLine
(
methodLambdaExpression
.
ToString
())
methodLambdaExpression
.
Compile
()()
Return
Nothing
End
Function
End
Class
]]
></
file
>
TestExpressionTrees
(
file
,
<
!
[
CDATA
[
()
=>
M1
(
a0
=>
Invoke
(
value
(
C1
`
1
+
_Closure$__1
-
0
[
System
.
String
]
).
$
VB
$
Local_anonymousDelegate
,
a0
))
]]
>
)
End
Sub
#End Region
#Region "Xml Literals"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录