-
Notifications
You must be signed in to change notification settings - Fork 0
fix: enhance error handling and logging in BuildResolutionState method #39
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -408,49 +408,110 @@ private record TargetContext(bool UseConnectionStringMode, string ConnectionStri | |||||
|
|
||||||
| private ResolutionState BuildResolutionState(BuildLog log) | ||||||
| { | ||||||
| // Determine mode using priority-based resolution | ||||||
| var (useConnectionStringMode, connectionString, sqlProjPath) = DetermineMode(log); | ||||||
| // Step 1: Determine mode using priority-based resolution | ||||||
| log.Detail("BuildResolutionState: Step 1 - DetermineMode starting"); | ||||||
| TargetContext? targetContext = null; | ||||||
| try | ||||||
| { | ||||||
| targetContext = DetermineMode(log); | ||||||
| } | ||||||
| catch (Exception ex) | ||||||
| { | ||||||
| log.Warn($"BuildResolutionState: DetermineMode threw: {ex.GetType().Name}: {ex.Message}"); | ||||||
| throw; | ||||||
| } | ||||||
|
|
||||||
| return Composer<ResolutionState, ResolutionState> | ||||||
| .New(() => default) | ||||||
| .With(state => state with | ||||||
| { | ||||||
| ConnectionString = connectionString, | ||||||
| UseConnectionStringMode = useConnectionStringMode, | ||||||
| SqlProjPath = sqlProjPath | ||||||
| }) | ||||||
| .With(state => state with | ||||||
| { | ||||||
| ConfigPath = ResolveFile(ConfigOverride, "efcpt-config.json") | ||||||
| }) | ||||||
| .With(state => state with | ||||||
| { | ||||||
| RenamingPath = ResolveFile( | ||||||
| RenamingOverride, | ||||||
| "efcpt.renaming.json", | ||||||
| "efcpt-renaming.json", | ||||||
| "efpt.renaming.json") | ||||||
| }) | ||||||
| .With(state => state with | ||||||
| { | ||||||
| TemplateDir = ResolveDir( | ||||||
| TemplateDirOverride, | ||||||
| "Template", | ||||||
| "CodeTemplates", | ||||||
| "Templates") | ||||||
| }) | ||||||
| // Either connection string or SQL project must be resolved | ||||||
| .Require(state | ||||||
| => state.UseConnectionStringMode | ||||||
| ? string.IsNullOrWhiteSpace(state.ConnectionString) | ||||||
| ? "Connection string resolution failed. No connection string could be resolved from configuration." | ||||||
| : null | ||||||
| : string.IsNullOrWhiteSpace(state.SqlProjPath) | ||||||
| ? "SqlProj resolution failed. No SQL project reference found. " + | ||||||
| "Add a .sqlproj ProjectReference, set EfcptSqlProj property, or provide a connection string via " + | ||||||
| "EfcptConnectionString/appsettings.json/app.config. Check build output for detailed error messages." | ||||||
| : null) | ||||||
| .Build(state => state); | ||||||
| var useConnectionStringMode = targetContext?.UseConnectionStringMode ?? false; | ||||||
| var connectionString = targetContext?.ConnectionString ?? ""; | ||||||
| var sqlProjPath = targetContext?.SqlProjPath ?? ""; | ||||||
|
|
||||||
| log.Detail($"BuildResolutionState: Step 1 complete - UseConnectionStringMode={useConnectionStringMode}, " + | ||||||
| $"ConnectionString={(string.IsNullOrEmpty(connectionString) ? "(empty)" : "(set)")}, " + | ||||||
| $"SqlProjPath={(string.IsNullOrEmpty(sqlProjPath) ? "(empty)" : sqlProjPath)}"); | ||||||
|
|
||||||
| // Step 2: Resolve config file | ||||||
| log.Detail("BuildResolutionState: Step 2 - ResolveFile for config starting"); | ||||||
| log.Detail($" ConfigOverride={(ConfigOverride ?? "(null)")}"); | ||||||
| log.Detail($" ProjectDirectory={(ProjectDirectory ?? "(null)")}"); | ||||||
| log.Detail($" DefaultsRoot={(DefaultsRoot ?? "(null)")}"); | ||||||
| string configPath; | ||||||
| try | ||||||
| { | ||||||
| configPath = ResolveFile(ConfigOverride ?? "", "efcpt-config.json"); | ||||||
|
||||||
| configPath = ResolveFile(ConfigOverride ?? "", "efcpt-config.json"); | |
| configPath = ResolveFile(ConfigOverride, "efcpt-config.json"); |
Copilot
AI
Dec 30, 2025
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.
The null-coalescing operator is unnecessary here. RenamingOverride property is initialized to an empty string and NormalizeProperties is called before this method, ensuring it can never be null.
| RenamingOverride ?? "", | |
| RenamingOverride, |
Copilot
AI
Dec 30, 2025
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.
The null-coalescing operator is unnecessary here. TemplateDirOverride property is initialized to an empty string and NormalizeProperties is called before this method, ensuring it can never be null.
| TemplateDirOverride ?? "", | |
| TemplateDirOverride, |
Uh oh!
There was an error while loading. Please reload this page.