Skip to content

Commit e4fe509

Browse files
committed
Refactor: remove GetCurrentAppContext() helper
Replaced all usages of GetCurrentAppContext() with direct access to Cpp2IlApi.CurrentAppContext, simplifying the code and removing an unnecessary wrapper method. Applied the null-forgiving operator where appropriate.
1 parent 1de9b91 commit e4fe509

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

Il2CppInterop.Generator/Il2CppGame.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Cpp2IL.Core.Api;
33
using Cpp2IL.Core.InstructionSets;
44
using Cpp2IL.Core.Logging;
5-
using Cpp2IL.Core.Model.Contexts;
65
using Cpp2IL.Plugin.StrippedCodeRegSupport;
76
using LibCpp2IL;
87

@@ -32,7 +31,7 @@ public static void Process(string gameExePath, string outputFolder, Cpp2IlOutput
3231
{
3332
Process(gameExePath, processingLayers, extraData);
3433

35-
outputFormat.DoOutput(GetCurrentAppContext(), outputFolder);
34+
outputFormat.DoOutput(Cpp2IlApi.CurrentAppContext!, outputFolder);
3635
}
3736

3837
public static void Process(string gameExePath, List<Cpp2IlProcessingLayer> processingLayers, KeyValuePair<string, string>[] extraData)
@@ -58,12 +57,12 @@ public static void Process(string gameExePath, List<Cpp2IlProcessingLayer> proce
5857

5958
foreach (var cpp2IlProcessingLayer in processingLayers)
6059
{
61-
cpp2IlProcessingLayer.PreProcess(GetCurrentAppContext(), processingLayers);
60+
cpp2IlProcessingLayer.PreProcess(Cpp2IlApi.CurrentAppContext, processingLayers);
6261
}
6362

6463
foreach (var cpp2IlProcessingLayer in processingLayers)
6564
{
66-
cpp2IlProcessingLayer.Process(GetCurrentAppContext());
65+
cpp2IlProcessingLayer.Process(Cpp2IlApi.CurrentAppContext);
6766
}
6867
}
6968

@@ -77,9 +76,4 @@ private static string GetGameAssemblyPath(string gameDirectory)
7776
}
7877
throw new FileNotFoundException("Could not find GameAssembly binary in game directory.");
7978
}
80-
81-
private static ApplicationAnalysisContext GetCurrentAppContext()
82-
{
83-
return Cpp2IlApi.CurrentAppContext ?? throw new NullReferenceException();
84-
}
8579
}

0 commit comments

Comments
 (0)