Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
this.Handlebars = HandlebarsDotNet.Handlebars.CreateSharedEnvironment();
HandlebarsHelpers.Register(Handlebars);

this.RegisterHelpers();

Check warning on line 59 in ECoreNetto.Reporting/Generators/HandleBarsReportGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this call from a constructor to the overridable 'RegisterHelpers' method.

Check warning on line 59 in ECoreNetto.Reporting/Generators/HandleBarsReportGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this call from a constructor to the overridable 'RegisterHelpers' method.
this.RegisterTemplates();

Check warning on line 60 in ECoreNetto.Reporting/Generators/HandleBarsReportGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this call from a constructor to the overridable 'RegisterTemplates' method.

Check warning on line 60 in ECoreNetto.Reporting/Generators/HandleBarsReportGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this call from a constructor to the overridable 'RegisterTemplates' method.
}

/// <summary>
Expand Down Expand Up @@ -91,7 +91,7 @@
{
var templatePath = $"ECoreNetto.Reporting.Templates.{name}.hbs";

var template = ResourceLoader.LoadEmbeddedResource(templatePath);
var template = ResourceLoader.LoadEmbeddedResource(typeof(HandleBarsReportGenerator).Assembly, templatePath);

var compiledTemplate = Handlebars.Compile(template);

Expand All @@ -115,7 +115,7 @@
var dataTypes = new List<EDataType>();
var eClasses = new List<EClass>();

foreach (var package in packages)

Check warning on line 118 in ECoreNetto.Reporting/Generators/HandleBarsReportGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Loop should be simplified by calling Select(package => package.EClassifiers))

Check warning on line 118 in ECoreNetto.Reporting/Generators/HandleBarsReportGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Loop should be simplified by calling Select(package => package.EClassifiers))
{
enums.AddRange(package.EClassifiers.OfType<EEnum>());

Expand Down
11 changes: 6 additions & 5 deletions ECoreNetto.Reporting/Resources/ResourceLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@ namespace ECoreNetto.Reporting.Resources
/// <summary>
/// Class responsible for loading embedded resources.
/// </summary>
internal static class ResourceLoader
public static class ResourceLoader
{
/// <summary>
/// Load an embedded resource
/// Load an embedded resource from the provided <see cref="Assembly"/>
/// </summary>
/// <param name="assembly">
/// The <see cref="Assembly"/> whose manifest contains the embedded resource
/// </param>
/// <param name="path">
/// The path of the embedded resource
/// </param>
/// <returns>
/// a string containing the contents of the embedded resource
/// </returns>
public static string LoadEmbeddedResource(string path)
public static string LoadEmbeddedResource(Assembly assembly, string path)
{
var assembly = Assembly.GetExecutingAssembly();

using var stream = assembly.GetManifestResourceStream(path);

using var reader = new StreamReader(stream ?? throw new MissingManifestResourceException());
Expand Down
17 changes: 6 additions & 11 deletions ECoreNetto.Tools/Resources/ResourceLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@

namespace ECoreNetto.Tools.Resources
{
using System.IO;
using System.Reflection;
using System.Resources;

using SharedResourceLoader = ECoreNetto.Reporting.Resources.ResourceLoader;

/// <summary>
/// Class responsible for loading embedded resources.
/// Class responsible for loading embedded resources from this assembly and for the
/// Tools-specific version and logo queries.
/// </summary>
public static class ResourceLoader
{
/// <summary>
/// Load an embedded resource
/// Load an embedded resource from the executing (ECoreNetto.Tools) assembly
/// </summary>
/// <param name="path">
/// The path of the embedded resource
Expand All @@ -40,13 +41,7 @@ public static class ResourceLoader
/// </returns>
public static string LoadEmbeddedResource(string path)
{
var assembly = Assembly.GetExecutingAssembly();

using var stream = assembly.GetManifestResourceStream(path);

using var reader = new StreamReader(stream ?? throw new MissingManifestResourceException());

return reader.ReadToEnd();
return SharedResourceLoader.LoadEmbeddedResource(Assembly.GetExecutingAssembly(), path);
}

/// <summary>
Expand Down
Loading