Repository navigation
Conversation
…temEnumerator buffer Agent-Logs-Url: https://github.com/teo-tsirpanis/dotnet-runtime/sessions/233c35f2-6fa4-4409-b093-93f4a80a0598 Co-authored-by: teo-tsirpanis <[email protected]>
… cast Agent-Logs-Url: https://github.com/teo-tsirpanis/dotnet-runtime/sessions/c20f57ce-bd4d-4583-90a1-c799d80ee39e Co-authored-by: teo-tsirpanis <[email protected]>
|
Tagging subscribers to this area: @dotnet/area-system-io |
There was a problem hiding this comment.
Pull request overview
This PR fixes Windows-specific implementation details in FileSystemEnumerator<TResult> to ensure the intended OS behaviors are actually applied and to make the NT query buffer’s alignment requirement explicit.
Changes:
- Replace
using (default(DisableMediaInsertionPrompt))withusing (DisableMediaInsertionPrompt.Create())so the media insertion prompt suppression is actually enabled. - Allocate the directory query buffer via
NativeMemory.AlignedAlloc(..., sizeof(ulong))and free it viaNativeMemory.AlignedFree, switching_bufferfromIntPtrtovoid*. - Update the
NtQueryDirectoryFileinterop signature to acceptvoid*forFileInformation, matching the updated buffer type.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs |
Uses the correct prompt-suppression factory and switches the query buffer to explicitly aligned native allocation. |
src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs |
Updates the P/Invoke signature to take a raw pointer for the output buffer. |
adamsitnik
left a comment
There was a problem hiding this comment.
@JeremyKuhne PTAL
Thank you for your contribution @teo-tsirpanis !
JeremyKuhne
left a comment
There was a problem hiding this comment.
Generally looks fine, see my comment on removing the broken suppression.
adamsitnik
left a comment
There was a problem hiding this comment.
LGTM, thank you @teo-tsirpanis !
|
Workflow state for the Holistic Review Orchestrator. {
"version": 5,
"last_dispatched_commit": "c7575244ccabb4805405dfff2f6eebfec123eec7",
"last_dispatched_base_ref": "main",
"last_dispatched_base_sha": "cb84c8521ce6a4cbde63cb1a700fcb850be791ae",
"last_reviewed_commit": "c7575244ccabb4805405dfff2f6eebfec123eec7",
"last_reviewed_base_ref": "main",
"last_reviewed_base_sha": "cb84c8521ce6a4cbde63cb1a700fcb850be791ae",
"last_recorded_worker_run_id": "29689521922",
"review_attempt_commit": "",
"review_attempt_base_ref": "",
"review_attempt_count": 0,
"max_review_attempts": 5,
"review_history_format": "holistic-review-disclosure-v1",
"review_history": [
{
"commit": "567dacdda9f2fc7b65576203789ac94e117cfbe9",
"review_id": 4730178051
},
{
"commit": "c7575244ccabb4805405dfff2f6eebfec123eec7",
"review_id": 4730872254
}
]
} |
There was a problem hiding this comment.
Holistic Review
Motivation: Small cleanups in the Windows FileSystemEnumerator implementation: remove an ineffective use of DisableMediaInsertionPrompt, make the NtQueryDirectoryFile buffer's alignment requirement explicit, and modernize the interop signature.
Approach: The default(DisableMediaInsertionPrompt) guard in Init() is removed. Because it was constructed via default, its _disableSuccess field was always false, so SetThreadErrorMode was never called and Dispose() was a no-op — the prompt was never actually suppressed. Removing it is therefore behavior-preserving. The buffer is switched from Marshal.AllocHGlobal/FreeHGlobal to NativeMemory.AlignedAlloc/AlignedFree with an explicit 8-byte (sizeof(ulong)) alignment, documenting the LONGLONG alignment requirement of FILE_FULL_DIR_INFORMATION. The _buffer field and the NtQueryDirectoryFile FileInformation parameter change from IntPtr to void*, and disposal null checks are updated accordingly.
Summary: The change is correct and self-consistent. NativeMemory.AlignedAlloc guarantees the required 8-byte alignment (stronger than the previous implicit LocalAlloc alignment) and does not require the size to be a multiple of the alignment, so the existing _bufferLength values are fine. The try/catch around allocation still frees on failure, and disposal now correctly pairs AlignedFree with AlignedAlloc and null-checks the pointer. The interop signature change to void* is confined to the single caller. No functional regression is apparent and the alignment intent is now clearer. LGTM.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 47.6 AIC · ⌖ 14.5 AIC · ⊞ 10K
There was a problem hiding this comment.
Holistic Review
Motivation: Small cleanups in the Windows FileSystemEnumerator implementation: remove an ineffective use of DisableMediaInsertionPrompt, make the NtQueryDirectoryFile buffer's alignment requirement explicit, and modernize the interop signature.
Approach: The default(DisableMediaInsertionPrompt) guard in Init() is removed (behavior-preserving, since the default-constructed value never called SetThreadErrorMode). The buffer moves from Marshal.AllocHGlobal/FreeHGlobal to NativeMemory.AlignedAlloc/AlignedFree with an explicit 8-byte (sizeof(ulong)) alignment documenting the LONGLONG alignment requirement of FILE_FULL_DIR_INFORMATION, and the _buffer field plus the NtQueryDirectoryFile FileInformation parameter change from IntPtr to void*.
Summary: The PR patch has not changed since the prior review: the current and previous patch IDs are identical (a113cb1d), and only the merge base moved, indicating the PR was retargeted/rebased onto main with no new commits. There are no incremental changes to review and no new actionable findings. The cumulative assessment is unchanged: the change is correct, self-consistent, and behavior-preserving, with the alignment intent now clearer. LGTM.
Assessment History:
- review 4730178051 (commit 567dacd): verdict LGTM. Current verdict: LGTM. Unchanged — the PR patch is identical after the retarget, so motivation, approach, and risk assessment all remain the same.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 29 AIC · ⌖ 10.4 AIC · ⊞ 10K
|
@JeremyKuhne could you please re-approve the PR? I can't merge it after you have requested changes. Thanks! |
Since the code is windows only, it can just use |
Co-authored-by: Jan Kotas <[email protected]>
Note
This PR was created with the assistance of GitHub Copilot.
Replaced ineffective use ofRemoved, after PR feedback.default(DisableMediaInsertionPrompt), withDisableMediaInsertionPrompt.Create()._bufferwas updated to be backed byNativeMemory.AlignedAllocinstead ofMarshal.AllocHGlobal. This makes the alignment requirement explicit and might increase performance.