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

Add Model Generation tool #11

Open
Arithmomaniac opened this issue Nov 8, 2017 · 19 comments
Open

Add Model Generation tool #11

Arithmomaniac opened this issue Nov 8, 2017 · 19 comments

Comments

@Arithmomaniac
Copy link
Collaborator

Currently, models need to be written by hand, but there is no inherent reason the relevant information could not be pulled from an application schema file.

I would suggest using Heretik's parser (and contributing to it where needed so that it can be used by Gravity), but the XML could also be used directly.

One question that would need to be asked is how the generation would be done. Do we want to use MRT4 to generate a class file, or generate a whole DLL via a command-line application that a user could reference?

@dvbarnes
Copy link

I'm thinking about taking this on, potentially creating a lib that use's Heretik's parser and converting it to use Gravity's model. I believe T4 is the way to go, could you provide any information on creating the dll reference and why it would be better?

@mrobustelli
Copy link
Contributor

mrobustelli commented Nov 28, 2017

@dvbarnes let me know when you plan on jumping on this or if you want to talk about it. This is something I have wanted for a while. My first thought was a Visual Studio plugin or something like that. A stand alone app is a possibility as well or maybe even a Relativity app. I plan on talking with @ggachevski tomorrow and will bring this up. I am going to push for quick discussion, but unless there are major objections, I would push for the side of whoever is planning on doing the work. That being said, with my limiting schedule, I would like to figure out a way to help out on this one.

This is what your talking about right? https://msdn.microsoft.com/en-us/library/bb126445.aspx

@dvbarnes
Copy link

dvbarnes commented Nov 28, 2017

@mrobustelli This is exactly how the application parser works! I was thinking about creating a separate app that would use the application parser's api to create the T4 file close to what Application parser uses, but more focused for Gravity. I would probably be jumping on this in the next few days since it's pretty simple.

As far as implementation I'd probably create a new nuget package called Application-parser-gravity, or something, and just host the T4 template files there.

@jhightower
Copy link

@dvbarnes You might want to consider using Roslyn instead of using T4 templates. This StackOverflow article has some info on how to use it https://stackoverflow.com/questions/32769630/how-to-compile-a-c-sharp-file-with-roslyn-programmatically You could also create a tool similar to xsd that generates the models and guids and put them into a dll.

@Arithmomaniac
Copy link
Collaborator Author

@dvbarnes one thing to keep in mind when redistributing a T4 file via Nuget (as opposed to a command-line too) is that the developer may choose to move the T4 file out of the root of the project, in which case you would need to set up your T4 file to use paths relative to the project root when referencing other DLLs.

Also, redistributing a T4 file as a Nuget package does not work well in Nuget 3.3+, as the file is not actually added to your Visual Studio project (see here.)

I'm partial to creating a command line application that:

  • Takes an application.xml file as input
  • Uses a templating engine (T4/Mono.TextTemplating or Scripty) to generate a C# file from that
  • Compiles that C# file as @jhightower explains above

@dvbarnes
Copy link

dvbarnes commented Nov 29, 2017

After thinking about this the best route would be the process described by @Arithmomaniac and possibly adding different type switches IE --type basic(current application-parser logic) and --type gravity (gravity dll builder). similar to how angular or Yeoman works. This would allow us more flexibility on creating the compiled document that can be consumed. This would take in an application.xml file and spit out a compiled dll that the developer can reference. using https://msdn.microsoft.com/en-us/magazine/mt707527.aspx seems to guide an example of using Rosyln to create a compiled dll

@ggachevski
Copy link
Contributor

Awesome! I am labeling as "discussion" a bit, as there are some cases where one would need more flexibility -- potentially a UI. @mrobustelli & @hhristov-tsd and I discussed briefly yesterday, and I believe there are a few consumer cases that would necessitate a UI part to be existent. For example, for a given RDO, I will want a few Slim models and a few Fat models. This means, for me, that if I want a generated model (be it in code or DLL), I would need some UI under which I can pick my RDO, the fields/properties to be included, and how they would be included (for example, the children as list of ints instead of list of RDOs). As minimalistic as I feel, I could argue for a in-Relativity app that can do this for me and to spit me out the generated C# code, so that I can provide my own namespaces and file location.

A few thoughts, but this Issue suggestion here is as mighty as it can get for the current Gravity. Soooo needed.

@dvbarnes
Copy link

@ggachevski I think this is could turn into that going forward. As an MVP I think generating a .NET dll from an application.xml file would be a great start.

@dvbarnes
Copy link

dvbarnes commented Nov 30, 2017

I have started the work in https://github.com/Heretik-Corp/application-parser/tree/Add_gravity_support. This will provide a split between the core of parsing and the T4 work. Next steps are to work in the gravity repo to create a generator specific to gravity.

@Arithmomaniac
Copy link
Collaborator Author

@dvbarnes How is this coming along?

@dvbarnes
Copy link

Unfortunately I have been very busy these last few months and have not had as much time to work on this as I would have liked. This may be something I'll have to hand over to another developer.

@ggachevski
Copy link
Contributor

ggachevski commented Mar 16, 2018 via email

@mrobustelli
Copy link
Contributor

@dvbarnes don't sweat it. Totally understand. I want to get to this to. The issue is not officially assigned so don't stress out too much. I will try to reach out to a few other devs that might be able to help too.

@Arithmomaniac
Copy link
Collaborator Author

When building this tool, we could multi-target to .NET Core so that we can distribute it on Nuget as a global tool in addition to a plain exe/dll.

@dvbarnes
Copy link

Update on this from my end. Heretik has chosen to move in a different direction and I won't be contributing to this project in the foreseeable future. If you are interested we have been working on https://github.com/Heretik-Corp/Objectmanager-Rest. This could provide value to this project in the future.

@mrobustelli mrobustelli added this to Prioritized in Issue Prioritization Sep 24, 2018
@hhristov-tsd
Copy link
Collaborator

Hey guys!

I had some time to put effort on this one and came up with a sort of working-proof of concept console app. It reads a Relativity application .XML schema and converts it into .CS files using text formatting. I've tested it on the Gravity Demo app and some of our internal projects and it handles them quite well. Generated around 100 .CS Gravity models under a second (in debug mode).

As it is quite general and not polished, I can give you guys a sneak peek on the next bi-weekly meetup. My plans for it are to create some basic UI (win.forms or even better - UWF via .NET Core), but we could discuss any ideas around it when we meet.

@Arithmomaniac
Copy link
Collaborator Author

Arithmomaniac commented Oct 12, 2018 via email

@hhristov-tsd
Copy link
Collaborator

I would like to a bit polish the idea and will gladly open it up in a branch, but I am quite occupied probably by the end of next week. So lets shoot for our next meetup to discuss it in detail then.

@hhristov-tsd
Copy link
Collaborator

Added initial version of the Model Generation Tool. It can be found in the new branch: https://github.com/relativitydev/Gravity/tree/modelGenerationTool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Issue Prioritization
  
Prioritized
Development

No branches or pull requests

6 participants