[Repo Assist] improve: remove System.Linq from SystemCapability#213
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Draft
Conversation
Replace three LINQ chains with explicit loops to match the no-LINQ pattern already established throughout the codebase (ExecShellWrapperParser, NodeCapabilities, OpenClawGatewayClient, etc.): - ResolveExecutable: AddRange+Select → foreach+Add when building the PATHEXT extensions list; eliminates the lazy IEnumerable allocation from Enumerable.Select. - HandleExecApprovalsGet: Rules.Select(...).ToArray() → indexed for-loop into pre-allocated object[rules.Count]; removes the intermediate IEnumerable<> iterator allocation. - HandleExecApprovalsSet shells parsing: .Where(...).Select(...).ToArray() → foreach with explicit ValueKind guard; pre-sizes the List<string> from GetArrayLength() to avoid re-allocation on resize. Also removes the now-unused 'using System.Linq;' import. No behaviour change; 652 Shared tests pass, 20 skipped. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
13 tasks
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.
🤖 This is an automated PR from Repo Assist.
Removes the
using System.Linq;dependency fromSystemCapability.cs, replacing three LINQ chains with explicit loops to match the pattern already established throughout the codebase (ExecShellWrapperParser,NodeCapabilities,OpenClawGatewayClient, and others that had LINQ removed in recent PRs).What changed
ResolveExecutable— PATHEXT extensions listBefore:
After:
Removes the lazy
IEnumerable<string>allocation fromEnumerable.Select. TheList<string>receives elements directly.HandleExecApprovalsGet— rules summaryBefore:
After:
Pre-allocates the output array to the exact size; avoids the intermediate
IEnumerable<>iterator +ToArray()copy.HandleExecApprovalsSet— shells array parsingBefore:
After:
Pre-sizes the list from
GetArrayLength()(avoids resize), uses a simple guard instead of.Where(), and setsShells = nullfor empty arrays (matching theis { Length: > 0 }pattern inExecApprovalPolicy.Evaluate).Test Status
dotnet test OpenClaw.Shared.Tests— 652 passed, 20 skipped (unchanged from baseline)