-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Report invalid global.json state in dotnet --info
and hostfxr_resolve_sdk2
#118418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances global.json error reporting in dotnet --info
and the hostfxr_resolve_sdk2
API by tracking and exposing information about invalid global.json files instead of silently ignoring them.
- Tracks global.json state (not_found, valid, invalid_json, invalid_data) throughout the SDK resolution process
- Updates error reporting to provide specific error messages for JSON parsing and validation failures
- Adds new
global_json_state
result key tohostfxr_resolve_sdk2
API for telemetry purposes
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
src/native/corehost/json_parser.h | Added get_error_message() method and m_parse_error field to store parsing errors |
src/native/corehost/json_parser.cpp | Modified to store error messages instead of immediately tracing them |
src/native/corehost/hostmisc/utils.h | Added format_string utility function for creating formatted strings |
src/native/corehost/hostmisc/pal.h | Added template str_printf and strlen_printf functions for cross-platform string formatting |
src/native/corehost/fxr/sdk_resolver.h | Restructured to track global.json state and error information in global_file_info struct |
src/native/corehost/fxr/sdk_resolver.cpp | Refactored global.json parsing to return state information and detailed error messages |
src/native/corehost/fxr/hostfxr.cpp | Added global_json_state result key and corresponding state strings for the API |
src/native/corehost/fxr/command_line.cpp | Updated dotnet --info to display invalid global.json information with error details |
src/native/corehost/runtime_config.cpp | Added error tracing using the new error message functionality |
src/native/corehost/hostpolicy/deps_format.cpp | Added error tracing for dependency JSON parsing failures |
src/native/corehost/comhost/clsidmap.cpp | Updated error messages to use the new error message functionality |
Test files | Updated test expectations to match new error message formats and added tests for invalid global.json scenarios |
Co-authored-by: Copilot <[email protected]>
We currently ignore invalid global.json, which can lead to unexpected/undesired behaviour. While we're not going to change that behaviour right now, this change adds some indication about this situation in
dotnet --info
and updates ahostfxr
API to indicate if an invalid global.json was found.sdk_resolver
track/store information about global.json even when it is deemed invaliddotnet --info
to list invalid global.json file path and error messagehostfxr_resolve_sdk2_result_key_t::global_json_state
forhostfxr_resolve_sdk2
APInot_found
,valid
,invalid_json
,invalid_data
Example part of
dotnet --info
:Before:
cc @dotnet/appmodel @AaronRobinsonMSFT @richlander
Resolves #94496
Related:
global.json
version string like9.0.x
sdk#49816