Conversation
|
🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new CSS bundling tool for BootstrapBlazor that combines multiple CSS files into a single output file based on JSON configuration.
- Adds a new console application
BootstrapBlazor.CssBundleras a .NET tool - Implements CSS file bundling functionality with JSON-based configuration
- Includes command-line argument parsing and help text
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/BootstrapBlazor.CssBundler/Program.cs | Entry point for the CSS bundler tool |
| src/tools/BootstrapBlazor.CssBundler/BundlerOptions.cs | Configuration model for bundler settings |
| src/tools/BootstrapBlazor.CssBundler/Bundler.cs | Core bundling logic and file processing |
| src/tools/BootstrapBlazor.CssBundler/BootstrapBlazor.CssBundler.csproj | Project configuration for the bundler tool |
| src/tools/BootstrapBlazor.CssBundler/ArgumentsHelper.cs | Command-line argument parsing and help display |
| BootstrapBlazor.Extensions.slnx | Solution file update to include the new tool project |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Remove the hard-coded absolute path in the DEBUG block or make it configurable to avoid environment-specific dependencies.
- Consider using a dedicated CLI parser (e.g. System.CommandLine) instead of manual args parsing to support flags, defaults, and validation.
- When concatenating files, insert separators (e.g. newlines or comments) between inputs and add basic exception handling to improve robustness.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Remove the hard-coded absolute path in the DEBUG block or make it configurable to avoid environment-specific dependencies.
- Consider using a dedicated CLI parser (e.g. System.CommandLine) instead of manual args parsing to support flags, defaults, and validation.
- When concatenating files, insert separators (e.g. newlines or comments) between inputs and add basic exception handling to improve robustness.
## Individual Comments
### Comment 1
<location> `src/tools/BootstrapBlazor.CssBundler/Bundler.cs:62` </location>
<code_context>
+
+ using var reader = File.OpenText(inputFile);
+ reader.BaseStream.CopyTo(writer);
+ reader.Close();
+ }
+ writer.Close();
</code_context>
<issue_to_address>
**nitpick:** Explicitly calling Close on a 'using' resource is redundant.
The explicit Close call on 'reader' can be removed, as disposal is handled by the 'using' statement.
</issue_to_address>
### Comment 2
<location> `src/tools/BootstrapBlazor.CssBundler/Bundler.cs:40-43` </location>
<code_context>
+ return;
+ }
+
+ if (option.InputFiles.Count == 0)
+ {
+ return;
+ }
+
</code_context>
<issue_to_address>
**suggestion:** Empty input files list is silently ignored.
Log a message when no input files are provided to notify the user that no bundling occurred.
```suggestion
if (option.InputFiles.Count == 0)
{
Console.WriteLine("No input files provided. Bundling was skipped.");
return;
}
```
</issue_to_address>
### Comment 3
<location> `src/tools/BootstrapBlazor.CssBundler/Bundler.cs:52-58` </location>
<code_context>
+ foreach (var file in option.InputFiles)
+ {
+ var inputFile = Path.Combine(rootFolder, file);
+ if (!File.Exists(inputFile))
+ {
+ continue;
+ }
+
</code_context>
<issue_to_address>
**suggestion:** Missing input files are skipped without notification.
Log a warning for each missing file to improve visibility and troubleshooting.
```suggestion
foreach (var file in option.InputFiles)
{
var inputFile = Path.Combine(rootFolder, file);
if (!File.Exists(inputFile))
{
Console.WriteLine($"[Warning] Input file not found: {inputFile}");
continue;
}
```
</issue_to_address>
### Comment 4
<location> `src/tools/BootstrapBlazor.CssBundler/BundlerOptions.cs:20` </location>
<code_context>
+ {
+ var json = File.ReadAllText(configFile);
+
+ return JsonSerializer.Deserialize<BundlerOptions>(json, JsonSerializerOptions.Web) ?? new();
+ }
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** Deserialization may fail silently and fallback to empty options.
Malformed config files result in default options without notifying the user. Please handle deserialization errors and inform the user when loading fails.
</issue_to_address>
### Comment 5
<location> `src/tools/BootstrapBlazor.CssBundler/Bundler.cs:35` </location>
<code_context>
+ {
+ var option = BundlerOptions.LoadFromConfigFile(bundlerFile);
+
+ if (string.IsNullOrEmpty(option.OutputFileName))
+ {
+ return;
</code_context>
<issue_to_address>
**issue (complexity):** Consider combining early-return checks and removing redundant resource disposal for clearer and safer code.
```suggestion
// 1. Collapse the three early-return guards into one for clarity
if (string.IsNullOrEmpty(option.OutputFileName)
|| option.InputFiles.Count == 0
|| string.IsNullOrEmpty(rootFolder))
{
return;
}
var outputPath = Path.Combine(rootFolder, option.OutputFileName);
// 2. Remove manual Close() calls and simplify merging
// Option A: Read all text into a StringBuilder and write once
var sb = new StringBuilder();
foreach (var relative in option.InputFiles)
{
var inputPath = Path.Combine(rootFolder, relative);
if (!File.Exists(inputPath)) continue;
sb.AppendLine(File.ReadAllText(inputPath));
}
File.WriteAllText(outputPath, sb.ToString());
// Option B: Stream-copy without redundant Close()
using (var output = File.Create(outputPath))
{
foreach (var relative in option.InputFiles)
{
var inputPath = Path.Combine(rootFolder, relative);
if (!File.Exists(inputPath)) continue;
using var input = File.OpenRead(inputPath);
input.CopyTo(output);
}
}
Console.WriteLine($"Bundler Completed .... {option.OutputFileName}");
```
- Combined the three `if (…) return;` checks into a single guard.
- Removed explicit `reader.Close()`/`writer.Close()`: `using`/`using var` already disposes.
- Demonstrated both a memory‐buffered (`StringBuilder` + `WriteAllText`) and a streaming approach—pick the one that best fits your load size.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Link issues
fixes #575
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add a new BootstrapBlazor.CssBundler console tool to concatenate CSS files based on a JSON configuration.
New Features:
Build: