Skip to content

Commit 97d621b

Browse files
Fix failing tests in generators
1 parent 8ecd6cc commit 97d621b

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

SysML2.NET.CodeGenerator/Generators/EcoreHandleBarsGenerators/EcoreHandleBarsGenerator.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace SysML2.NET.CodeGenerator.Generators.HandleBarsGenerators
2424
using System.Threading.Tasks;
2525

2626
using ECoreNetto;
27+
2728
using SysML2.NET.CodeGenerator.Generators;
2829

2930
/// <summary>
@@ -33,11 +34,12 @@ namespace SysML2.NET.CodeGenerator.Generators.HandleBarsGenerators
3334
public abstract class EcoreHandleBarsGenerator : HandleBarsGenerator
3435
{
3536
/// <summary>
36-
/// Initializes a new instance of the <see cref="HandleBarsGenerator"/> class/
37+
/// Gets an optional subfolder location path to locate templates
3738
/// </summary>
38-
protected EcoreHandleBarsGenerator()
39+
/// <returns>An optional subfolder name</returns>
40+
protected override string GetOptionalSubfolderTemplateLocation()
3941
{
40-
this.TemplateFolderPath = Path.Combine(this.TemplateFolderPath, "Ecore");
42+
return "ecore";
4143
}
4244

4345
/// <summary>

SysML2.NET.CodeGenerator/Generators/Generator.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,33 @@ public abstract class Generator
3939
/// Initializes a new instance of the <see cref="Generator"/> class.
4040
/// </summary>
4141
protected Generator()
42+
{
43+
this.AssignTemplateFolderPath();
44+
}
45+
46+
/// <summary>
47+
/// Assigns the value of the <see cref="TemplateFolderPath"/>
48+
/// </summary>
49+
private void AssignTemplateFolderPath()
4250
{
4351
var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
4452
this.TemplateFolderPath = Path.Combine(assemblyFolder, "Templates");
53+
54+
var subfolderLocation = this.GetOptionalSubfolderTemplateLocation();
55+
56+
if (!string.IsNullOrWhiteSpace(subfolderLocation))
57+
{
58+
this.TemplateFolderPath = Path.Combine(this.TemplateFolderPath, subfolderLocation);
59+
}
60+
}
61+
62+
/// <summary>
63+
/// Gets an optional subfolder location path to locate templates
64+
/// </summary>
65+
/// <returns>An optional subfolder name</returns>
66+
protected virtual string GetOptionalSubfolderTemplateLocation()
67+
{
68+
return null;
4569
}
4670

4771
/// <summary>

0 commit comments

Comments
 (0)