You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The new FromJson template has compile-breaking template-parameter defaults and fragile iterator-to-std::string_view construction that should be corrected before merging.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR refactors shared JSON deserialization helpers to support parsing directly from iterator ranges, enabling callers to avoid allocating/copying buffers into temporary std::strings before parsing. It also updates WSLc image-import progress parsing to use the new iterator-based API.
Changes:
Added an iterator-range FromJson overload and routed existing const char* / const wchar_t* overloads through it.
Updated WSLCSession::ImportImageImpl progress parsing to parse JSON directly from the received buffer iterators.
File summaries
File
Description
src/windows/wslcsession/WSLCSession.cpp
Uses iterator-based FromJson for import-progress parsing to avoid an intermediate std::string copy.
src/shared/inc/JsonUtils.h
Introduces iterator-range JSON parsing and updates overloads/error reporting accordingly.
Review details
Suppressed comments (2)
src/shared/inc/JsonUtils.h:82
const std::string_view value{First, Last}; depends on the C++23 iterator-range constructor and on Iterator being contiguous; this is likely to break builds or callers that pass non-contiguous iterators. Since this is only used on the exception path, consider materializing a std::string from the iterator range for logging/error text instead.
FromJson(const char* Value) uses strlen(Value) but this header doesn’t include <cstring> (and on Windows stringshared.h doesn’t include it either), so this can be a fragile/implicit dependency. Prefer std::char_traits<char>::length(Value) (available via <string>) to keep the header self-contained.
T FromJson(const char* Value)
{
return FromJson<T, TJson>(Value, Value + strlen(Value));
}
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🔵 Needs a closer look
FromJson(const char*) introduces a new strlen() dependency in a header without ensuring the required include, creating a fragile transitive-include build risk.
Add explicit <cstring> include for strlen dependency
src/shared/inc/JsonUtils.h:97
FromJson(const char* Value) now depends on strlen() but this header doesn’t include <cstring>, so it relies on transitive includes and can break depending on include order/toolset. Prefer a length computation that doesn’t introduce a new header dependency (or explicitly include <cstring>).
This branch has not been deployed
No deployments
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
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.
Summary of the Pull Request
This change reworks the json parsing logic to work with iterators, which avoids having to copy the entire json into a std::string in some places
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed