Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Top-level EditorConfig for DbDiff (.NET 10 / C# 14)
# Docs: https://learn.microsoft.com/dotnet/fundamentals/code-analysis/configuration-options

root = true

# Global defaults
[*]
charset = utf-8
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
max_line_length = 120

# C# files
[*.cs]
######## Formatting ########
# Braces and new lines
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true

# Indentation
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_switch_labels = true
csharp_indent_case_contents = true
csharp_indent_labels = one_less_than_current
csharp_indent_case_contents_when_block = true

# Spacing
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_around_binary_operators = before_and_after

# Using directives
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = true
csharp_using_directive_placement = inside_namespace:suggestion

######## Code style ########
# Qualification
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# 'var' preferences
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion

# Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion

# Pattern matching and null handling
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion

# Other modern C# features
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_readonly_struct_member = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_prefer_top_level_statements = true:suggestion

# Using 'nameof' where appropriate
dotnet_style_prefer_nameof_expression = true:suggestion

# Prefer collection/object initializers
dotnet_style_collection_initializer = true:suggestion
dotnet_style_object_initializer = true:suggestion

# Access modifiers
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

# Parentheses
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = never_if_unnecessary

# File header (optional). Not enforced by default.

######## Naming ########
# Symbols
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_fields.required_modifiers =

dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly

dotnet_naming_symbols.constants.applicable_kinds = field
dotnet_naming_symbols.constants.required_modifiers = const

dotnet_naming_symbols.interfaces.applicable_kinds = interface

dotnet_naming_symbols.types.applicable_kinds = class, struct, enum, delegate

# Styles
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.camel_case.capitalization = camel_case

dotnet_naming_style.camel_case_underscore.capitalization = camel_case
dotnet_naming_style.camel_case_underscore.required_prefix = _

dotnet_naming_style.prefix_i_pascal.capitalization = pascal_case
dotnet_naming_style.prefix_i_pascal.required_prefix = I

# Rules
dotnet_naming_rule.private_fields_underscore.symbols = private_fields
dotnet_naming_rule.private_fields_underscore.style = camel_case_underscore
dotnet_naming_rule.private_fields_underscore.severity = suggestion

dotnet_naming_rule.static_readonly_fields_style.symbols = static_readonly_fields
dotnet_naming_rule.static_readonly_fields_style.style = camel_case
dotnet_naming_rule.static_readonly_fields_style.severity = suggestion

dotnet_naming_rule.constants_pascal.symbols = constants
dotnet_naming_rule.constants_pascal.style = pascal_case
dotnet_naming_rule.constants_pascal.severity = suggestion

dotnet_naming_rule.interfaces_with_i_prefix.symbols = interfaces
dotnet_naming_rule.interfaces_with_i_prefix.style = prefix_i_pascal
dotnet_naming_rule.interfaces_with_i_prefix.severity = suggestion

dotnet_naming_rule.types_pascal.symbols = types
dotnet_naming_rule.types_pascal.style = pascal_case
dotnet_naming_rule.types_pascal.severity = suggestion

######## Analyzer severities ########
# Start with info/warnings to avoid noisy builds; adjust per team preference.
dotnet_analyzer_diagnostic.category-Style.severity = suggestion
dotnet_analyzer_diagnostic.category-Design.severity = warning
dotnet_analyzer_diagnostic.category-Maintainability.severity = warning
dotnet_analyzer_diagnostic.category-Naming.severity = suggestion
dotnet_analyzer_diagnostic.category-Reliability.severity = warning
dotnet_analyzer_diagnostic.category-Security.severity = warning

# Treat compiler warnings as build warnings (not errors) by default
dotnet_analyzer_diagnostic.severity = warning
14 changes: 7 additions & 7 deletions src/DbDiff.Application.Tests/PathValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void ValidateOutputPath_WithAllowedBasePath_WhenPathIsOutsideBase_ThrowsU
var outputPath = Path.Combine(Path.GetTempPath(), "outside", "output.txt");

// Act & Assert
Assert.Throws<UnauthorizedAccessException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
PathValidator.ValidateOutputPath(outputPath, basePath));
}

Expand All @@ -104,15 +104,15 @@ public void ValidateOutputPath_WithSystemDirectory_ThrowsUnauthorizedAccessExcep
}

// Act & Assert
Assert.Throws<UnauthorizedAccessException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
PathValidator.ValidateOutputPath(systemPath));
}

[Fact]
public void ValidateOutputPath_WithInvalidCharacters_ThrowsArgumentException()
{
// Arrange
var invalidPath = OperatingSystem.IsWindows()
var invalidPath = OperatingSystem.IsWindows()
? "output/file<>*.txt" // <, >, * are invalid on Windows
: "output/file\0.txt"; // null character is invalid on Unix

Expand Down Expand Up @@ -160,7 +160,7 @@ public void ValidateConfigPath_WithNonExistentFile_ThrowsFileNotFoundException()
var nonExistentPath = Path.Combine(Path.GetTempPath(), "nonexistent-config.json");

// Act & Assert
Assert.Throws<FileNotFoundException>(() =>
Assert.Throws<FileNotFoundException>(() =>
PathValidator.ValidateConfigPath(nonExistentPath));
}

Expand All @@ -174,7 +174,7 @@ public void ValidateConfigPath_WithNonJsonFile_ThrowsArgumentException()
try
{
// Act & Assert
Assert.Throws<ArgumentException>(() =>
Assert.Throws<ArgumentException>(() =>
PathValidator.ValidateConfigPath(tempTextFile));
}
finally
Expand All @@ -196,7 +196,7 @@ public void ValidateConfigPath_WithAllowedBasePath_WhenFileIsOutsideBase_ThrowsU
try
{
// Act & Assert
Assert.Throws<UnauthorizedAccessException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
PathValidator.ValidateConfigPath(configFile, basePath));
}
finally
Expand Down Expand Up @@ -251,7 +251,7 @@ public void ValidateLogPath_WithSystemDirectory_ThrowsUnauthorizedAccessExceptio
}

// Act & Assert
Assert.Throws<UnauthorizedAccessException>(() =>
Assert.Throws<UnauthorizedAccessException>(() =>
PathValidator.ValidateLogPath(systemLogPath));
}

Expand Down
2 changes: 1 addition & 1 deletion src/DbDiff.Application/DTOs/SchemaExportRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public SchemaExportRequest(string connectionString, string outputPath)
{
if (string.IsNullOrWhiteSpace(connectionString))
throw new ArgumentException("Connection string cannot be null or empty.", nameof(connectionString));

// Validate and sanitize the output path to prevent path traversal attacks
OutputPath = PathValidator.ValidateOutputPath(outputPath);
ConnectionString = connectionString;
Expand Down
7 changes: 3 additions & 4 deletions src/DbDiff.Application/Formatters/CustomTextFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

public string Format(DatabaseSchema schema)
{
if (schema == null)
throw new ArgumentNullException(nameof(schema));
ArgumentNullException.ThrowIfNull(schema);

var sb = new StringBuilder();

// Header section
sb.AppendLine($"DATABASE: {schema.DatabaseName}");

Check warning on line 16 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / build-and-test

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 16 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 16 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 16 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 16 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 16 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 16 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)
sb.AppendLine($"EXTRACTED: {schema.ExtractedAt:yyyy-MM-ddTHH:mm:ss.fffZ}");

Check warning on line 17 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / build-and-test

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 17 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 17 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 17 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 17 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 17 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 17 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)
sb.AppendLine();

// Sort tables alphabetically by full name for deterministic output
Expand All @@ -26,7 +25,7 @@

foreach (var table in sortedTables)
{
sb.AppendLine($"TABLE: {table.FullName}");

Check warning on line 28 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 28 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

// Sort columns alphabetically by name
var sortedColumns = table.Columns
Expand All @@ -35,22 +34,22 @@

foreach (var column in sortedColumns)
{
sb.AppendLine($" COLUMN: {column.Name}");

Check warning on line 37 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 37 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

if (IncludeOrdinalPosition)
sb.AppendLine($" OrdinalPosition: {column.OrdinalPosition}");

Check warning on line 40 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 40 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

sb.AppendLine($" Type: {column.DataType}");

Check warning on line 42 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 42 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)
sb.AppendLine($" Nullable: {(column.IsNullable ? "Yes" : "No")}");

Check warning on line 43 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 43 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

if (column.MaxLength.HasValue)
sb.AppendLine($" MaxLength: {column.MaxLength.Value}");

Check warning on line 46 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 46 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

if (column.Precision.HasValue)
sb.AppendLine($" Precision: {column.Precision.Value}");

Check warning on line 49 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 49 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

if (column.Scale.HasValue)
sb.AppendLine($" Scale: {column.Scale.Value}");

Check warning on line 52 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 52 in src/DbDiff.Application/Formatters/CustomTextFormatter.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (ubuntu-latest)

The behavior of 'StringBuilder.AppendLine(ref StringBuilder.AppendInterpolatedStringHandler)' could vary based on the current user's locale settings. Replace this call in 'CustomTextFormatter.Format(DatabaseSchema)' with a call to 'StringBuilder.AppendLine(IFormatProvider, ref StringBuilder.AppendInterpolatedStringHandler)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)
}

sb.AppendLine();
Expand Down
14 changes: 7 additions & 7 deletions src/DbDiff.Application/Services/SchemaExportService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DbDiff.Application.DTOs;
using DbDiff.Application.Formatters;

using Microsoft.Extensions.Logging;

namespace DbDiff.Application.Services;
Expand All @@ -11,7 +12,7 @@
private readonly ILogger<SchemaExportService> _logger;

public SchemaExportService(
ISchemaExtractor schemaExtractor,
ISchemaExtractor schemaExtractor,
ISchemaFormatter schemaFormatter,
ILogger<SchemaExportService> logger)
{
Expand All @@ -21,23 +22,22 @@
}

public async Task<SchemaExportResult> ExportSchemaAsync(
SchemaExportRequest request,
SchemaExportRequest request,
CancellationToken cancellationToken = default)
{
if (request == null)
throw new ArgumentNullException(nameof(request));
ArgumentNullException.ThrowIfNull(request);

try
{
_logger.LogInformation("Starting schema extraction from database");

Check warning on line 32 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 32 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 32 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 32 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 32 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

// Extract schema from database
var schema = await _schemaExtractor.ExtractSchemaAsync(
request.ConnectionString,
request.ConnectionString,
cancellationToken);

_logger.LogInformation("Successfully extracted schema from database {DatabaseName} with {TableCount} tables",
schema.DatabaseName,
_logger.LogInformation("Successfully extracted schema from database {DatabaseName} with {TableCount} tables",

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 39 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)
schema.DatabaseName,
schema.Tables.Count);

// Format schema to text
Expand All @@ -48,19 +48,19 @@
if (!string.IsNullOrEmpty(outputDirectory) && !Directory.Exists(outputDirectory))
{
Directory.CreateDirectory(outputDirectory);
_logger.LogDebug("Created output directory: {OutputDirectory}", outputDirectory);

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogDebug(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogDebug(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogDebug(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogDebug(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogDebug(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 51 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)
}

// Write to file
await File.WriteAllTextAsync(request.OutputPath, formattedSchema, cancellationToken);

_logger.LogInformation("Schema exported successfully to {OutputPath}", request.OutputPath);

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogInformation(ILogger, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 57 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

Evaluation of this argument may be expensive and unnecessary if logging is disabled (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1873)

return SchemaExportResult.SuccessResult(request.OutputPath, schema.Tables.Count);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to export schema");

Check warning on line 63 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / build-and-test

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogError(ILogger, Exception?, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 63 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogError(ILogger, Exception?, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 63 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (macos-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogError(ILogger, Exception?, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 63 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogError(ILogger, Exception?, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)

Check warning on line 63 in src/DbDiff.Application/Services/SchemaExportService.cs

View workflow job for this annotation

GitHub Actions / multi-platform-test (windows-latest)

For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogError(ILogger, Exception?, string?, params object?[])' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1848)
return SchemaExportResult.FailureResult(ex.Message);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/DbDiff.Application/Validation/PathValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ private static bool IsPathWithinDirectory(string path, string directory)
var normalizedPath = Path.GetFullPath(path).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
var normalizedDirectory = Path.GetFullPath(directory).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

return normalizedPath.StartsWith(normalizedDirectory + Path.DirectorySeparatorChar,
GetPathComparison()) ||
return normalizedPath.StartsWith(normalizedDirectory + Path.DirectorySeparatorChar,
GetPathComparison()) ||
normalizedPath.Equals(normalizedDirectory, GetPathComparison());
}

Expand All @@ -198,7 +198,7 @@ private static bool IsRestrictedSystemPath(string path)

// Check system drive root
var systemDrive = Path.GetPathRoot(Environment.SystemDirectory);
if (!string.IsNullOrEmpty(systemDrive) &&
if (!string.IsNullOrEmpty(systemDrive) &&
normalizedPath.Equals(systemDrive.TrimEnd(Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase))
return true;
}
Expand Down
17 changes: 9 additions & 8 deletions src/DbDiff.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using DbDiff.Application.DTOs;
using DbDiff.Application.DTOs;
using DbDiff.Application.Formatters;
using DbDiff.Application.Services;
using DbDiff.Application.Validation;
using DbDiff.Domain;
using DbDiff.Infrastructure;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

using Serilog;
using Serilog.Extensions.Logging;

// Build configuration
var configuration = new ConfigurationBuilder()
Expand Down Expand Up @@ -123,9 +124,9 @@
{
// Validate config file path - restrict to current directory and subdirectories for security
var validatedConfigPath = PathValidator.ValidateConfigPath(
configFile,
configFile,
allowedBasePath: Directory.GetCurrentDirectory());

configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(validatedConfigPath, optional: false, reloadOnChange: false)
Expand All @@ -140,13 +141,13 @@
}

// Priority: CLI args > Environment variables > Config file
var connectionString = connection
var connectionString = connection
?? Environment.GetEnvironmentVariable("DBDIFF_ConnectionStrings__Default")
?? configuration["ConnectionStrings:Default"];

var outputPath = output
var outputPath = output
?? Environment.GetEnvironmentVariable("DBDIFF_Export__OutputPath")
?? configuration["Export:OutputPath"]
?? configuration["Export:OutputPath"]
?? "schema.txt";

if (string.IsNullOrWhiteSpace(connectionString))
Expand All @@ -173,7 +174,7 @@
}

var exportService = serviceProvider.GetRequiredService<SchemaExportService>();

// Note: Path validation happens in SchemaExportRequest constructor
SchemaExportRequest request;
try
Expand Down
10 changes: 5 additions & 5 deletions src/DbDiff.Domain/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public class Column
public int OrdinalPosition { get; init; }

public Column(
string name,
DataType dataType,
bool isNullable,
string name,
DataType dataType,
bool isNullable,
int ordinalPosition,
int? maxLength = null,
int? precision = null,
int? maxLength = null,
int? precision = null,
int? scale = null)
{
if (string.IsNullOrWhiteSpace(name))
Expand Down
2 changes: 1 addition & 1 deletion src/DbDiff.Domain/DataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override bool Equals(object? obj)
{
if (obj is DataType other)
return TypeName.Equals(other.TypeName, StringComparison.OrdinalIgnoreCase);

return false;
}

Expand Down
Loading