From 2f1fe4a6b7d369b45c2b159c9e9f6b323eb225ff Mon Sep 17 00:00:00 2001 From: Damien Date: Mon, 9 Sep 2024 19:18:13 +0200 Subject: [PATCH] [C#] Fix using en trop si `requiredNonNullable` --- TopModel.Generator.Csharp/CSharpClassGenerator.cs | 5 ++++- TopModel.Generator/Program.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TopModel.Generator.Csharp/CSharpClassGenerator.cs b/TopModel.Generator.Csharp/CSharpClassGenerator.cs index 83897a15..890b2ab7 100644 --- a/TopModel.Generator.Csharp/CSharpClassGenerator.cs +++ b/TopModel.Generator.Csharp/CSharpClassGenerator.cs @@ -462,7 +462,10 @@ protected virtual void GenerateUsings(CSharpWriter w, Class item, string tag) usings.Add("System.ComponentModel"); } - if (item.Properties.Any(p => p.Required || p.PrimaryKey || Config.GetType(p)?.TrimEnd('?') == "string" && p.Domain.Length != null)) + if (item.Properties.Any(p => + p.Required && !Config.RequiredNonNullable(tag) + || p.PrimaryKey + || Config.GetType(p)?.TrimEnd('?') == "string" && p.Domain.Length != null)) { usings.Add("System.ComponentModel.DataAnnotations"); } diff --git a/TopModel.Generator/Program.cs b/TopModel.Generator/Program.cs index aee4bd48..46ca4c66 100644 --- a/TopModel.Generator/Program.cs +++ b/TopModel.Generator/Program.cs @@ -226,7 +226,7 @@ void HandleFile(FileInfo file) { var generatorsPath = Path.Combine(new FileInfo(Assembly.GetEntryAssembly()!.Location).DirectoryName!, "../../../.."); var modules = Directory.GetFileSystemEntries(generatorsPath).Where(e => e.Contains("TopModel.Generator.") && !e.Contains("TopModel.Generator.Core")); - config.CustomGenerators.AddRange(modules.Select(m => Path.GetRelativePath(config.ModelRoot, m))); + config.CustomGenerators.AddRange(modules.Select(m => Path.GetRelativePath(config.ModelRoot, m).Replace("\\", "/"))); } if (updateMode == "all")