@@ -35,10 +35,7 @@ public HtmlFormatterScriban()
3535 }
3636 catch ( Exception ex )
3737 {
38- // Fallback to basic template if templates can't be loaded
39- Console . WriteLine ( $ "Warning: Could not load templates, using fallback: { ex . Message } ") ;
40- _mainTemplate = Template . Parse ( GetFallbackTemplate ( ) ) ;
41- _partialTemplates = new Dictionary < string , Template > ( ) ;
38+ throw new InvalidOperationException ( "Failed to initialize Scriban HTML formatter templates. Ensure template resources are properly embedded." , ex ) ;
4239 }
4340 }
4441
@@ -72,7 +69,7 @@ public string Format(ComparisonResult result)
7269 context . PushGlobal ( scriptObject ) ;
7370
7471 // Set up template loader for includes
75- context . TemplateLoader = new CustomTemplateLoader ( _partialTemplates ) ;
72+ context . TemplateLoader = new CustomTemplateLoader ( ) ;
7673
7774 return _mainTemplate . Render ( context ) ;
7875 }
@@ -137,7 +134,7 @@ private object PrepareResultData(ComparisonResult result)
137134 modified_count = result . Summary . ModifiedCount ,
138135 breaking_changes_count = result . Summary . BreakingChangesCount
139136 } ,
140- configuration = PrepareConfigurationData ( result . Configuration ) ,
137+ configuration = PrepareConfigData ( result . Configuration ) ,
141138 breaking_changes = PrepareBreakingChangesData ( result . Differences . Where ( d => d . IsBreakingChange ) )
142139 } ;
143140 }
@@ -251,46 +248,6 @@ private object[] PrepareBreakingChangesData(IEnumerable<ApiDifference> breakingC
251248 } ) . ToArray ( ) ;
252249 }
253250
254- private object PrepareConfigurationData ( DotNetApiDiff . Models . Configuration . ComparisonConfiguration config )
255- {
256- return new
257- {
258- filters = new
259- {
260- include_internals = config . Filters . IncludeInternals ,
261- include_compiler_generated = config . Filters . IncludeCompilerGenerated ,
262- include_namespaces = config . Filters . IncludeNamespaces ,
263- exclude_namespaces = config . Filters . ExcludeNamespaces ,
264- include_types = config . Filters . IncludeTypes ,
265- exclude_types = config . Filters . ExcludeTypes
266- } ,
267- mappings = new
268- {
269- auto_map_same_name_types = config . Mappings . AutoMapSameNameTypes ,
270- ignore_case = config . Mappings . IgnoreCase ,
271- type_mappings = config . Mappings . TypeMappings . Select ( kvp => new { key = kvp . Key , value = kvp . Value } ) ,
272- namespace_mappings = config . Mappings . NamespaceMappings . Select ( kvp => new { key = kvp . Key , value = kvp . Value } )
273- } ,
274- exclusions = new
275- {
276- excluded_types = config . Exclusions . ExcludedTypes ,
277- excluded_members = config . Exclusions . ExcludedMembers ,
278- excluded_type_patterns = config . Exclusions . ExcludedTypePatterns ,
279- excluded_member_patterns = config . Exclusions . ExcludedMemberPatterns
280- } ,
281- breaking_change_rules = new
282- {
283- treat_type_removal_as_breaking = config . BreakingChangeRules . TreatTypeRemovalAsBreaking ,
284- treat_member_removal_as_breaking = config . BreakingChangeRules . TreatMemberRemovalAsBreaking ,
285- treat_signature_change_as_breaking = config . BreakingChangeRules . TreatSignatureChangeAsBreaking ,
286- treat_reduced_accessibility_as_breaking = config . BreakingChangeRules . TreatReducedAccessibilityAsBreaking
287- } ,
288- output_format = config . OutputFormat ,
289- fail_on_breaking_changes = config . FailOnBreakingChanges ,
290- output_path = config . OutputPath
291- } ;
292- }
293-
294251 private string RenderPartial ( string templateName , object data )
295252 {
296253 if ( _partialTemplates . TryGetValue ( templateName , out var template ) )
@@ -313,8 +270,9 @@ private string GetCssStyles()
313270 {
314271 return EmbeddedTemplateLoader . LoadStyles ( ) ;
315272 }
316- catch
273+ catch ( Exception ex )
317274 {
275+ System . Diagnostics . Debug . WriteLine ( $ "Warning: Could not load CSS styles, using fallback: { ex . Message } ") ;
318276 return GetFallbackStyles ( ) ;
319277 }
320278 }
@@ -325,8 +283,9 @@ private string GetJavaScriptCode()
325283 {
326284 return EmbeddedTemplateLoader . LoadScripts ( ) ;
327285 }
328- catch
286+ catch ( Exception ex )
329287 {
288+ System . Diagnostics . Debug . WriteLine ( $ "Warning: Could not load JavaScript, using fallback: { ex . Message } ") ;
330289 return GetFallbackJavaScript ( ) ;
331290 }
332291 }
0 commit comments