Merged
Conversation
This commit modernizes the entire solution to leverage .NET 10 and C# 14 features: Logging Modernization: - Replaced System.Diagnostics.Trace with Microsoft.Extensions.Logging.ILogger - Created Shape2SqlServerLoggerFactory for centralized logger access - Marked Shape2SqlServerTrace as obsolete for backward compatibility - Added Microsoft.Extensions.Logging NuGet packages (10.0.2) Syntax Modernizations: - File-scoped namespaces throughout (C# 10+) - Target-typed new() expressions where type is obvious - String interpolation instead of string.Format - Collection expressions [] for list/array initialization (C# 12+) - Expression-bodied members for properties and methods - Primary constructors for simple types (SqlColumnDescriptor) - Nullable reference types enabled (#nullable enable) - Proper nullable annotations (?, ??, null!) - Switch expressions with pattern matching - Modern using declarations - Collection spread operator [..] WinForms Specific: - Initialized logger factory in Program.cs startup - Modernized event handlers with nullable sender - Updated all form classes with modern syntax Build Status: - Solution builds successfully with 0 errors - 382 warnings (all expected: nullable reference types and Windows-specific APIs) All changes maintain identical business logic while using modern C# features. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Logging Configuration:
- Added Serilog.Extensions.Logging (10.0.0) and Serilog.Sinks.File (7.0.0)
- Configured rolling file logs with 10MB size limit
- Logs written to logs/shape2sqlserver-{Date}.log
- Warning level and above logged to file
- Daily rolling interval with size-based rolling
- Keeps last 7 days of logs
Implementation:
- Updated Shape2SqlServerLoggerFactory with Serilog file sink
- Updated Program.cs with matching file logging configuration
- Console and Debug logging remain unchanged
- Fixed ILogger ambiguity between Microsoft.Extensions.Logging and Serilog
All logs (Warning+) are now persisted to disk for troubleshooting and audit.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Major architectural improvements: - Replaced static logger access with proper dependency injection - ShapeFileImporter accepts ILogger<ShapeFileImporter> via constructor injection - SqlServerHelper.ConvertToSqlType accepts ILogger parameter - ShapeFileReaderBulk updated to accept injected logger - frmMain uses ILoggerFactory for creating typed loggers - Suppressed CA1416 warnings (Windows-specific APIs expected in WinForms) DI Configuration: - ServiceCollection configured in Program.cs - All forms registered as transient services - Serilog file logging configured with 10MB limit - Backward compatible with optional logger parameters Build Status: 0 errors, 0 warnings ✓ Benefits: - Better testability (loggers can be mocked) - Follows SOLID principles - More maintainable and flexible architecture Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a comprehensive .editorconfig and enable nullable/analysis/code-style enforcement in project files. Convert BoundingBox to an immutable record with computed properties and a cleaner ToString. Replace string.Format usage with raw interpolated string literals for SQL creation/index scripts for readability. Simplify GetFieldType using expression-bodied member and pattern matching, set SqlServerBytesWriter.IsGeography when writing geography, and replace radio-button checks with a concise switch expression in SaveSettings.
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.
No description provided.