Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Automatic generation of mockable classes and interfaces #70

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
39fc4fc
first step towards automatic code generation of mockables.
ffMathy Nov 16, 2015
37995f0
new changes to generation.
ffMathy Nov 16, 2015
fc7df65
changed back faulty class.
ffMathy Nov 16, 2015
82598fb
better generation.
ffMathy Nov 16, 2015
a2e1110
further changes to generation by wrapping interface declarations in n…
ffMathy Nov 17, 2015
ba3bfa4
yet another attempt.
ffMathy Nov 17, 2015
c2bf4e6
more stuff.
ffMathy Nov 17, 2015
27a5788
further progress.
ffMathy Nov 17, 2015
543a237
class fix.
ffMathy Nov 17, 2015
847d7f5
more fixes.
ffMathy Nov 17, 2015
e064da1
fixes.
ffMathy Nov 17, 2015
1d90d10
awesomeness.
ffMathy Nov 17, 2015
17ca24d
foo.
ffMathy Nov 17, 2015
f2aac5d
finalized program.
ffMathy Nov 21, 2015
91cb6e7
static conversion.
ffMathy Nov 22, 2015
50223d7
updates.
ffMathy Nov 22, 2015
109afa0
new changes.
ffMathy Nov 22, 2015
c95ebba
new program stuff.
ffMathy Nov 22, 2015
ad34bea
added mockables.
ffMathy Nov 22, 2015
4172584
more updates.
ffMathy Nov 22, 2015
a31d0a6
foo changes.
ffMathy Nov 22, 2015
5c9556e
new stuff.
ffMathy Nov 22, 2015
cc8e5b6
updated.
ffMathy Nov 22, 2015
032d0a1
added stuff.
ffMathy Nov 22, 2015
616d4b2
better program.
ffMathy Nov 22, 2015
a581682
new stuff.
ffMathy Nov 22, 2015
3a66854
new hid files.
ffMathy Nov 22, 2015
f540802
class fixes.
ffMathy Nov 22, 2015
a2cd483
fixed extension stuff.
ffMathy Nov 22, 2015
fc65cc8
reverted to compiled solution.
ffMathy Nov 22, 2015
0244024
cleanup.
ffMathy Nov 22, 2015
698fb35
new stuff.
ffMathy Nov 22, 2015
3410aee
better using.
ffMathy Nov 22, 2015
3074d18
stuff.
ffMathy Nov 22, 2015
b733dd1
foobar.
ffMathy Nov 22, 2015
8370833
removed mockables.
ffMathy Nov 22, 2015
ade9412
fooo
ffMathy Nov 22, 2015
395db2d
whitespace.
ffMathy Nov 22, 2015
55ead2a
blah.
ffMathy Nov 22, 2015
ceadefb
new progress.
ffMathy Nov 22, 2015
db23b47
generated code updates.
ffMathy Nov 22, 2015
9e9840f
fix for duplicate code.
ffMathy Nov 22, 2015
0ff5a71
mockables.
ffMathy Nov 22, 2015
47b5846
new changes.
ffMathy Nov 22, 2015
c1b983b
removed invoke prefix.
ffMathy Nov 22, 2015
a137f66
new code format.
ffMathy Nov 22, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/AdvApi32.Desktop/AdvApi32Mockable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.

namespace PInvoke
{
using System;
using System.Runtime.InteropServices;
public partial class AdvApi32 : IAdvApi32Mockable {
/// <summary>
/// Changes the optional configuration parameters of a service.
/// </summary>
/// <param name="hService">
/// A handle to the service.
/// This handle is returned by the OpenService or CreateService function and
/// must have the <see cref="ServiceAccess.SERVICE_CHANGE_CONFIG"/> access right.
/// </param>
/// <param name="dwInfoLevel">
/// The configuration information to be changed.
/// This parameter can be one value from <see cref="ServiceStartType"/>.
/// </param>
/// <param name="lpInfo">
/// A pointer to the new value to be set for the configuration information.
/// The format of this data depends on the value of the dwInfoLevel parameter.
/// If this value is NULL, the information remains unchanged.
/// </param>
/// <returns>
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero
/// </returns>
public bool InvokeChangeServiceConfig2(SafeServiceHandle hService, ServiceInfoLevel dwInfoLevel, IntPtr lpInfo)
=> ChangeServiceConfig2(hService, dwInfoLevel, lpInfo);
}
}
32 changes: 32 additions & 0 deletions src/AdvApi32.Desktop/IAdvApi32Mockable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.

namespace PInvoke
{
using System;
using System.Runtime.InteropServices;
public interface IAdvApi32Mockable {
/// <summary>
/// Changes the optional configuration parameters of a service.
/// </summary>
/// <param name="hService">
/// A handle to the service.
/// This handle is returned by the OpenService or CreateService function and
/// must have the <see cref="ServiceAccess.SERVICE_CHANGE_CONFIG"/> access right.
/// </param>
/// <param name="dwInfoLevel">
/// The configuration information to be changed.
/// This parameter can be one value from <see cref="ServiceStartType"/>.
/// </param>
/// <param name="lpInfo">
/// A pointer to the new value to be set for the configuration information.
/// The format of this data depends on the value of the dwInfoLevel parameter.
/// If this value is NULL, the information remains unchanged.
/// </param>
/// <returns>
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is zero
/// </returns>
bool InvokeChangeServiceConfig2(SafeServiceHandle hService, ServiceInfoLevel dwInfoLevel, IntPtr lpInfo);
}
}
236 changes: 236 additions & 0 deletions src/BCrypt/BCryptMockable.cs

Large diffs are not rendered by default.

230 changes: 230 additions & 0 deletions src/BCrypt/IBCryptMockable.cs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/Gdi32.Desktop/Gdi32Mockable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.

namespace PInvoke
{
using System;
using System.Runtime.InteropServices;
public partial class Gdi32 : IGdi32Mockable { public bool InvokeDeleteObject(IntPtr hObject)
=> DeleteObject(hObject);
}
}
10 changes: 10 additions & 0 deletions src/Gdi32.Desktop/IGdi32Mockable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.

namespace PInvoke
{
using System;
using System.Runtime.InteropServices;
public interface IGdi32Mockable { bool InvokeDeleteObject(IntPtr hObject);
}
}
165 changes: 165 additions & 0 deletions src/Hid.Desktop/HidMockable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.

namespace PInvoke
{
using System;
using System.Runtime.InteropServices;
using System.Text;
using static Kernel32;
public partial class Hid : IHidMockable { /// <summary>
/// The HidD_GetHidGuid routine returns the device interfaceGUID for HIDClass devices.
/// </summary>
/// <param name="hidGuid">
/// Pointer to a caller-allocated GUID buffer that the routine uses to return the device interface GUID
/// for HIDClass devices.
/// </param>
public void InvokeHidD_GetHidGuid(out Guid hidGuid)
=> HidD_GetHidGuid(hidGuid);

/// <summary>
/// Returns the attributes of a specified top-level collection.
/// </summary>
/// <param name="hidDeviceObject">Specifies an open handle to a top-level collection.</param>
/// <param name="attributes">
/// Pointer to a caller-allocated <see cref="HiddAttributes" /> structure that returns the
/// attributes of the collection specified by HidDeviceObject.
/// </param>
/// <returns>TRUE if succeeds; otherwise, it returns FALSE.</returns>
public bool InvokeHidD_GetAttributes(
SafeObjectHandle hidDeviceObject,
ref HiddAttributes attributes)
=> HidD_GetAttributes(hidDeviceObject, attributes);

/// <summary>
/// Returns a top-level collection's embedded string that identifies the manufacturer.
/// </summary>
/// <param name="hidDeviceObject">Specifies an open handle to a top-level collection.</param>
/// <param name="buffer">
/// Pointer to a caller-allocated buffer that the routine uses to return the collection's manufacturer
/// string.
/// </param>
/// <param name="bufferLength">
/// Specifies the length, in bytes, of a caller-allocated buffer provided at Buffer. If the
/// buffer is not large enough to return the entire NULL-terminated embedded string, the routine returns nothing in the
/// buffer.
/// </param>
/// <returns>TRUE if it returns the entire NULL-terminated embedded string. Otherwise, the routine returns FALSE.</returns>
/// <remarks>
/// The maximum possible number of characters in an embedded string is device specific. For USB devices, the
/// maximum string length is 126 wide characters (not including the terminating NULL character).
/// </remarks>
public bool InvokeHidD_GetManufacturerString(
SafeObjectHandle hidDeviceObject,
StringBuilder buffer,
int bufferLength)
=> HidD_GetManufacturerString(hidDeviceObject, buffer, bufferLength);

/// <summary>
/// Returns the embedded string of a top-level collection that identifies the manufacturer's product.
/// </summary>
/// <param name="hidDeviceObject">Specifies an open handle to a top-level collection.</param>
/// <param name="buffer">Pointer to a caller-allocated buffer that the routine uses to return the requested product string.</param>
/// <param name="bufferLength">
/// Specifies the length, in bytes, of a caller-allocated buffer provided at Buffer. If the
/// buffer is not large enough to return the entire NULL-terminated embedded string, the routine returns nothing in the
/// buffer.
/// </param>
/// <returns>
/// TRUE if it successfully returns the entire NULL-terminated embedded string. Otherwise, the routine returns
/// FALSE.
/// </returns>
/// ///
/// <remarks>
/// The maximum possible number of characters in an embedded string is device specific. For USB devices, the
/// maximum string length is 126 wide characters (not including the terminating NULL character).
/// </remarks>
public bool InvokeHidD_GetProductString(
SafeObjectHandle hidDeviceObject,
StringBuilder buffer,
int bufferLength)
=> HidD_GetProductString(hidDeviceObject, buffer, bufferLength);

/// <summary>
/// Returns the embedded string of a top-level collection that identifies the serial number of the collection's physical
/// device.
/// </summary>
/// <param name="hidDeviceObject">Specifies an open handle to a top-level collection.</param>
/// <param name="buffer">
/// Pointer to a caller-allocated buffer that the routine uses to return the requested serial number
/// string.
/// </param>
/// <param name="bufferLength">
/// Specifies the length, in bytes, of a caller-allocated buffer provided at Buffer. If the
/// buffer is not large enough to return the entire NULL-terminated embedded string, the routine returns nothing in the
/// buffer.
/// </param>
/// <returns>
/// TRUE if it successfully returns the entire NULL-terminated embedded string. Otherwise, the routine returns
/// FALSE.
/// </returns>
/// /// ///
/// <remarks>
/// The maximum possible number of characters in an embedded string is device specific. For USB devices, the
/// maximum string length is 126 wide characters (not including the terminating NULL character).
/// </remarks>
public bool InvokeHidD_GetSerialNumberString(
SafeObjectHandle hidDeviceObject,
StringBuilder buffer,
int bufferLength)
=> HidD_GetSerialNumberString(hidDeviceObject, buffer, bufferLength);

/// <summary>
/// Sets the maximum number of input reports that the HID class driver ring buffer can hold for a specified top-level
/// collection.
/// </summary>
/// <param name="hidDeviceObject">Specifies an open handle to a top-level collection.</param>
/// <param name="numberBuffers">
/// Specifies the maximum number of buffers that the HID class driver should maintain for the
/// input reports generated by the HidDeviceObject collection.
/// </param>
/// <returns>TRUE if it succeeds; otherwise, it returns FALSE.</returns>
public bool InvokeHidD_SetNumInputBuffers(
SafeObjectHandle hidDeviceObject,
uint numberBuffers)
=> HidD_SetNumInputBuffers(hidDeviceObject, numberBuffers);

/// <summary>
/// Returns a top-level collection's preparsed data.
/// </summary>
/// <param name="hidDeviceObject">Specifies an open handle to a top-level collection.</param>
/// <param name="preparsedDataHandle">
/// Pointer to the address of a routine-allocated buffer that contains a collection's
/// preparsed data in a <see cref="SafePreparsedDataHandle" /> structure.
/// </param>
/// <returns>TRUE if it succeeds; otherwise, it returns FALSE.</returns>
public bool InvokeHidD_GetPreparsedData(
SafeObjectHandle hidDeviceObject,
out SafePreparsedDataHandle preparsedDataHandle)
=> HidD_GetPreparsedData(hidDeviceObject, preparsedDataHandle);

/// <summary>
/// Returns a top-level collection's <see cref="HidpCaps" /> structure.
/// </summary>
/// <param name="preparsedData">Pointer to a top-level collection's preparsed data.</param>
/// <param name="capabilities">
/// Pointer to a caller-allocated buffer that the routine uses to return a collection's
/// <see cref="HidpCaps" /> structure.
/// </param>
/// <returns>
/// <see cref="NTStatus.HIDP_STATUS_SUCCESS" /> on success or <see cref="NTStatus.HIDP_STATUS_INVALID_PREPARSED_DATA" /> if rhe
/// specified preparsed data is invalid.
/// </returns>
public NTStatus InvokeHidP_GetCaps(SafePreparsedDataHandle preparsedData, ref HidpCaps capabilities)
=> HidP_GetCaps(preparsedData, capabilities);
/// <summary>
/// The HidD_GetHidGuid routine returns the device interfaceGUID for HIDClass devices.
/// </summary>
/// <param name="hidGuid">
/// Pointer to a caller-allocated GUID buffer that the routine uses to return the device interface GUID
/// for HIDClass devices.
/// </param>
public void InvokeHidD_GetHidGuid(out Guid hidGuid)
=> HidD_GetHidGuid(hidGuid);
}
}
Loading