Skip to content

v4: Generator should be swappable / extendable #246

Open
@bielu

Description

@bielu

HI @zpqrtbnk ,
On time when I was working with my extension for MB v4, I hit that issue I need split generation separation in to 2 separate files and in time of work on that I noticed to do that I need modify Our.ModelsBuilder.Building.Generator and I noticed we actually dont have way to hijack here as we dont register that in container and we dont have any event which would allow me to change that part:

  var codeModel = CreateModels(modelsNamespace, files, (name, code) =>
            {
                var filename = Path.Combine(modelsDirectory, name + ".generated.cs");
                File.WriteAllText(filename, code);
            });

Which I would extend with additional option after as example:

  var codeTransformation = CreateTransformation(modelsNamespace, files, (name, code) =>
            {
                var filename = Path.Combine(modelsDirectory, name + ".transformation.generated.cs");
                File.WriteAllText(filename, code);
            });

and later

if (bin != null)
            {
                // build
                foreach (var file in Directory.GetFiles(modelsDirectory, "*.generated.cs"))
                    files[file] = File.ReadAllText(file);
                var compiler = new Compiler(_options.LanguageVersion);
                // FIXME what is the name of the DLL as soon as we accept several namespaces = an option?
                compiler.Compile(codeModel.AssemblyName, files, bin);
                compiler.Compile(codeTransformation.AssemblyName, files, bin);
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions