Replace DllImport with LibraryImport in SMA 6 (#18581)

This commit is contained in:
Ilya
2022-11-22 23:27:45 +05:00
committed by GitHub
parent 8bc9fdb2a1
commit 05e50dfbd7
3 changed files with 20 additions and 13 deletions
@@ -280,7 +280,7 @@ namespace System.Management.Automation
{
for (int i = 0; i < argCount; i++)
{
VariantClear(variantArgArray + s_variantSize * i);
Interop.Windows.VariantClear(variantArgArray + s_variantSize * i);
}
Marshal.FreeCoTaskMem(variantArgArray);
@@ -297,7 +297,7 @@ namespace System.Management.Automation
{
for (int i = 0; i < refCount; i++)
{
VariantClear(tmpVariants + s_variantSize * i);
Interop.Windows.VariantClear(tmpVariants + s_variantSize * i);
}
Marshal.FreeCoTaskMem(tmpVariants);
@@ -305,13 +305,6 @@ namespace System.Management.Automation
}
}
/// <summary>
/// Clear variables of type VARIANTARG (or VARIANT) before the memory containing the VARIANTARG is freed.
/// </summary>
/// <param name="pVariant"></param>
[DllImport("oleaut32.dll")]
internal static extern void VariantClear(IntPtr pVariant);
/// <summary>
/// We have to declare 'bstrSource', 'bstrDescription' and 'bstrHelpFile' as pointers because
/// CLR marshalling layer would try to free those BSTRs by default and that is not correct.
@@ -276,9 +276,6 @@ namespace System.Management.Automation.InteropServices
}
}
[DllImport("oleaut32.dll")]
internal static extern void VariantClear(IntPtr variant);
/// <summary>
/// Release any unmanaged memory associated with the Variant
/// </summary>
@@ -306,7 +303,7 @@ namespace System.Management.Automation.InteropServices
{
fixed (void* pThis = &this)
{
VariantClear((IntPtr)pThis);
Interop.Windows.VariantClear((nint)pThis);
}
}
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#nullable enable
#if !UNIX
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Windows
{
[LibraryImport("oleaut32.dll")]
internal static partial void VariantClear(nint pVariant);
}
}
#endif