-
Notifications
You must be signed in to change notification settings - Fork 0
Fix configuration precedence for OutputFormat and OutputPath (#38) #43
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
Fixes #38: Configuration values for OutputFormat and OutputPath are now properly used when included in configuration files. Changes: - Modified CompareCommand.cs to fix configuration precedence logic - Changed OutputFormat property to nullable to detect explicit user input - Fixed JSON enum serialization in ComparisonConfiguration.cs - Added comprehensive unit tests for JSON enum parsing - Added integration tests for configuration precedence scenarios The fix ensures: - Config file values are used when no CLI override is provided - Explicit CLI arguments properly override config values - JSON enum parsing works with both 'Html' and 'html' formats - Round-trip serialization maintains enum values correctly All 425 tests passing with no regressions.
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 fixes a configuration precedence issue where command line default values were incorrectly overriding configuration file values for OutputFormat and OutputPath parameters, even when users didn't explicitly provide command line arguments.
- Changed OutputFormat property to nullable to distinguish between explicit user input and automatic defaults
- Fixed JSON enum serialization to ensure consistent handling between save and load operations
- Added comprehensive test coverage for configuration precedence scenarios
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/DotNetApiDiff/Commands/CompareCommand.cs |
Fixed configuration precedence logic by making OutputFormat nullable and only overriding config values when explicitly provided |
src/DotNetApiDiff/Models/Configuration/ComparisonConfiguration.cs |
Added JsonStringEnumConverter to SaveToJsonFile method for consistent enum serialization |
tests/DotNetApiDiff.Tests/Unit/JsonEnumSerializationTests.cs |
Added comprehensive unit tests for JSON enum parsing with case variations |
tests/DotNetApiDiff.Tests/Integration/CliWorkflowTests.cs |
Added integration tests to verify configuration precedence and CLI override behavior |
tests/DotNetApiDiff.Tests/TestData/config-output-format-and-path.json |
Test configuration file with output format and path settings |
Signed-off-by: jbrinkman <[email protected]>
Fixes Windows CI failure where file paths with backslashes in JSON strings
were not properly escaped, causing JSON parsing errors.
Changes:
- Escape backslashes in outputPath interpolation for integration tests
- Use .Replace('\', '\\') to convert single backslashes to double backslashes
- Fixes both CliWorkflow tests that create JSON config files with paths
This resolves the System.Text.Json.JsonException on Windows CI builds
while maintaining compatibility with Unix-style paths on macOS/Linux.
- Fixed CliWorkflow_WithConfigFileOutputSettings_ShouldUseConfigurationValues test
- Added proper JSON escaping when replacing paths in config file content
- Use .Replace('\', '\\') to escape backslashes for Windows paths
- Resolves JSON parsing error: 'U' is an invalid escapable character
This complements the previous Windows CI fix and ensures all integration
tests work correctly on Windows by properly escaping file paths when
they are inserted into JSON configuration files.
Description
Fixes #38: Configuration values for OutputFormat and OutputPath are now properly used when included in configuration files.
Problem
The original issue was that configuration values from JSON files were being ignored due to incorrect precedence logic. Command line default values were unconditionally overriding configuration file values, even when users didn't explicitly provide command line arguments.
Solution
Core Changes
Fixed Configuration Precedence Logic (
CompareCommand.cs):OutputFormatproperty from non-nullable with default value to nullableFixed JSON Enum Serialization (
ComparisonConfiguration.cs):JsonStringEnumConvertertoSaveToJsonFilemethodTest Coverage
Added Comprehensive Unit Tests (
JsonEnumSerializationTests.cs):LoadFromJsonFilemethod functionalityAdded Integration Tests (
CliWorkflowTests.cs):CliWorkflow_ConfigurationJsonEnumParsing_ShouldParseOutputFormatCorrectly: Verifies config values are used when no CLI overrideCliWorkflow_CommandLineOverridesConfig_ShouldUseExplicitCommandLineFormat: Verifies CLI values override config when explicitly providedBehavior
✅ Before Fix
✅ After Fix
--outputargument, it correctly overrides config file valuesTesting
Files Changed
src/DotNetApiDiff/Commands/CompareCommand.cs- Fixed precedence logicsrc/DotNetApiDiff/Models/Configuration/ComparisonConfiguration.cs- Fixed JSON serializationtests/DotNetApiDiff.Tests/Integration/CliWorkflowTests.cs- Added integration teststests/DotNetApiDiff.Tests/Unit/JsonEnumSerializationTests.cs- Added unit teststests/DotNetApiDiff.Tests/TestData/config-output-format-and-path.json- Test data