-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeRef.FromDllFile overload with Type
- Loading branch information
1 parent
e1eb1a5
commit 1838f56
Showing
6 changed files
with
173 additions
and
49 deletions.
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
91 changes: 91 additions & 0 deletions
91
src/InlineIL.Tests.InvalidAssemblyToProcess/TypeRefTestCases.Injected.cs
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using InlineIL.Tests.InjectedAssembly; | ||
using static InlineIL.IL.Emit; | ||
|
||
namespace InlineIL.Tests.InvalidAssemblyToProcess; | ||
|
||
#pragma warning disable CS0618 | ||
|
||
public partial class TypeRefTestCases | ||
{ | ||
private const string _injectedAltAssemblyPath = "InjectedDllDir/InlineIL.Tests.InjectedAssembly.Alternative.dll"; | ||
|
||
public void UseMethodsFromDifferentVersionsOfDll() | ||
{ | ||
// Use referenced DLL | ||
InjectedType.AddInt32(40, 2); | ||
|
||
// Use alternative version of the referenced DLL | ||
Ldc_I4(40); | ||
Ldc_I4_2(); | ||
|
||
Call( | ||
MethodRef.Method( | ||
TypeRef.FromDllFile(_injectedAltAssemblyPath, "InlineIL.Tests.InjectedAssembly.InjectedType"), | ||
"MultiplyInt32" | ||
) | ||
); | ||
|
||
Pop(); | ||
} | ||
|
||
public void UseMethodsFromDifferentVersionsOfDllUsingTypeReference() | ||
{ | ||
// Use referenced DLL | ||
InjectedType.AddInt32(40, 2); | ||
|
||
// Use alternative version of the referenced DLL | ||
Ldc_I4(40); | ||
Ldc_I4_2(); | ||
|
||
Call( | ||
MethodRef.Method( | ||
TypeRef.FromDllFile(_injectedAltAssemblyPath, typeof(InjectedType)), | ||
"MultiplyInt32" | ||
) | ||
); | ||
|
||
Pop(); | ||
} | ||
|
||
public void InvalidInjectedDllFile() | ||
{ | ||
Ldtoken( | ||
TypeRef.FromDllFile("InjectedDllDir/DoesNotExist.dll", "SomeType") | ||
); | ||
} | ||
|
||
public void InvalidInjectedTypeName() | ||
{ | ||
Ldtoken( | ||
TypeRef.FromDllFile(_injectedAltAssemblyPath, "DoesNotExist") | ||
); | ||
} | ||
|
||
public void InvalidInjectedTypeSpec() | ||
{ | ||
Ldtoken( | ||
TypeRef.FromDllFile(_injectedAltAssemblyPath, typeof(InjectedType[])) | ||
); | ||
} | ||
|
||
public void InvalidInjectedTypeSpec2() | ||
{ | ||
Ldtoken( | ||
TypeRef.FromDllFile(_injectedAltAssemblyPath, typeof(InjectedType).MakeByRefType()) | ||
); | ||
} | ||
|
||
public void InvalidInjectedFnPtr() | ||
{ | ||
Ldtoken( | ||
TypeRef.FromDllFile(_injectedAltAssemblyPath, typeof(delegate*<int, void>)) | ||
); | ||
} | ||
|
||
public void InvalidInjectedGenericParam<T>() | ||
{ | ||
Ldtoken( | ||
TypeRef.FromDllFile(_injectedAltAssemblyPath, typeof(T)) | ||
); | ||
} | ||
} |
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
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