Repository navigation
Convert hostfxr error-writer callback to an UnmanagedCallersOnly method - #56276
Merged
jkotas merged 3 commits intoSep 15, 2026
Merged
Conversation
…ativeWrapper Co-authored-by: jkotas <[email protected]>
Co-authored-by: jkotas <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot
AI
changed the title
Convert marshalled error-writer delegate to an UnmanagedCallersOnly method
Convert hostfxr error-writer callback to an UnmanagedCallersOnly method
Sep 11, 2026
jkotas
reviewed
Sep 11, 2026
Co-authored-by: jkotas <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
|
This was found by dotnet/runtime#133675 . We are going to fix the bug in Marshal.GetFunctionPointerForDelegate too, but it would be best to avoid Marshal.GetFunctionPointerForDelegate in the first place. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Restore the OS guard before creating SetupConfiguration to preserve non-Windows/Mono behavior.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Converts the modern hostfxr error-writer callback to an UnmanagedCallersOnly method while retaining the .NET Framework fallback.
Changes:
- Adds a Cdecl unmanaged callback for modern .NET.
- Retains delegate marshalling for .NET Framework.
- Updates platform detection and resolver settings initialization.
File summaries
| File | Summary |
|---|---|
src/Resolvers/Microsoft.DotNet.SdkResolver/VSSettings.cs |
Adjusts Visual Studio settings initialization; the platform guard should be retained. |
src/Resolvers/Microsoft.DotNet.NativeWrapper/NETCoreSdkResolverNativeWrapper.cs |
Uses the unmanaged hostfxr error callback. |
src/Resolvers/Microsoft.DotNet.NativeWrapper/Interop.cs |
Updates callback declarations and platform detection. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
jkoritzinsky
approved these changes
Sep 15, 2026
jkotas
deleted the
copilot/convert-marshalled-delegate-to-unmanagedcallersonl
branch
September 15, 2026 02:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NETCoreSdkResolverNativeWrapper.GetGlobalJsonStateinstalled its no-op hostfxr error writer via a managed delegate marshalled withMarshal.GetFunctionPointerForDelegate.Marshal.GetFunctionPointerForDelegateis a problematic API for both reliability and performance reasons. It should be avoided in modern interop where possible.