Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4: Generator should be swappable / extendable #246

Open
bielu opened this issue Oct 25, 2020 · 0 comments
Open

v4: Generator should be swappable / extendable #246

bielu opened this issue Oct 25, 2020 · 0 comments

Comments

@bielu
Copy link
Contributor

bielu commented Oct 25, 2020

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);
            }
@bielu bielu changed the title v4: Generator should swappable / extendable v4: Generator should be swappable / extendable Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant