Skip to content

Commit 4438760

Browse files
authored
Use GeneratedDllImport for blittable p/invokes in System.Diagnostics.Process, System.Diagnostics.Process, System.Diagnostics.FileVersionInfo, System.Runtime.InteropServices.RuntimeInformation (#61532)
1 parent 31dd708 commit 4438760

31 files changed

+74
-70
lines changed

eng/generators.targets

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
and (
2323
('@(Reference)' != ''
2424
and @(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))
25-
and @(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.CompilerServices.Unsafe'))
25+
and (@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.CompilerServices.Unsafe'))
26+
or ('@(ProjectReference)' != ''
27+
and @(ProjectReference->AnyHaveMetadataValue('Identity', $([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'System.Runtime.CompilerServices.Unsafe', 'src', 'System.Runtime.CompilerServices.Unsafe.ilproj'))))))
2628
and @(Reference->AnyHaveMetadataValue('Identity', 'System.Memory')))
2729
or ('@(ProjectReference)' != ''
2830
and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))))" />

src/libraries/Common/src/Interop/Unix/Interop.Errors.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,25 +183,25 @@ internal static unsafe string StrError(int platformErrno)
183183
}
184184

185185
#if SERIAL_PORTS
186-
[DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")]
187-
internal static extern Error ConvertErrorPlatformToPal(int platformErrno);
186+
[GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")]
187+
internal static partial Error ConvertErrorPlatformToPal(int platformErrno);
188188

189-
[DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")]
190-
internal static extern int ConvertErrorPalToPlatform(Error error);
189+
[GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")]
190+
internal static partial int ConvertErrorPalToPlatform(Error error);
191191

192-
[DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")]
193-
private static extern unsafe byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize);
192+
[GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")]
193+
private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize);
194194
#else
195-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")]
195+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")]
196196
[SuppressGCTransition]
197-
internal static extern Error ConvertErrorPlatformToPal(int platformErrno);
197+
internal static partial Error ConvertErrorPlatformToPal(int platformErrno);
198198

199-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")]
199+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")]
200200
[SuppressGCTransition]
201-
internal static extern int ConvertErrorPalToPlatform(Error error);
201+
internal static partial int ConvertErrorPalToPlatform(Error error);
202202

203-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")]
204-
private static extern unsafe byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize);
203+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")]
204+
private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize);
205205
#endif
206206
}
207207
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEGid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Sys
1010
{
11-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEGid")]
12-
internal static extern uint GetEGid();
11+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEGid")]
12+
internal static partial uint GetEGid();
1313
}
1414
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal static partial class Interop
77
{
88
internal static partial class Sys
99
{
10-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEUid")]
11-
internal static extern uint GetEUid();
10+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEUid")]
11+
internal static partial uint GetEUid();
1212
}
1313
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroups.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal static partial class Sys
4444
while (true);
4545
}
4646

47-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroups", SetLastError = true)]
48-
private static extern unsafe int GetGroups(int ngroups, uint* groups);
47+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroups", SetLastError = true)]
48+
private static unsafe partial int GetGroups(int ngroups, uint* groups);
4949
}
5050
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetOSArchitecture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal static partial class Interop
99
internal static partial class Sys
1010
{
1111
[SuppressGCTransition]
12-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetOSArchitecture")]
13-
internal static extern int GetOSArchitecture();
12+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetOSArchitecture")]
13+
internal static partial int GetOSArchitecture();
1414
}
1515
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal static partial class Interop
99
internal static partial class Sys
1010
{
1111
[SuppressGCTransition]
12-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessArchitecture")]
13-
internal static extern int GetProcessArchitecture();
12+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessArchitecture")]
13+
internal static partial int GetProcessArchitecture();
1414
}
1515
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal static partial class Interop
77
{
88
internal static partial class Sys
99
{
10-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSid")]
11-
internal static extern int GetSid(int pid);
10+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSid")]
11+
internal static partial int GetSid(int pid);
1212
}
1313
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal static partial class Interop
77
{
88
internal static partial class Sys
99
{
10-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUid")]
11-
internal static extern uint GetUid();
10+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUid")]
11+
internal static partial uint GetUid();
1212
}
1313
}

src/libraries/Common/src/Interop/Unix/System.Native/Interop.RegisterForSigChld.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal static partial class Interop
77
{
88
internal static partial class Sys
99
{
10-
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RegisterForSigChld")]
11-
internal static extern unsafe void RegisterForSigChld(delegate* unmanaged<int, int, int> handler);
10+
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RegisterForSigChld")]
11+
internal static unsafe partial void RegisterForSigChld(delegate* unmanaged<int, int, int> handler);
1212
}
1313
}

0 commit comments

Comments
 (0)