1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 
7 using Internal.TypeSystem;
8 using Internal.TypeSystem.Interop;
9 using Debug = System.Diagnostics.Debug;
10 using Internal.TypeSystem.Ecma;
11 
12 namespace Internal.IL.Stubs
13 {
14     /// <summary>
15     /// Synthetic method that represents the actual PInvoke target method.
16     /// All parameters are simple types. There will be no code
17     /// generated for this method. Instead, a static reference to a symbol will be emitted.
18     /// </summary>
19     public sealed partial class PInvokeTargetNativeMethod : MethodDesc
20     {
21         private readonly MethodDesc _declMethod;
22         private readonly MethodSignature _signature;
23 
PInvokeTargetNativeMethod(MethodDesc declMethod, MethodSignature signature)24         public PInvokeTargetNativeMethod(MethodDesc declMethod, MethodSignature signature)
25         {
26             _declMethod = declMethod;
27             _signature = signature;
28         }
29 
30         public override TypeSystemContext Context
31         {
32             get
33             {
34                 return _declMethod.Context;
35             }
36         }
37 
38         public override TypeDesc OwningType
39         {
40             get
41             {
42                 return _declMethod.OwningType;
43             }
44         }
45 
46         public override MethodSignature Signature
47         {
48             get
49             {
50                 return _signature;
51             }
52         }
53 
54         public override string Name
55         {
56             get
57             {
58                 return _declMethod.Name;
59             }
60         }
61 
HasCustomAttribute(string attributeNamespace, string attributeName)62         public override bool HasCustomAttribute(string attributeNamespace, string attributeName)
63         {
64             return false;
65         }
66 
67         public override bool IsPInvoke
68         {
69             get
70             {
71                 return true;
72             }
73         }
74 
GetPInvokeMethodMetadata()75         public override PInvokeMetadata GetPInvokeMethodMetadata()
76         {
77             return _declMethod.GetPInvokeMethodMetadata();
78         }
79     }
80 }
81