-
Notifications
You must be signed in to change notification settings - Fork 199
Integrate EarlyBound Generator API #383
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
Conversation
Removed Previous CrmSvcUtil Utilities. Mapped all settings of earlyboundtypes except generateStateEnums and GenerateGlobalOptionSets. There are no settings currently for this in the EarlyBoundGenerator, and I can't think of a good reason why you would not want to include these. Updated EarlyBoundTypeConfig to inherit from DLaB.EarlyBoundGeneator.Settings.POCO.ExtensionConfig. This means all settings in the EarlyBoundGenerator will be allowed (except it they are overriden with the current settings of the EarlyBoundTypeConfig. Also added names for the action, and optionSet. Updated Tests. Updated VS. Not sure that matters...
Not sure why, but the tests failed for the older logic when generating a file per entity because the entities.cs file wasn't getting deleted. I don't believe I've done anything to remove any code that deletes those files, so I've left it there. If I have some how, then let me know and i'll figure out how to add it back I guess. |
Here is the update to the documentation: Wherever you can, it's best practice to use early bound types in your C# code. You can easily get spkl to generate these classes in a way that can be repeatedly run and refreshed when your schema changes. There are two main options for generating earlybound types, spkl has it's own built in generator, as well as the EarlyBoundGeneratorApi, the same one built for the XrmToolBox. To use the spkl internal generator your spkl.json would look like:
To use the EarlyBoundGeneratorApi your spkl.json would look like:
No matter which generator you use, you can refresh the classes file by calling: spkl earlybound |
This is a great idea. I wonder about a slightly different use case. Could the earlyboundconfig generated by XrmToolbox be referenced in the config when using Daryls Early Bound generator within spkl? This gives the benefits of the XrmToolbox configuration screens, whilst the consistent/combined usage within spkl, something like: "earlyboundtypes": [ I'm not sure if that will introduce tool close a version dependency - e.g. if XrmToolbox logic is updated, but spkl doesn't have a corresponding release using the updated EBG library then the config might not be used. A thought anyway. |
In order to be as compatible with the Spkl framework as possible, I used the config settings from spkl to override the EBG settings. Where there wasn't a compatible setting, I used the same settings as the EBG. So it would not be too hard to transfer the settings over manually. And if you are opening the EBG to generate the config, you might as well just use the EBG to generate your entities. |
This is great @daryllabar ! Would you mind to also add possibility of having entities and actions as collection like proposed by me in #353 ? This really matters for big projects with a lot of entities and many people merging spkl.json in parallel and it's super simple to have it as an alternative to single, comma separated string. |
The EBG itself supports putting the logical names on new lines, while still being pipe delimited, so if it's essential, you can decide just to use that instead. Problem is I use the same method as the Spkl framework to get the logical names, so that won't work in your case. The simplest thing I can think of is to create an override setting that points to an EBG xml file, Instead of the JSON. Once this PR gets approved, feel free to submit a PR for either approach, it would be rather trival. |
This looks like it's because of c53631f#diff-a3e89ccc902720e9929d5a1f5ef72f68 |
Sorry, it's been awhile since i looked at this. I'm guessing you want me to make the older tests pass, and to check out the code that you are calling out as the culprit? |
Thanks @daryllabar - No it's fine - I've got a branch where I'm testing before merging - I've added the delete of entities.cs back in. @ewingjm - I think the issue here is that the code splitting should split out the context - rather than leaving the original entities.cs in there. |
@daryllabar - Not sure why, but the EbgApi version of the integration tests take 10 times longer to run - any idea why? |
Not sure. I do a lot of work with naming of entities that require me to go loop through the generated code multiple times before it's actually written to disk. Maybe that's it? Any improvement for tests that don't split the file up into multiple files? |
Ah, yes - that makes much more sense! |
Done some testing this morning:
|
|
I can fix those things. Also - I had to add logic to only set MaskPassword to true if the connection string contains a password - currently the https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/blob/033048492159d7bbd2a5354e3c7f6b01143804c7/DLaB.EarlyBoundGenerator.Logic/Logic.cs#L217 will fail with Index was out of range. |
Also - in your PR - you've added a reference to Microsoft.VisualBasic - is that really needed? |
I've added an issue on my side for the Mask Password thing. Thanks for pointing it out. |
Replaced by #389 |
PR for Integrate EarlyBound Generator #378
Added a new useEarlyBoundGeneratorApi flag to allow for using the EBG vs the Spkrl logic. Mapped all settings of earlyboundtypes except generateStateEnums and GenerateGlobalOptionSets as there are no settings currently for this in the EarlyBoundGenerator.
Updated EarlyBoundTypeConfig to inherit from DLaB.EarlyBoundGeneator.Settings.POCO.ExtensionConfig. This means all settings in the EarlyBoundGenerator will be allowed (except it they are overriden with the current settings of the EarlyBoundTypeConfig. Also added names for the action, and optionSet.
Updated Tests.