From ee7b399c0f60ff134e5a3ef01a1e0bf96b540b72 Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 4 Sep 2024 16:27:27 +0200 Subject: [PATCH] [JS] Config JS surchargeable --- .../JavascriptConfig.cs | 24 +++++++++---------- TopModel.Generator/Program.cs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/TopModel.Generator.Javascript/JavascriptConfig.cs b/TopModel.Generator.Javascript/JavascriptConfig.cs index bc90985e..38bf1d96 100644 --- a/TopModel.Generator.Javascript/JavascriptConfig.cs +++ b/TopModel.Generator.Javascript/JavascriptConfig.cs @@ -103,7 +103,7 @@ public class JavascriptConfig : GeneratorConfigBase protected override string NullValue => "undefined"; - public string GetClassFileName(Class classe, string tag) + public virtual string GetClassFileName(Class classe, string tag) { return Path.Combine( OutputDirectory, @@ -113,7 +113,7 @@ public string GetClassFileName(Class classe, string tag) .Replace("\\", "/"); } - public string GetCommentResourcesFilePath(Namespace ns, string tag, string lang) + public virtual string GetCommentResourcesFilePath(Namespace ns, string tag, string lang) { return Path.Combine( OutputDirectory, @@ -123,13 +123,13 @@ public string GetCommentResourcesFilePath(Namespace ns, string tag, string lang) .Replace("\\", "/"); } - public IEnumerable<(string Import, string Path)> GetDomainImportPaths(string fileName, IProperty prop, string tag) + public virtual IEnumerable<(string Import, string Path)> GetDomainImportPaths(string fileName, IProperty prop, string tag) { return GetDomainImports(prop, tag) .Select(import => (Import: import.Split("/").Last(), Path: GetRelativePath(import[..import.LastIndexOf('/')], fileName))); } - public List<(string Import, string Path)> GetEndpointImports(string fileName, IEnumerable endpoints, string tag, IEnumerable availableClasses) + public virtual List<(string Import, string Path)> GetEndpointImports(string fileName, IEnumerable endpoints, string tag, IEnumerable availableClasses) { return endpoints.SelectMany(e => e.ClassDependencies) .Select(dep => ( @@ -143,7 +143,7 @@ public string GetCommentResourcesFilePath(Namespace ns, string tag, string lang) .GroupAndSort(); } - public string GetEndpointsFileName(ModelFile file, string tag) + public virtual string GetEndpointsFileName(ModelFile file, string tag) { return Path.Combine( OutputDirectory, @@ -152,7 +152,7 @@ public string GetEndpointsFileName(ModelFile file, string tag) .Replace("\\", "/"); } - public string? GetImportPathForClass(ClassDependency dep, string targetTag, string sourceTag, IEnumerable availableClasses) + public virtual string? GetImportPathForClass(ClassDependency dep, string targetTag, string sourceTag, IEnumerable availableClasses) { string target; if (dep is { Source: IProperty and not CompositionProperty and not AliasProperty { Property: CompositionProperty } }) @@ -196,7 +196,7 @@ public string GetEndpointsFileName(ModelFile file, string tag) return path; } - public string GetMainResourceFilePath(string tag, string lang) + public virtual string GetMainResourceFilePath(string tag, string lang) { return Path.Combine( OutputDirectory, @@ -206,19 +206,19 @@ public string GetMainResourceFilePath(string tag, string lang) .Replace("\\", "/"); } - public string GetReferencesFileName(Namespace ns, string tag) + public virtual string GetReferencesFileName(Namespace ns, string tag) { return Path.Combine(OutputDirectory, ResolveVariables(ModelRootPath!, tag), ns.ModulePathKebab, "references.ts").Replace("\\", "/"); } - public string GetRelativePath(string path, string fileName) + public virtual string GetRelativePath(string path, string fileName) { return !path.StartsWith('.') ? path : Path.GetRelativePath(string.Join('/', fileName.Split('/').SkipLast(1)), Path.Combine(OutputDirectory, path)).Replace("\\", "/"); } - public string GetResourcesFilePath(Namespace ns, string tag, string lang) + public virtual string GetResourcesFilePath(Namespace ns, string tag, string lang) { return Path.Combine( OutputDirectory, @@ -228,13 +228,13 @@ public string GetResourcesFilePath(Namespace ns, string tag, string lang) .Replace("\\", "/"); } - public IEnumerable<(string Import, string Path)> GetValueImportPaths(string fileName, IProperty prop, string? value = null) + public virtual IEnumerable<(string Import, string Path)> GetValueImportPaths(string fileName, IProperty prop, string? value = null) { return GetValueImports(prop, value) .Select(import => (Import: import.Split("/").Last(), Path: GetRelativePath(import[..import.LastIndexOf('/')], fileName))); } - public bool IsListComposition(IProperty property) + public virtual bool IsListComposition(IProperty property) { var cp = property switch { diff --git a/TopModel.Generator/Program.cs b/TopModel.Generator/Program.cs index 5e065a6e..592f9a6a 100644 --- a/TopModel.Generator/Program.cs +++ b/TopModel.Generator/Program.cs @@ -290,7 +290,7 @@ void HandleFile(FileInfo file) if (returnCode == 0) { generators.AddRange(new DirectoryInfo(Path.Combine(Path.GetFullPath(cg, new FileInfo(fullName).DirectoryName!), "bin")) - .GetFiles("TopModel.Generator.*.dll", SearchOption.AllDirectories) + .GetFiles($"{cg.Split('/').Last()}.dll", SearchOption.AllDirectories) .Where(a => a.FullName.Contains(framework) && a.Name != "TopModel.Generator.Core.dll") .DistinctBy(a => a.Name) .Select(f => Assembly.LoadFrom(f.FullName))