Skip to content

modernize#5

Merged
xfischer merged 6 commits intomasterfrom
feature/modernize
Feb 6, 2026
Merged

modernize#5
xfischer merged 6 commits intomasterfrom
feature/modernize

Conversation

@xfischer
Copy link
Copy Markdown
Owner

@xfischer xfischer commented Feb 6, 2026

No description provided.

xfischer and others added 6 commits February 6, 2026 08:23
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.
@xfischer xfischer merged commit a90d794 into master Feb 6, 2026
@xfischer xfischer deleted the feature/modernize branch February 6, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant