< Summary

Information
Class: DotNetApiDiff.Reporting.CustomTemplateLoader
Assembly: DotNetApiDiff
File(s): /home/runner/work/dotnet-api-diff/dotnet-api-diff/src/DotNetApiDiff/Reporting/CustomTemplateLoader.cs
Line coverage
53%
Covered lines: 7
Uncovered lines: 6
Coverable lines: 13
Total lines: 34
Line coverage: 53.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetPath(...)100%11100%
Load(...)100%1157.14%
LoadAsync(...)100%210%

File(s)

/home/runner/work/dotnet-api-diff/dotnet-api-diff/src/DotNetApiDiff/Reporting/CustomTemplateLoader.cs

#LineLine coverage
 1using Scriban;
 2using Scriban.Parsing;
 3using Scriban.Runtime;
 4
 5namespace DotNetApiDiff.Reporting;
 6
 7/// <summary>
 8/// Custom template loader for Scriban that loads templates from embedded resources
 9/// </summary>
 10public class CustomTemplateLoader : ITemplateLoader
 11{
 12    public string GetPath(TemplateContext context, SourceSpan callerSpan, string templateName)
 16813    {
 16814        return templateName;
 16815    }
 16
 17    public string Load(TemplateContext context, SourceSpan callerSpan, string templatePath)
 3018    {
 19        try
 3020        {
 21            // Load template source directly from embedded resources
 3022            return EmbeddedTemplateLoader.LoadTemplate($"{templatePath}.scriban");
 23        }
 024        catch (Exception ex)
 025        {
 026            throw new InvalidOperationException($"Template '{templatePath}' not found: {ex.Message}", ex);
 27        }
 3028    }
 29
 30    public ValueTask<string> LoadAsync(TemplateContext context, SourceSpan callerSpan, string templatePath)
 031    {
 032        return new ValueTask<string>(Load(context, callerSpan, templatePath));
 033    }
 34}