-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add methods for resolving il2cpp definitions to their contexts
- Loading branch information
Showing
3 changed files
with
85 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Linq; | ||
|
||
namespace Cpp2IL.Core.Tests; | ||
|
||
public class MemberResolutionTests | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
Cpp2IlApi.ResetInternalState(); | ||
TestGameLoader.LoadSimple2019Game(); | ||
} | ||
|
||
[Test] | ||
public void TestMethodResolving() | ||
{ | ||
var appContext = Cpp2IlApi.CurrentAppContext; | ||
|
||
var methodContext = appContext!.AllTypes.SelectMany(t => t.Methods).First(m => m.Definition is not null); | ||
|
||
Assert.That(appContext.ResolveContextForMethod(methodContext.Definition), Is.EqualTo(methodContext)); | ||
} | ||
|
||
[Test] | ||
public void TestFieldResolving() | ||
{ | ||
var appContext = Cpp2IlApi.CurrentAppContext; | ||
|
||
var fieldContext = appContext!.AllTypes.SelectMany(t => t.Fields).First(f => f.BackingData?.Field is not null); | ||
|
||
Assert.That(appContext.ResolveContextForField(fieldContext.BackingData!.Field), Is.EqualTo(fieldContext)); | ||
} | ||
|
||
[Test] | ||
public void TestEventResolving() | ||
{ | ||
var appContext = Cpp2IlApi.CurrentAppContext; | ||
|
||
var eventContext = appContext!.AllTypes.SelectMany(t => t.Events).First(e => e.Definition is not null); | ||
|
||
Assert.That(appContext.ResolveContextForEvent(eventContext.Definition), Is.EqualTo(eventContext)); | ||
} | ||
|
||
[Test] | ||
public void TestPropertyResolving() | ||
{ | ||
var appContext = Cpp2IlApi.CurrentAppContext; | ||
|
||
var propertyContext = appContext!.AllTypes.SelectMany(t => t.Properties).First(p => p.Definition is not null); | ||
|
||
Assert.That(appContext.ResolveContextForProperty(propertyContext.Definition), Is.EqualTo(propertyContext)); | ||
} | ||
} |
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