Skip to content

Commit 82cfe3e

Browse files
authored
Merge pull request #147 from nefarius/deps-update
Update dependencies and refactor PInvoke calls to use Span-based patterns
2 parents 43264c4 + cc58ae3 commit 82cfe3e

8 files changed

Lines changed: 32 additions & 37 deletions

Tests/Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1"/>
13-
<PackageReference Include="NUnit" Version="4.5.1" />
14-
<PackageReference Include="NUnit3TestAdapter" Version="6.1.0"/>
15-
<PackageReference Include="NUnit.Analyzers" Version="4.12.0">
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0"/>
13+
<PackageReference Include="NUnit" Version="4.6.1" />
14+
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0"/>
15+
<PackageReference Include="NUnit.Analyzers" Version="4.13.0">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
</PackageReference>
19-
<PackageReference Include="coverlet.collector" Version="8.0.1">
19+
<PackageReference Include="coverlet.collector" Version="10.0.1">
2020
<PrivateAssets>all</PrivateAssets>
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
</PackageReference>

src/Generator/DeviceManagementPropertiesGenerator.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" PrivateAssets="all" />
17-
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0">
16+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" PrivateAssets="all" />
17+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
</PackageReference>
21-
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.213">
21+
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.279">
2222
<PrivateAssets>all</PrivateAssets>
2323
</PackageReference>
24-
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="65.0.8-preview" />
24+
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="70.0.11-preview" />
2525
<PackageReference Include="Microsoft.Windows.WDK.Win32Metadata" Version="0.13.25-experimental" />
2626
</ItemGroup>
2727

src/Nefarius.Utilities.DeviceManagement.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.213">
29+
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.279">
3030
<PrivateAssets>all</PrivateAssets>
3131
</PackageReference>
32-
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="65.0.8-preview">
32+
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="70.0.11-preview">
3333
<PrivateAssets>all</PrivateAssets>
3434
</PackageReference>
3535
<PackageReference Include="Microsoft.Windows.WDK.Win32Metadata" Version="0.13.25-experimental">
@@ -47,7 +47,7 @@
4747
</ItemGroup>
4848

4949
<ItemGroup>
50-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All"/>
50+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" PrivateAssets="All"/>
5151
</ItemGroup>
5252

5353
<ItemGroup>

src/PnP/Devcon.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,13 @@ public static bool RefreshPhantom()
521521
public static unsafe bool Update(string hardwareId, string fullInfPath,
522522
out bool rebootRequired)
523523
{
524-
BOOL reboot = false;
525-
526524
BOOL ret = PInvoke.UpdateDriverForPlugAndPlayDevices(
527525
HWND.Null,
528526
hardwareId,
529527
fullInfPath,
530528
UPDATEDRIVERFORPLUGANDPLAYDEVICES_FLAGS.INSTALLFLAG_FORCE |
531529
UPDATEDRIVERFORPLUGANDPLAYDEVICES_FLAGS.INSTALLFLAG_NONINTERACTIVE,
532-
&reboot
530+
out BOOL reboot
533531
);
534532

535533
rebootRequired = reboot > 0;

src/PnP/DeviceClassFilters.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ private static unsafe void AddFiltersEntry(Guid classGuid, string filter, string
174174
WIN32_ERROR status = PInvoke.RegQueryValueEx(
175175
key,
176176
filter,
177-
&type,
177+
out type,
178178
null,
179-
&sizeRequired
179+
ref sizeRequired
180180
);
181181

182182
// value exists
@@ -187,9 +187,9 @@ private static unsafe void AddFiltersEntry(Guid classGuid, string filter, string
187187
status = PInvoke.RegQueryValueEx(
188188
key,
189189
filter,
190-
&type,
191-
buffer,
192-
&sizeRequired
190+
out type,
191+
new Span<byte>(buffer, (int)sizeRequired),
192+
ref sizeRequired
193193
);
194194

195195
if (status != WIN32_ERROR.ERROR_SUCCESS)
@@ -268,9 +268,9 @@ private static unsafe void RemoveFiltersEntry(Guid classGuid, string filter, str
268268
WIN32_ERROR status = PInvoke.RegQueryValueEx(
269269
key,
270270
filter,
271-
&type,
271+
out type,
272272
null,
273-
&sizeRequired
273+
ref sizeRequired
274274
);
275275

276276
// value exists
@@ -281,9 +281,9 @@ private static unsafe void RemoveFiltersEntry(Guid classGuid, string filter, str
281281
status = PInvoke.RegQueryValueEx(
282282
key,
283283
filter,
284-
&type,
285-
buffer,
286-
&sizeRequired
284+
out type,
285+
new Span<byte>(buffer, (int)sizeRequired),
286+
ref sizeRequired
287287
);
288288

289289
if (status != WIN32_ERROR.ERROR_SUCCESS)
@@ -341,9 +341,9 @@ private static unsafe void RemoveFiltersEntry(Guid classGuid, string filter, str
341341
WIN32_ERROR status = PInvoke.RegQueryValueEx(
342342
key,
343343
filter,
344-
&type,
344+
out type,
345345
null,
346-
&sizeRequired
346+
ref sizeRequired
347347
);
348348

349349
switch (status)
@@ -356,9 +356,9 @@ private static unsafe void RemoveFiltersEntry(Guid classGuid, string filter, str
356356
status = PInvoke.RegQueryValueEx(
357357
key,
358358
filter,
359-
&type,
360-
buffer,
361-
&sizeRequired
359+
out type,
360+
new Span<byte>(buffer, (int)sizeRequired),
361+
ref sizeRequired
362362
);
363363

364364
if (status != WIN32_ERROR.ERROR_SUCCESS)

src/PnP/PnPDevice.Properties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ out uint valueBufferSize
348348
_instanceHandle,
349349
propertyKey,
350350
out propertyType,
351-
(byte*)valueBuffer.ToPointer(),
351+
new Span<byte>((byte*)valueBuffer.ToPointer(), (int)valueBufferSize),
352352
ref valueBufferSize,
353353
0
354354
);

src/PnP/PnPDevice.Static.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static PnPDevice GetDeviceByInstanceId(string instanceId,
8484
symbolicLink,
8585
property,
8686
out _,
87-
(byte*)buffer,
87+
new Span<byte>((byte*)buffer, (int)sizeRequired),
8888
ref sizeRequired,
8989
0
9090
);

src/PnP/UsbPnPDevice.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,8 @@ public unsafe void CyclePort()
131131
BOOL success = PInvoke.DeviceIoControl(
132132
hubHandle,
133133
PInvoke.IOCTL_USB_HUB_CYCLE_PORT,
134-
&parameters,
135-
(uint)size,
136-
&parameters,
137-
(uint)size,
138-
null,
134+
new ReadOnlySpan<byte>((byte*)&parameters, size),
135+
new Span<byte>((byte*)&parameters, size),
139136
null
140137
);
141138

0 commit comments

Comments
 (0)