diff --git a/PowerShell.Common.props b/PowerShell.Common.props index cf9f792f99c..72fbf3c86a8 100644 --- a/PowerShell.Common.props +++ b/PowerShell.Common.props @@ -185,14 +185,6 @@ full - - - - false - - strict diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index 25b1624c6cf..783afe62915 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -932,8 +932,10 @@ internal static partial class NativeMethods [LibraryImport(psLib)] internal static partial int WaitPid(int pid, [MarshalAs(UnmanagedType.Bool)] bool nohang); - // This is a struct tm from . - [StructLayout(LayoutKind.Sequential)] + // This is the struct `private_tm` from setdate.h in libpsl-native. + // Packing is set to 4 to match the unmanaged declaration. + // https://github.com/PowerShell/PowerShell-Native/blob/c5575ceb064e60355b9fee33eabae6c6d2708d14/src/libpsl-native/src/setdate.h#L23 + [StructLayout(LayoutKind.Sequential, Pack = 4)] internal unsafe struct UnixTm { /// Seconds (0-60). @@ -980,7 +982,7 @@ internal static UnixTm DateTimeToUnixTm(DateTime date) return tm; } - [LibraryImport(psLib)] + [LibraryImport(psLib, SetLastError = true)] internal static unsafe partial int SetDate(UnixTm* tm); [LibraryImport(psLib, StringMarshalling = StringMarshalling.Utf8)]