Skip to content

Commit

Permalink
Remove some code that is incompatible with dotnet 5+ (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 authored Aug 9, 2023
1 parent c535509 commit b31fb08
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 15 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/dotnet-preparation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Remove some code which is no longer valid for dotnet 5+
3 changes: 0 additions & 3 deletions plugins/module_utils/Process.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -305,7 +304,6 @@ public SafeMemoryBuffer(IntPtr handle) : base(true)
base.SetHandle(handle);
}

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
Expand Down Expand Up @@ -385,7 +383,6 @@ public SafeNativeHandle() : base(true) { }
public SafeNativeHandle(IntPtr handle) : this(handle, true) { }
public SafeNativeHandle(IntPtr handle, bool ownsHandle) : base(ownsHandle) { this.handle = handle; }

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
return NativeMethods.CloseHandle(handle);
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/SCManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
Expand Down Expand Up @@ -295,7 +294,6 @@ public SafeMemoryBuffer(IntPtr handle) : base(true)
base.SetHandle(handle);
}

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
Expand All @@ -308,7 +306,6 @@ internal class SafeServiceHandle : SafeHandleZeroOrMinusOneIsInvalid
public SafeServiceHandle() : base(true) { }
public SafeServiceHandle(IntPtr handle) : base(true) { this.handle = handle; }

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
return NativeMethods.CloseServiceHandle(handle);
Expand Down
4 changes: 0 additions & 4 deletions plugins/modules/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Add-CSharpType -AnsibleModule $module -References @'
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Text;
Expand Down Expand Up @@ -227,7 +226,6 @@ namespace Ansible.Windows.Setup
base.SetHandle(Marshal.AllocHGlobal(cb));
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
Expand All @@ -239,7 +237,6 @@ namespace Ansible.Windows.Setup
{
public SafeDsMemoryBuffer() : base(true) { }
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
NativeMethods.DsRoleFreeMemory(this.handle);
Expand All @@ -251,7 +248,6 @@ namespace Ansible.Windows.Setup
{
public SafeNetAPIBuffer() : base(true) { }
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
NativeMethods.NetApiBufferFree(this.handle);
Expand Down
2 changes: 0 additions & 2 deletions plugins/modules/win_package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Security.Principal;
Expand Down Expand Up @@ -180,7 +179,6 @@ namespace Ansible.WinPackage
{
public SafeMsiHandle() : base(true) { }
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
UInt32 res = NativeMethods.MsiCloseHandle(handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Add-CSharpType -References @'
using Microsoft.Win32.SafeHandles;
using System;
using System.ComponentModel;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Text;
Expand Down Expand Up @@ -246,7 +245,6 @@ namespace Ansible.Device
{
public SafeDeviceInfoSet() : base(true) { }
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
return NativeMethods.SetupDiDestroyDeviceInfoList(handle);
Expand All @@ -271,7 +269,6 @@ namespace Ansible.Device
base.SetHandle(Marshal.StringToHGlobalUni(sz));
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
Expand Down

0 comments on commit b31fb08

Please sign in to comment.