This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 509
[ILVerify] Add additional tests for delegate assignment/return #5027
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,68 @@ | |
} | ||
} | ||
|
||
// Type containing test methods for delegate-assignment | ||
.class public auto ansi beforefieldinit TestMethodsType | ||
extends [System.Runtime]System.Object | ||
{ | ||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
ldarg.0 | ||
call instance void [System.Runtime]System.Object::.ctor() | ||
ret | ||
} | ||
|
||
.method public hidebysig static uint8 ByteReturnMethod() cil managed | ||
{ | ||
ldc.i4.0 | ||
ret | ||
} | ||
|
||
.method public hidebysig static valuetype ByteEnum ByteEnumReturnMethod() cil managed | ||
{ | ||
ldc.i4.0 | ||
box ByteEnum | ||
ret | ||
} | ||
|
||
.method public hidebysig static int32 IntReturnMethod() cil managed | ||
{ | ||
ldc.i4.0 | ||
ret | ||
} | ||
|
||
.method public hidebysig static string StringReturnMethod() cil managed | ||
{ | ||
ldnull | ||
ret | ||
} | ||
|
||
.method public hidebysig static object ObjectReturnMethod() cil managed | ||
{ | ||
ldnull | ||
ret | ||
} | ||
|
||
.method public hidebysig static void ByteParamMethod(uint8 param) cil managed | ||
{ | ||
ret | ||
} | ||
|
||
.method public hidebysig static void ByteEnumParamMethod(valuetype ByteEnum param) cil managed | ||
{ | ||
ret | ||
} | ||
} | ||
|
||
.class public auto ansi sealed ByteEnum | ||
extends [System.Runtime]System.Enum | ||
{ | ||
.field public specialname rtspecialname uint8 value__ | ||
.field public static literal valuetype ByteEnum A = uint8(0) | ||
.field public static literal valuetype ByteEnum B = uint8(0) | ||
} | ||
|
||
.class public auto ansi beforefieldinit FtnTestsType | ||
extends [System.Runtime]System.Object | ||
{ | ||
|
@@ -363,4 +425,74 @@ | |
callvirt instance void [System.Runtime]System.Action::Invoke() | ||
ret | ||
} | ||
|
||
// creating a Func<object> from a string return method is valid | ||
.method private hidebysig instance void ObjectFuncFromStringMethod_Valid() cil managed | ||
{ | ||
ldnull | ||
ldftn string TestMethodsType::StringReturnMethod() | ||
newobj instance void class [System.Runtime]System.Func`1<object>::.ctor(object, native int) | ||
pop | ||
ret | ||
} | ||
|
||
// creating a Func<string> from a object return method is invalid | ||
.method private hidebysig instance void StringFuncFromObjectMethod_Invalid_DelegateCtor() cil managed | ||
{ | ||
ldnull | ||
ldftn object TestMethodsType::ObjectReturnMethod() | ||
newobj instance void class [System.Runtime]System.Func`1<string>::.ctor(object, native int) | ||
pop | ||
ret | ||
} | ||
|
||
// creating a Func<byte> from an int return method is invalid | ||
.method private hidebysig instance void ByteFuncFromIntMethod_Invalid_DelegateCtor() cil managed | ||
{ | ||
ldnull | ||
ldftn int32 TestMethodsType::IntReturnMethod() | ||
newobj instance void class [System.Runtime]System.Func`1<uint8>::.ctor(object, native int) | ||
pop | ||
ret | ||
} | ||
|
||
// creating a Func<int> from a byte return method is invalid | ||
.method private hidebysig instance void IntFuncFromByteMethod_Invalid_DelegateCtor() cil managed | ||
{ | ||
ldnull | ||
ldftn uint8 TestMethodsType::ByteReturnMethod() | ||
newobj instance void class [System.Runtime]System.Func`1<int32>::.ctor(object, native int) | ||
pop | ||
ret | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
|
||
// creating a Func<byte> from a ByteEnum return method is invalid | ||
.method private hidebysig instance void IntFuncFromByteEnumMethod_Invalid_DelegateCtor() cil managed | ||
{ | ||
ldnull | ||
ldftn valuetype ByteEnum TestMethodsType::ByteEnumReturnMethod() | ||
newobj instance void class [System.Runtime]System.Func`1<int32>::.ctor(object, native int) | ||
pop | ||
ret | ||
} | ||
|
||
// creating an Action<int> from a method with byte parameter is invalid | ||
.method private hidebysig instance void IntActionFromByteMethod_Invalid_DelegateCtor() cil managed | ||
{ | ||
ldnull | ||
ldftn void TestMethodsType::ByteParamMethod(uint8) | ||
newobj instance void class [System.Runtime]System.Action`1<int32>::.ctor(object, native int) | ||
pop | ||
ret | ||
} | ||
|
||
// creating an Action<byte> from a method with an enum (with underlying type byte) as parameter is invalid | ||
.method private hidebysig instance void ByteActionFromByteEnum_Invalid_DelegateCtor() cil managed | ||
{ | ||
ldnull | ||
ldftn void TestMethodsType::ByteEnumParamMethod(valuetype ByteEnum) | ||
newobj instance void class [System.Runtime]System.Action`1<uint8>::.ctor(object, native int) | ||
pop | ||
ret | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also cover arguments and enums here?
Action<int8>
toAction<int32>
Action<int8 enum>
toAction<int8>