Skip to content

Update dependencies and refactor PInvoke calls to use Span-based patterns#147

Merged
nefarius merged 1 commit into
masterfrom
deps-update
May 30, 2026
Merged

Update dependencies and refactor PInvoke calls to use Span-based patterns#147
nefarius merged 1 commit into
masterfrom
deps-update

Conversation

@nefarius
Copy link
Copy Markdown
Owner

@nefarius nefarius commented May 30, 2026

Summary by CodeRabbit

  • Chores

    • Updated NuGet dependencies to latest versions across test and source projects, including test frameworks, code analysis tools, and Windows SDK packages.
  • Refactor

    • Modernized platform interop code to use safer span-based buffer handling and explicit output parameters instead of raw pointer operations.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

📝 Walkthrough

Walkthrough

NuGet package versions are bumped across test frameworks, Roslyn analyzers, and Windows SDK metadata. PInvoke call sites throughout the library are refactored to use Span<T> instead of raw pointers, standardizing the managed-to-unmanaged boundary across registry queries, property lookups, and device control operations.

Changes

Dependency Updates

Layer / File(s) Summary
Test and generator dependencies
Tests/Tests.csproj, src/Generator/DeviceManagementPropertiesGenerator.csproj
Test framework packages (NUnit, SDK, analyzers, coverage) and Roslyn analyzer versions are upgraded to newer releases.
Main library dependencies
src/Nefarius.Utilities.DeviceManagement.csproj
Windows SDK packages (CsWin32, Win32Metadata) and SourceLink bumped to match generator and toolchain updates.

Interop Boundary Refactoring

Layer / File(s) Summary
Devcon out parameter refactoring
src/PnP/Devcon.cs
Reboot flag passed to UpdateDriverForPlugAndPlayDevices via out BOOL parameter instead of pre-declared local variable.
Registry value query span conversion
src/PnP/DeviceClassFilters.cs
Three methods (AddFiltersEntry, RemoveFiltersEntry, GetFiltersEntry) updated to pass RegQueryValueEx buffers as Span<byte> and use out/ref parameters consistently.
Property retrieval span conversion
src/PnP/PnPDevice.Properties.cs, src/PnP/PnPDevice.Static.cs
Native buffers passed to CM_Get_DevNode_Property and CM_Get_Device_Interface_Property converted from raw pointers to Span<byte> views.
DeviceIoControl span conversion
src/PnP/UsbPnPDevice.cs
USB_CYCLE_PORT_PARAMS buffer converted to ReadOnlySpan<byte> input and mutable Span<byte> output for DeviceIoControl call.

🐰 The pointers take flight,
Safe Spans now guide each call,
Win32 dreams in light!

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately captures both major components of the changeset: dependency version updates across multiple project files and refactoring of PInvoke calls to use modern Span-based patterns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Generator/DeviceManagementPropertiesGenerator.csproj`:
- Around line 16-25: The PackageReference for Microsoft.Windows.CsWin32 is
pinned to Version="0.3.279" which is not available on the configured NuGet
feeds; open the PackageReference element PackageReference
Include="Microsoft.Windows.CsWin32" Version="0.3.279" and update the Version
attribute to a release that exists on your feeds (check nuget.org or your winsdk
feed for the latest available 0.3.x or stable version) or add the correct feed
that hosts 0.3.279 so the project can restore successfully.

In `@src/Nefarius.Utilities.DeviceManagement.csproj`:
- Around line 29-34: The referenced Microsoft.Windows.CsWin32 version 0.3.279 in
Nefarius.Utilities.DeviceManagement.csproj and
DeviceManagementPropertiesGenerator.csproj is not available on the public NuGet
flatcontainer—validate that exact CsWin32 0.3.279 exists on the intended feed or
replace it with a published version; either point both projects to a confirmed
CsWin32 package (or your private feed) to keep generator/runtime alignment, or
bump both projects to a known-published CsWin32 version and ensure
Microsoft.Windows.SDK.Win32Metadata (70.0.11-preview) remains compatible by
reviewing its release notes for any P/Invoke signature changes before committing
the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a0392049-7d93-4816-846d-64fc0ebe21c3

📥 Commits

Reviewing files that changed from the base of the PR and between 43264c4 and cc58ae3.

📒 Files selected for processing (8)
  • Tests/Tests.csproj
  • src/Generator/DeviceManagementPropertiesGenerator.csproj
  • src/Nefarius.Utilities.DeviceManagement.csproj
  • src/PnP/Devcon.cs
  • src/PnP/DeviceClassFilters.cs
  • src/PnP/PnPDevice.Properties.cs
  • src/PnP/PnPDevice.Static.cs
  • src/PnP/UsbPnPDevice.cs

Comment thread src/Generator/DeviceManagementPropertiesGenerator.csproj
Comment thread src/Nefarius.Utilities.DeviceManagement.csproj
@nefarius nefarius changed the title Updated all dependencies Update dependencies and refactor PInvoke calls to use Span-based patterns May 30, 2026
@nefarius nefarius merged commit 82cfe3e into master May 30, 2026
2 checks passed
@nefarius nefarius deleted the deps-update branch May 30, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant