Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Kinetix.Tools.Core + T4 and parameters singleton removal + .NET Core #1

Merged
merged 8 commits into from
Jul 24, 2018

Conversation

JabX
Copy link
Collaborator

@JabX JabX commented Jun 9, 2018

Preparing groundwork for KleeGroup/kinetix-tools#9, KleeGroup/kinetix-tools#10 and KleeGroup/kinetix-tools#11

This is a PR because it's completely untested, though I am confident there won't be any regression 😃

I created Kinetix.Tools.Common where I put all parameter types (GeneratorParameters and co.), the Model namespace (i needed to use ModelProperty so I copied everything over), FileWriter in prevision of the TS gen migration, and every TS util we had across both generators.

While working on parameters, I removed the Singletons.GeneratorParameters and gave every class the parameters it needed to work instead. I realized we some of them were actually misplaced, so I moved them :

  • Kinetix from root to csharp
  • DefaultValuesFile, NoTableFile, HistoriqueCreationFile from root to ssdt

I removed the T4 files and kept the generated C#, that I cleaned up by removing all the useless things that were generated. It is perfectly usable as it is, but it would be better if we could build in the future something like CSharpWriter on top of it.

Again, a lot of stuff moved around, because that's my favorite thing to do 😛

Please update your config file and test the PR to confirm there's no regression on your side (well, you could wait for me to test it first on Monday).

(Also, I might have changed the output folder of the generators to remove the framework prefix, so we can more easily test between full .NET and Core in the future.)

@JabX JabX requested a review from c3dr0x June 9, 2018 21:04
@JabX
Copy link
Collaborator Author

JabX commented Jun 15, 2018

I checked on my project and it works well.

I added a new feature to use the default values from the OOM to generate the adequate C# for EF and the default value in the generated SQL. I think it should work with SSDT too, with the default value file overriding the default values set in the OOM.

I also removed the MSBuild dependency for SSDT as discussed (since wildcards work!)

Finally, I rebased (painfully) on master, so please check that everything still works fine for you, and you can merge.

@JabX
Copy link
Collaborator Author

JabX commented Jun 15, 2018

I managed to get both generators work on .NET Core with minimal changes.
You'll need the 2.1 SDK installed (it doesn't come with VS yet) and to change your generators calls from %modgen%.exe to dotnet %modgen%.dll.

@JabX JabX changed the title Kinetix.Tools.Core + T4 and parameters singleton removal Kinetix.Tools.Core + T4 and parameters singleton removal + .NET Core Jun 15, 2018
@c3dr0x
Copy link
Collaborator

c3dr0x commented Jun 26, 2018

So, I tried It.

Class generator

Almost ok, it changed the content of my sqlproj file by what seems to be the content of a list factory sql file

----
---- ATTENTION CE FICHIER EST GENERE AUTOMATIQUEMENT (7667C01C58993CD698162FA04A2840CE180E56F7) !
----

-- ===========================================================================================
--   Description		:	Insertion des valeurs de listes statiques.
-- ===========================================================================================

Service generator

It doesn't run:

image

@JabX
Copy link
Collaborator Author

JabX commented Jun 26, 2018

The ModGen issue is weird and I'd appreciate if you could take a look at what's happening (since you have a SSDT project on hand). It should be pretty trivial to find the problem and fix it.

And I'm pretty sure the ServiceGen issue comes from the fact that your project is a classic ASP.NET project that the .NET Core SDK cannot open... Which is probably (one of the reasons) why the classic MSBuildWorkspace isn't supported on Core. I'm gonna look into it when I have the time to try and find a solution for this (which doesn't force us to go back to full .NET)

@c3dr0x
Copy link
Collaborator

c3dr0x commented Jul 3, 2018

Okay I found why it changed the .sqlproj file

https://github.com/get-focus/kinetix-tools/blob/preemptive-refactor/Kinetix.ClassGenerator/SsdtSchemaGenerator/SqlScriptEngine.cs#L100

You gave the sqlproj path to edit instead of the scriptfile path

@c3dr0x c3dr0x added the enhancement New feature or request label Jul 3, 2018
Copy link
Collaborator

@c3dr0x c3dr0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SpaServiceGenerator is broken for framework projects

@JabX
Copy link
Collaborator Author

JabX commented Jul 17, 2018

The sqlproj problem should be fixed now, and I added the option to multitarget net471 and netcoreapp2.1 because using MSBuildWorkspace is mandatory to handle non-Core projects and isn't available on Core.

I also noticed that Buildalyzer wasn't properly emulating MSBuildWorkspace on Core because it didn't fill the Folders property on each Document. So I added a workaround for it (specific to Core) and fixed the code so that the behavior (and the output) is identical between both versions. Meaning I can use the net471 version to generate for a Core project (netcoreapp2.1 will be mandatory when we'll want to package it as a tool but we're not here yet).

Please let me know if it works fine for you, so that we can merge it and go forward with new changes.

var secondFolder = controller.Folders.Count > 1 ? $"/{string.Join("/", controller.Folders.Skip(1).Select(f => f.ToDashCase()))}" : string.Empty;
var folderCount = (frontEnds.Count() > 1 ? 1 : 0) + controller.Folders.Count;
var secondFolder = folders.Count > 1 ? $"/{string.Join("/", folders.Skip(1).Select(f => f.ToDashCase()))}" : string.Empty;
var folderCount = (frontEnds.Count() > 1 ? 1 : 0) + folders.Count - 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to generate the JS imports in the service files, and I noticed a "-1" was missing (my Folders.Count was always 0 instead of always 1, so I didn't catch it).
I hope this works for your folder hierarchy

@c3dr0x c3dr0x merged commit dfbc295 into master Jul 24, 2018
@c3dr0x c3dr0x deleted the preemptive-refactor branch July 24, 2018 09:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants