@@ -17,15 +17,22 @@ namespace JD.Efcpt.Build.Tasks;
1717/// </remarks>
1818public sealed class AddSqlFileWarnings : Task
1919{
20+ /// <summary>
21+ /// Full path to the MSBuild project file (used for profiling).
22+ /// </summary>
23+ public string ProjectPath { get ; set ; } = "" ;
24+
2025 /// <summary>
2126 /// Directory containing SQL script files.
2227 /// </summary>
2328 [ Required ]
29+ [ ProfileInput ]
2430 public string ScriptsDirectory { get ; set ; } = "" ;
2531
2632 /// <summary>
2733 /// Database name for the warning header.
2834 /// </summary>
35+ [ ProfileInput ]
2936 public string DatabaseName { get ; set ; } = "" ;
3037
3138 /// <summary>
@@ -39,49 +46,42 @@ public sealed class AddSqlFileWarnings : Task
3946 [ Output ]
4047 public int FilesProcessed { get ; set ; }
4148
42- /// <summary>
43- /// Executes the task.
44- /// </summary>
49+ /// <inheritdoc />
4550 public override bool Execute ( )
51+ => TaskExecutionDecorator . ExecuteWithProfiling (
52+ this , ExecuteCore , ProfilingHelper . GetProfiler ( ProjectPath ) ) ;
53+
54+ private bool ExecuteCore ( TaskExecutionContext ctx )
4655 {
47- var log = new BuildLog ( Log , LogVerbosity ) ;
56+ var log = new BuildLog ( ctx . Logger , LogVerbosity ) ;
4857
49- try
58+ log . Info ( "Adding auto-generation warnings to SQL files..." ) ;
59+
60+ if ( ! Directory . Exists ( ScriptsDirectory ) )
5061 {
51- log . Info ( "Adding auto-generation warnings to SQL files..." ) ;
62+ log . Warn ( $ "Scripts directory not found: { ScriptsDirectory } ") ;
63+ return true ; // Not an error
64+ }
5265
53- if ( ! Directory . Exists ( ScriptsDirectory ) )
66+ // Find all SQL files
67+ var sqlFiles = Directory . GetFiles ( ScriptsDirectory , "*.sql" , SearchOption . AllDirectories ) ;
68+
69+ FilesProcessed = 0 ;
70+ foreach ( var sqlFile in sqlFiles )
71+ {
72+ try
5473 {
55- log . Warn ( $ "Scripts directory not found: { ScriptsDirectory } " ) ;
56- return true ; // Not an error
74+ AddWarningHeader ( sqlFile , log ) ;
75+ FilesProcessed ++ ;
5776 }
58-
59- // Find all SQL files
60- var sqlFiles = Directory . GetFiles ( ScriptsDirectory , "*.sql" , SearchOption . AllDirectories ) ;
61-
62- FilesProcessed = 0 ;
63- foreach ( var sqlFile in sqlFiles )
77+ catch ( Exception ex )
6478 {
65- try
66- {
67- AddWarningHeader ( sqlFile , log ) ;
68- FilesProcessed ++ ;
69- }
70- catch ( Exception ex )
71- {
72- log . Warn ( $ "Failed to process { Path . GetFileName ( sqlFile ) } : { ex . Message } ") ;
73- }
79+ log . Warn ( $ "Failed to process { Path . GetFileName ( sqlFile ) } : { ex . Message } ") ;
7480 }
75-
76- log . Info ( $ "Processed { FilesProcessed } SQL files") ;
77- return true ;
78- }
79- catch ( Exception ex )
80- {
81- log . Error ( "JD0025" , $ "Failed to add SQL file warnings: { ex . Message } ") ;
82- log . Detail ( $ "Exception details: { ex } ") ;
83- return false ;
8481 }
82+
83+ log . Info ( $ "Processed { FilesProcessed } SQL files") ;
84+ return true ;
8585 }
8686
8787 /// <summary>
0 commit comments