|
1 | | -#if !(CS110 && NET70) |
2 | 1 | using System; |
3 | | -#endif |
| 2 | +using System.Runtime.CompilerServices; |
| 3 | +using System.Runtime.InteropServices; |
4 | 4 | using System.Text; |
5 | 5 |
|
6 | 6 | namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
@@ -46,15 +46,168 @@ public static string VarianceTest(object o) |
46 | 46 | return (delegate*<object, string>)(&VarianceTest); |
47 | 47 | } |
48 | 48 |
|
49 | | - public unsafe delegate*<void> AddressOfLocalFunction() |
| 49 | + public unsafe delegate*<void> AddressOfLocalFunction_Managed() |
| 50 | + { |
| 51 | + return &LocalFunction; |
| 52 | + |
| 53 | + static void LocalFunction() |
| 54 | + { |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + public unsafe delegate* unmanaged<void> AddressOfLocalFunction_Unmanaged() |
| 59 | + { |
| 60 | + return &LocalFunction; |
| 61 | + |
| 62 | + [UnmanagedCallersOnly] |
| 63 | + static void LocalFunction() |
| 64 | + { |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + public unsafe delegate* unmanaged[Cdecl]<void> AddressOfLocalFunction_CDecl() |
| 69 | + { |
| 70 | + return &LocalFunction; |
| 71 | + |
| 72 | + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvCdecl) })] |
| 73 | + static void LocalFunction() |
| 74 | + { |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + public unsafe delegate* unmanaged[Fastcall]<void> AddressOfLocalFunction_Fastcall() |
| 79 | + { |
| 80 | + return &LocalFunction; |
| 81 | + |
| 82 | + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvFastcall) })] |
| 83 | + static void LocalFunction() |
| 84 | + { |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | +#if NET60 |
| 89 | + public unsafe delegate* unmanaged[MemberFunction]<void> AddressOfLocalFunction_MemberFunction() |
| 90 | + { |
| 91 | + return &LocalFunction; |
| 92 | + |
| 93 | + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvMemberFunction) })] |
| 94 | + static void LocalFunction() |
| 95 | + { |
| 96 | + } |
| 97 | + } |
| 98 | +#endif |
| 99 | + |
| 100 | + public unsafe delegate* unmanaged[Stdcall]<void> AddressOfLocalFunction_Stdcall() |
| 101 | + { |
| 102 | + return &LocalFunction; |
| 103 | + |
| 104 | + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvStdcall) })] |
| 105 | + static void LocalFunction() |
| 106 | + { |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | +#if NET60 |
| 111 | + public unsafe delegate* unmanaged[SuppressGCTransition]<void> AddressOfLocalFunction_SuppressGCTransition() |
| 112 | + { |
| 113 | + return &LocalFunction; |
| 114 | + |
| 115 | + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvSuppressGCTransition) })] |
| 116 | + static void LocalFunction() |
| 117 | + { |
| 118 | + } |
| 119 | + } |
| 120 | +#endif |
| 121 | + |
| 122 | + public unsafe delegate* unmanaged[Thiscall]<void> AddressOfLocalFunction_Thiscall() |
| 123 | + { |
| 124 | + return &LocalFunction; |
| 125 | + |
| 126 | + [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvThiscall) })] |
| 127 | + static void LocalFunction() |
| 128 | + { |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + public unsafe delegate* unmanaged[Cdecl, Fastcall]<void> AddressOfLocalFunction_CDeclAndFastcall() |
| 133 | + { |
| 134 | + return &LocalFunction; |
| 135 | + |
| 136 | + [UnmanagedCallersOnly(CallConvs = new Type[] { |
| 137 | + typeof(CallConvCdecl), |
| 138 | + typeof(CallConvFastcall) |
| 139 | + })] |
| 140 | + static void LocalFunction() |
| 141 | + { |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + public unsafe delegate* unmanaged[Fastcall, Cdecl]<void> AddressOfLocalFunction_FastcallAndCDecl() |
| 146 | + { |
| 147 | + return &LocalFunction; |
| 148 | + |
| 149 | + [UnmanagedCallersOnly(CallConvs = new Type[] { |
| 150 | + typeof(CallConvFastcall), |
| 151 | + typeof(CallConvCdecl) |
| 152 | + })] |
| 153 | + static void LocalFunction() |
| 154 | + { |
| 155 | + } |
| 156 | + } |
| 157 | + |
| 158 | +#if NET60 |
| 159 | + public unsafe delegate* unmanaged[Cdecl, SuppressGCTransition]<void> AddressOfLocalFunction_CDeclAndSuppressGCTransition() |
50 | 160 | { |
51 | 161 | return &LocalFunction; |
52 | 162 |
|
| 163 | + [UnmanagedCallersOnly(CallConvs = new Type[] { |
| 164 | + typeof(CallConvCdecl), |
| 165 | + typeof(CallConvSuppressGCTransition) |
| 166 | + })] |
53 | 167 | static void LocalFunction() |
54 | 168 | { |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + public unsafe delegate* unmanaged[Fastcall, SuppressGCTransition]<void> AddressOfLocalFunction_FastcallAndSuppressGCTransition() |
| 173 | + { |
| 174 | + return &LocalFunction; |
55 | 175 |
|
| 176 | + [UnmanagedCallersOnly(CallConvs = new Type[] { |
| 177 | + typeof(CallConvFastcall), |
| 178 | + typeof(CallConvSuppressGCTransition) |
| 179 | + })] |
| 180 | + static void LocalFunction() |
| 181 | + { |
56 | 182 | } |
57 | 183 | } |
| 184 | + |
| 185 | + public unsafe delegate* unmanaged[Stdcall, SuppressGCTransition]<void> AddressOfLocalFunction_StdcallAndSuppressGCTransition() |
| 186 | + { |
| 187 | + return &LocalFunction; |
| 188 | + |
| 189 | + [UnmanagedCallersOnly(CallConvs = new Type[] { |
| 190 | + typeof(CallConvStdcall), |
| 191 | + typeof(CallConvSuppressGCTransition) |
| 192 | + })] |
| 193 | + static void LocalFunction() |
| 194 | + { |
| 195 | + } |
| 196 | + } |
| 197 | + |
| 198 | + public unsafe delegate* unmanaged[Thiscall, SuppressGCTransition]<void> AddressOfLocalFunction_ThiscallAndSuppressGCTransition() |
| 199 | + { |
| 200 | + return &LocalFunction; |
| 201 | + |
| 202 | + [UnmanagedCallersOnly(CallConvs = new Type[] { |
| 203 | + typeof(CallConvThiscall), |
| 204 | + typeof(CallConvSuppressGCTransition) |
| 205 | + })] |
| 206 | + static void LocalFunction() |
| 207 | + { |
| 208 | + } |
| 209 | + } |
| 210 | +#endif |
58 | 211 | } |
59 | 212 |
|
60 | 213 | internal class FunctionPointersWithCallingConvention |
|
0 commit comments