Core - Automatically merge enable-features/disable-features command-line arguments with existing values#5245
Core - Automatically merge enable-features/disable-features command-line arguments with existing values#5245SLT-World wants to merge 2 commits into
enable-features/disable-features command-line arguments with existing values#5245Conversation
…-line arguments with existing values
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds a configurable setting to control how feature-related command-line arguments ( ChangesFeature Command-Line Argument Merge Control
Sequence Diagram(s)sequenceDiagram
participant Client
participant CefSharpApp
participant CefSharpSettings
participant CommandLine
Client->>CefSharpApp: supply enable-features / disable-features arg
CefSharpApp->>CefSharpSettings: read MergeFeaturesCommandLineArgs
alt Merge enabled
CefSharpApp->>CommandLine: read existing switch value
CommandLine-->>CefSharpApp: existingValue
CefSharpApp->>CefSharpApp: compare and append missing features
CefSharpApp->>CommandLine: set updated switch value
else Merge disabled
CefSharpApp->>CommandLine: remove existing switch
CefSharpApp->>CommandLine: set switch = incomingValue
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CefSharp.Core.Runtime/Internals/CefSharpApp.h`:
- Around line 212-228: The substring check using currentValue->Contains causes
incorrect duplicate detection; in the block gated by
CefSharpSettings::MergeFeaturesCommandLineArgs (around
commandLine->GetSwitchValue/name handling), replace the Contains-based logic
with proper comma-separated token parsing: split the existingValue (via
StringUtils::ToClr(existingValue)) and the incoming kvp->Value by commas, trim
whitespace, build a case-sensitive set/list of existing tokens, iterate the
incoming tokens and add only those not already present, then reconstruct the
merged comma-separated string and call commandLine->RemoveSwitch(name);
commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(mergedValue));
this ensures exact-feature matching and correctly handles multi-feature inputs
like "Feature1,Feature2".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cdc755c2-d284-4ddc-b997-e038c8368ec6
📒 Files selected for processing (2)
CefSharp.Core.Runtime/Internals/CefSharpApp.hCefSharp/CefSharpSettings.cs
| if (CefSharpSettings::MergeFeaturesCommandLineArgs) | ||
| { | ||
| CefString existingValue = commandLine->GetSwitchValue(name); | ||
| if (existingValue.empty()) | ||
| { | ||
| commandLine->AppendSwitchWithValue(name, value); | ||
| } | ||
| else | ||
| { | ||
| String^ currentValue = StringUtils::ToClr(existingValue); | ||
| if (!currentValue->Contains(kvp->Value)) | ||
| { | ||
| commandLine->RemoveSwitch(name); | ||
| commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(currentValue + "," + kvp->Value)); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Substring matching causes incorrect duplicate detection for feature lists.
The Contains() check at Line 222 uses substring matching instead of parsing the comma-separated feature list, leading to correctness issues:
False positives (features incorrectly detected as present):
- Existing:
"AutofillActorMode", New:"Autofill"→ Contains returns true,"Autofill"never added - Existing:
"EnableHangWatcher", New:"Hang"→ Contains returns true,"Hang"never added
Missing features when adding multiple features:
- Existing:
"Feature1", New:"Feature1,Feature2"→ Contains returns true,"Feature2"never added
Correct approach:
Split both the existing value and the new value by commas, then check each individual feature for presence before merging.
🐛 Proposed fix using proper comma-separated list handling
if (CefSharpSettings::MergeFeaturesCommandLineArgs)
{
CefString existingValue = commandLine->GetSwitchValue(name);
if (existingValue.empty())
{
commandLine->AppendSwitchWithValue(name, value);
}
else
{
- String^ currentValue = StringUtils::ToClr(existingValue);
- if (!currentValue->Contains(kvp->Value))
- {
- commandLine->RemoveSwitch(name);
- commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(currentValue + "," + kvp->Value));
- }
+ String^ currentValue = StringUtils::ToClr(existingValue);
+ auto existingFeatures = gcnew HashSet<String^>(currentValue->Split(','));
+ auto newFeatures = kvp->Value->Split(',');
+ bool hasNewFeature = false;
+ for each (String^ feature in newFeatures)
+ {
+ if (!existingFeatures->Contains(feature))
+ {
+ existingFeatures->Add(feature);
+ hasNewFeature = true;
+ }
+ }
+ if (hasNewFeature)
+ {
+ commandLine->RemoveSwitch(name);
+ commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(String::Join(",", existingFeatures)));
+ }
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (CefSharpSettings::MergeFeaturesCommandLineArgs) | |
| { | |
| CefString existingValue = commandLine->GetSwitchValue(name); | |
| if (existingValue.empty()) | |
| { | |
| commandLine->AppendSwitchWithValue(name, value); | |
| } | |
| else | |
| { | |
| String^ currentValue = StringUtils::ToClr(existingValue); | |
| if (!currentValue->Contains(kvp->Value)) | |
| { | |
| commandLine->RemoveSwitch(name); | |
| commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(currentValue + "," + kvp->Value)); | |
| } | |
| } | |
| } | |
| if (CefSharpSettings::MergeFeaturesCommandLineArgs) | |
| { | |
| CefString existingValue = commandLine->GetSwitchValue(name); | |
| if (existingValue.empty()) | |
| { | |
| commandLine->AppendSwitchWithValue(name, value); | |
| } | |
| else | |
| { | |
| String^ currentValue = StringUtils::ToClr(existingValue); | |
| auto existingFeatures = gcnew HashSet<String^>(currentValue->Split(',')); | |
| auto newFeatures = kvp->Value->Split(','); | |
| bool hasNewFeature = false; | |
| for each (String^ feature in newFeatures) | |
| { | |
| if (!existingFeatures->Contains(feature)) | |
| { | |
| existingFeatures->Add(feature); | |
| hasNewFeature = true; | |
| } | |
| } | |
| if (hasNewFeature) | |
| { | |
| commandLine->RemoveSwitch(name); | |
| commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(String::Join(",", existingFeatures))); | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@CefSharp.Core.Runtime/Internals/CefSharpApp.h` around lines 212 - 228, The
substring check using currentValue->Contains causes incorrect duplicate
detection; in the block gated by CefSharpSettings::MergeFeaturesCommandLineArgs
(around commandLine->GetSwitchValue/name handling), replace the Contains-based
logic with proper comma-separated token parsing: split the existingValue (via
StringUtils::ToClr(existingValue)) and the incoming kvp->Value by commas, trim
whitespace, build a case-sensitive set/list of existing tokens, iterate the
incoming tokens and add only those not already present, then reconstruct the
merged comma-separated string and call commandLine->RemoveSwitch(name);
commandLine->AppendSwitchWithValue(name, StringUtils::ToNative(mergedValue));
this ensures exact-feature matching and correctly handles multi-feature inputs
like "Feature1,Feature2".
|
✅ Build CefSharp 147.0.100-CI5477 completed (commit c7cf2e36e2 by @SLT-World) |
|
✅ Build CefSharp 147.0.100-CI5478 completed (commit 754ee7190c by @SLT-World) |
|
✅ Build CefSharp 147.0.100-CI5479 completed (commit a61bfb6978 by @SLT-World) |
Core - Automatically merge
enable-features/disable-featurescommand-line arguments with existing values.Fixes: #5244
Summary:
enable-features/disable-featurescommand-line arguments with existing values.Containscheck was added to mitigate that issue.Changes: [specify the structures changed]
CefSharpApp.handCefSharpSettings.cs.MergeFeaturesCommandLineArgsto CefSharpSettings, defaults to true.enable-featuresanddisable-featureslists inCefSharpApp.h.How Has This Been Tested?
Operating System: Windows 11
Environment: Visual Studio 2022
Changes visibly function after appending and modifying
within
App.xaml.csinCefSharp.Wpf.HwndHost.Example.Screenshots (if appropriate):

Types of changes
Checklist:
Summary by CodeRabbit