Conversation
…pped.Unix.cs, remove ILLink workaround Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
|
Tagging subscribers to this area: @agocke, @VSadov |
|
@copilot Merge from main and resolve conflicts |
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Show resolved
Hide resolved
…ate-overlapped-implementations
Done in 2ef8f8f. Merged main and resolved the conflict in |
…PortableThreadPool block Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Show resolved
Hide resolved
...aries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_PreAllocatedOverlappedTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR simplifies ThreadPoolBoundHandle / PreAllocatedOverlapped on non-Windows by consolidating them into platform-not-supported implementations (since overlapped I/O is unsupported there), while also cleaning up CoreLib project item conditions and removing an outdated ILLink descriptor workaround.
Changes:
- Replace non-Windows
PreAllocatedOverlapped/ThreadPoolBoundHandleimplementations with unified*.PlatformNotSupported.csstubs; delete old Unix/Browser variants. - Reorganize
System.Private.CoreLib.Shared.projitemsto group Windows-only thread-pool/overlapped files underTargetsWindows == true, and simplify non-Windows conditions underTargetsWindows != true. - Remove stale ILLink descriptor for
ThreadPoolBoundHandleand update tests to be Windows-specific where behavior is now PNSE on non-Windows.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_PreAllocatedOverlappedTests.cs | Marks several PreAllocatedOverlapped argument-validation tests as Windows-only. |
| src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.Unix.cs | Deletes the non-Windows implementation. |
| src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs | Adds Debug.Fail in private ctor; otherwise provides PNSE-based stub surface. |
| src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.Unix.cs | Deletes the Unix implementation. |
| src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.PlatformNotSupported.cs | Adds a new non-Windows PNSE-based implementation. |
| src/libraries/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.Browser.cs | Removes the old Browser stub. |
| src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems | Moves/retargets compile-item conditions to align Windows vs non-Windows grouping and portable threadpool layout. |
| src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.Shared.xml | Removes outdated ILLink preservation descriptor for ThreadPoolBoundHandle. |
Comments suppressed due to low confidence (1)
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs:16
- In the platform-not-supported implementation,
Handlecurrently returnsnull!and the private ctor only containsDebug.Fail(which is removed in Release). This means an instance created via reflection/serialization could exist and then fail withNullReferenceExceptionrather than a consistentPlatformNotSupportedException. Consider making the ctor and/orHandlegetter throwPlatformNotSupportedException(SR.PlatformNotSupported_OverlappedIO)to keep all entry points consistently unsupported.
...s/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.PlatformNotSupported.cs
Show resolved
Hide resolved
|
@copilot Merge from main and resolve conflicts |
…ate-overlapped-implementations # Conflicts: # src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.Unix.cs
Done in c9fc2bb. Merged main (2 new commits: |
...es/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.PlatformNotSupported.cs
Show resolved
Hide resolved
…pped* methods Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolBoundHandle.Portable.cs
Show resolved
Hide resolved
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
PreAllocatedOverlappedandThreadPoolBoundHandlehad separate implementations for non-Windows platforms: full portable/Unix partial-class implementations for Unix and Browser with managed threads, and stub files for Browser/Wasi without managed threads — despite overlapped I/O being unsupported (ThreadPoolBoundHandle.BindHandlealways throwsPlatformNotSupportedException) on all non-Windows targets.Description
PreAllocatedOverlapped.PlatformNotSupported.cs— standalone class whose constructor andUnsafeCreatecallArgumentNullException.ThrowIfNull(callback)before throwingPlatformNotSupportedException(SR.PlatformNotSupported_OverlappedIO); replaces the old no-opBrowser.csstub and the portable/Unix partial-class pair for all non-Windows targets.ThreadPoolBoundHandle.Browser.cs→ThreadPoolBoundHandle.PlatformNotSupported.cs— preserves the existing "all methods throwPlatformNotSupportedException" behavior under a platform-neutral name; private constructor now containsDebug.Fail("Unreachable")to document that the constructor can never legitimately be reached.PreAllocatedOverlapped.Unix.csandThreadPoolBoundHandle.Unix.cs— no longer needed; all non-Windows platforms now use thePlatformNotSupported.csstandalone classes.PreAllocatedOverlapped.Portable.csandThreadPoolBoundHandle.Portable.csWindows-only in theFeaturePortableThreadPoolblock — the portable partial-class cores are only required on Windows where the thread pool can be configured at runtime.PlatformNotSupported.csfiles into a singleCondition="'$(TargetsWindows)' != 'true'"ItemGroup outside theFeaturePortableThreadPoolblock — replaces both the per-entry non-Windows conditions insideFeaturePortableThreadPooland the oldFeatureMultithreading != trueblock, covering all non-Windows targets (with or without managed threads) in one place.ThreadPoolBoundHandleOverlapped.csto the platform-neutralTargetsWindows == truesection — moved out of theFeaturePortableThreadPoolblock and into the large Windows-only ItemGroup alongsideThreadPoolBoundHandle.WindowsThreadPool.csandPreAllocatedOverlapped.WindowsThreadPool.cs, so it is available to all Windows thread pool configurations.Win32ThreadPoolNativeOverlapped.cs,Win32ThreadPoolNativeOverlapped.ExecutionContextCallbackArgs.cs, andWin32ThreadPoolNativeOverlapped.OverlappedData.csto theTargetsWindows == truesection — these files are Windows-only and are now grouped with the other Windows-only thread pool files, in their correct alphabetical position betweenWaitHandle.Windows.csandWindowsThreadPool.cs.DeferredDisposableLifetime.csto the Windows-specific section — this file is only needed on Windows and is now grouped with the other Windows-only files..Unix.csconditions in theFeaturePortableThreadPoolblock to'$(TargetsWindows)' != 'true'— replaces the previous verbose per-platform conditions onThreadPool.Unix.cs,PortableThreadPool.Unix.cs, andLowLevelLifoSemaphore.Unix.cs.PreAllocatedOverlapped.*sortedPlatformNotSupported.cs→Portable.cs→Windows.cs;PreAllocatedOverlapped.WindowsThreadPool.csplaced in its correct alphabetical position in the Windows-only ItemGroup; allSystem\Threadingentries in the Windows-only section sorted alphabetically.ThreadPoolBoundHandleILLink descriptor — the workaround (preserving.interfaceimplwhen the type is not instantiated on Unix) was fixed in the linker long ago (mono/linker#649).PreAllocatedOverlapped_NullAsCallback_ThrowsArgumentNullExceptiontest runs on all platforms — argument validation (ArgumentNullExceptionfor null callback) is performed beforePlatformNotSupportedExceptionon non-Windows, following the pattern used in other places. Tests that require successful construction ofPreAllocatedOverlappedremain[PlatformSpecific(TestPlatforms.Windows)].[RequiresUnsafe]annotations —[RequiresUnsafe]was incorrectly applied (due to a merge conflict) toAllocateNativeOverlapped,UnsafeAllocateNativeOverlappedPortableCore, andAllocateNativeOverlappedPortableCoremethods inThreadPoolBoundHandle.Portable.cs, to the privateAllocateNativeOverlappedinOverlapped.cs, and toOverlapped.PackandOverlapped.UnsafePack. All these annotations are removed.Behavioral note: On all non-Windows platforms,
PreAllocatedOverlappedvalidates thecallbackargument (throwingArgumentNullExceptionif null) before throwingPlatformNotSupportedExceptionto indicate overlapped I/O is not supported. This is technically a breaking change from the previous Unix behavior where the constructor succeeded (allocating aThreadPoolBoundHandleOverlappedwhile leaking memory) even though the object could never be used.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.