|
15 | 15 | internal sealed class PInvoke : IEquatable<PInvoke>
|
16 | 16 | #pragma warning restore CA1067
|
17 | 17 | {
|
18 |
| - public PInvoke(string entryPoint, string module, MethodInfo method) |
| 18 | + public PInvoke(string entryPoint, string module, MethodInfo method, bool wasmLinkage) |
19 | 19 | {
|
20 | 20 | EntryPoint = entryPoint;
|
21 | 21 | Module = module;
|
22 | 22 | Method = method;
|
| 23 | + WasmLinkage = wasmLinkage; |
23 | 24 | }
|
24 | 25 |
|
25 | 26 | public string EntryPoint;
|
26 | 27 | public string Module;
|
27 | 28 | public MethodInfo Method;
|
28 | 29 | public bool Skip;
|
| 30 | + public bool WasmLinkage; |
29 | 31 |
|
30 | 32 | public bool Equals(PInvoke? other)
|
31 | 33 | => other != null &&
|
@@ -100,9 +102,10 @@ void CollectPInvokesForMethod(MethodInfo method)
|
100 | 102 | if ((method.Attributes & MethodAttributes.PinvokeImpl) != 0)
|
101 | 103 | {
|
102 | 104 | var dllimport = method.CustomAttributes.First(attr => attr.AttributeType.Name == "DllImportAttribute");
|
| 105 | + var wasmLinkage = method.CustomAttributes.Any(attr => attr.AttributeType.Name == "WasmImportLinkageAttribute"); |
103 | 106 | var module = (string)dllimport.ConstructorArguments[0].Value!;
|
104 | 107 | var entrypoint = (string)dllimport.NamedArguments.First(arg => arg.MemberName == "EntryPoint").TypedValue.Value!;
|
105 |
| - pinvokes.Add(new PInvoke(entrypoint, module, method)); |
| 108 | + pinvokes.Add(new PInvoke(entrypoint, module, method, wasmLinkage)); |
106 | 109 |
|
107 | 110 | string? signature = SignatureMapper.MethodToSignature(method);
|
108 | 111 | if (signature == null)
|
@@ -241,8 +244,23 @@ internal sealed class PInvokeCallback
|
241 | 244 | public PInvokeCallback(MethodInfo method)
|
242 | 245 | {
|
243 | 246 | Method = method;
|
| 247 | + foreach (var attr in method.CustomAttributes) |
| 248 | + { |
| 249 | + if (attr.AttributeType.Name == "UnmanagedCallersOnlyAttribute") |
| 250 | + { |
| 251 | + foreach(var arg in attr.NamedArguments) |
| 252 | + { |
| 253 | + if (arg.MemberName == "EntryPoint") |
| 254 | + { |
| 255 | + EntryPoint = arg.TypedValue.Value!.ToString(); |
| 256 | + return; |
| 257 | + } |
| 258 | + } |
| 259 | + } |
| 260 | + } |
244 | 261 | }
|
245 | 262 |
|
| 263 | + public string? EntryPoint; |
246 | 264 | public MethodInfo Method;
|
247 | 265 | public string? EntryName;
|
248 | 266 | }
|
|
0 commit comments