|
4 | 4 | using Cpp2IL.Core.Logging; |
5 | 5 | using Cpp2IL.Core.Model.Contexts; |
6 | 6 | using Cpp2IL.Core.Model.CustomAttributes; |
| 7 | +using Il2CppInterop.Generator.Operands; |
7 | 8 | using LibCpp2IL.BinaryStructures; |
8 | 9 |
|
9 | 10 | namespace Il2CppInterop.Generator; |
@@ -128,6 +129,12 @@ protected static void InjectAssemblies(ApplicationAnalysisContext appContext, IR |
128 | 129 | Dictionary<MethodDefinition, MethodAnalysisContext> methodLookup = new(); |
129 | 130 | foreach (var method in type.Methods) |
130 | 131 | { |
| 132 | + if (method.IsPInvokeImpl) |
| 133 | + { |
| 134 | + // No p/invoke methods |
| 135 | + continue; |
| 136 | + } |
| 137 | + |
131 | 138 | if (TryInjectMethod(method, typeContext, out var methodContext)) |
132 | 139 | { |
133 | 140 | methodLookup.Add(method, methodContext); |
@@ -193,11 +200,33 @@ protected static void InjectAssemblies(ApplicationAnalysisContext appContext, IR |
193 | 200 | continue; |
194 | 201 | } |
195 | 202 |
|
| 203 | + if (method.IsPInvokeImpl) |
| 204 | + { |
| 205 | + // No p/invoke methods |
| 206 | + continue; |
| 207 | + } |
| 208 | + |
196 | 209 | if (!TryInjectMethod(method, typeContext, out var methodContext)) |
197 | 210 | continue; |
198 | 211 |
|
199 | 212 | methodLookup.Add(method, methodContext); |
200 | | - methodsNeedingBodies.Add((methodContext, method)); |
| 213 | + if (method.IsAbstract) |
| 214 | + { |
| 215 | + methodContext.Attributes &= ~System.Reflection.MethodAttributes.Abstract; // We convert abstract methods to virtual methods |
| 216 | + |
| 217 | + methodContext.PutExtraData(new OriginalMethodBody() |
| 218 | + { |
| 219 | + Instructions = |
| 220 | + [ |
| 221 | + new Instruction(CilOpCodes.Ldnull), |
| 222 | + new Instruction(CilOpCodes.Throw), |
| 223 | + ] |
| 224 | + }); |
| 225 | + } |
| 226 | + else |
| 227 | + { |
| 228 | + methodsNeedingBodies.Add((methodContext, method)); |
| 229 | + } |
201 | 230 |
|
202 | 231 | foreach (var implementation in type.MethodImplementations) |
203 | 232 | { |
|
0 commit comments