Skip to content

Commit

Permalink
Core9 filebug (#2604)
Browse files Browse the repository at this point in the history
* Add proper EF Core 9 support

* files were placed wrong with EF Core 9

fixes #2603
  • Loading branch information
ErikEJ authored Nov 7, 2024
1 parent 3922dc6 commit bb0db72
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/Core/RevEng.Core.60/Routines/Functions/FunctionScaffolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public ScaffoldedModel ScaffoldModel(RoutineModel model, ModuleScaffolderOptions
ArgumentNullException.ThrowIfNull(scaffolderOptions);

var result = new ScaffoldedModel();
var path = string.Empty;

errors.AddRange(model.Errors);

Expand Down Expand Up @@ -102,16 +103,18 @@ public ScaffoldedModel ScaffoldModel(RoutineModel model, ModuleScaffolderOptions
{
schemas.Add($"{routine.Schema}Schema");
}

path = scaffolderOptions.UseSchemaFolders
? Path.Combine(routine.Schema, $"{typeName}.cs")
: $"{typeName}.cs";
#if CORE90
result.AdditionalFiles.Add(new ScaffoldedFile(Path.Combine(routine.Schema, $"{typeName}.cs"), classContent));
result.AdditionalFiles.Add(new ScaffoldedFile(path, classContent));
#else

result.AdditionalFiles.Add(new ScaffoldedFile
{
Code = classContent,
Path = scaffolderOptions.UseSchemaFolders
? Path.Combine(routine.Schema, $"{typeName}.cs")
: $"{typeName}.cs",
Path = path,
});
#endif
}
Expand Down
23 changes: 15 additions & 8 deletions src/Core/RevEng.Core.60/Routines/Procedures/ProcedureScaffolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public ScaffoldedModel ScaffoldModel(RoutineModel model, ModuleScaffolderOptions
ArgumentNullException.ThrowIfNull(scaffolderOptions);

var result = new ScaffoldedModel();
var path = string.Empty;

errors.AddRange(model.Errors);

Expand Down Expand Up @@ -105,15 +106,17 @@ public ScaffoldedModel ScaffoldModel(RoutineModel model, ModuleScaffolderOptions
schemas.Add($"{routine.Schema}Schema");
}

path = scaffolderOptions.UseSchemaFolders
? Path.Combine(routine.Schema, $"{typeName}.cs")
: $"{typeName}.cs";

#if CORE90
result.AdditionalFiles.Add(new ScaffoldedFile(Path.Combine(routine.Schema, $"{typeName}.cs"), classContent));
result.AdditionalFiles.Add(new ScaffoldedFile(path, classContent));
#else
result.AdditionalFiles.Add(new ScaffoldedFile
{
Code = classContent,
Path = scaffolderOptions.UseSchemaFolders
? Path.Combine(routine.Schema, $"{typeName}.cs")
: $"{typeName}.cs",
Path = path,
});
#endif
}
Expand All @@ -123,25 +126,29 @@ public ScaffoldedModel ScaffoldModel(RoutineModel model, ModuleScaffolderOptions

if (!string.IsNullOrEmpty(dbContextInterface))
{
path = Path.GetFullPath(Path.Combine(scaffolderOptions.ContextDir, $"I{scaffolderOptions.ContextName}{FileNameSuffix}.cs"));
#if CORE90
result.AdditionalFiles.Add(new ScaffoldedFile($"I{scaffolderOptions.ContextName}{FileNameSuffix}.cs", dbContextInterface));
result.AdditionalFiles.Add(new ScaffoldedFile(path, dbContextInterface));
#else
result.AdditionalFiles.Add(new ScaffoldedFile
{
Code = dbContextInterface,
Path = Path.GetFullPath(Path.Combine(scaffolderOptions.ContextDir, $"I{scaffolderOptions.ContextName}{FileNameSuffix}.cs")),
Path = path,
});
#endif
}

var dbContext = WriteDbContext(scaffolderOptions, model, schemas.Distinct().ToList());

path = Path.GetFullPath(Path.Combine(scaffolderOptions.ContextDir, scaffolderOptions.ContextName + $"{FileNameSuffix}.cs"));

#if CORE90
result.ContextFile = new ScaffoldedFile(Path.Combine(scaffolderOptions.ContextDir, scaffolderOptions.ContextName + $"{FileNameSuffix}.cs"), dbContext);
result.ContextFile = new ScaffoldedFile(path, dbContext);
#else
result.ContextFile = new ScaffoldedFile
{
Code = dbContext,
Path = Path.GetFullPath(Path.Combine(scaffolderOptions.ContextDir, scaffolderOptions.ContextName + $"{FileNameSuffix}.cs")),
Path = path,
};
#endif

Expand Down

0 comments on commit bb0db72

Please sign in to comment.