scottdurow / SparkleXrm

An open-source library for building Dynamics CRM XRM solutions using Script#, jQuery & Knockoutjs.
MIT License
264 stars 194 forks source link

Custom API Earlybound code splitting incorrectly #453

Open MrCliffster opened 2 years ago

MrCliffster commented 2 years ago

Problem: When generating Earlybound classes including Custom APIs the Custom API files are incomplete

After running earlybound.bat, spkl successfully generates the full suite of directories and files for Entities, Actions, and OptionSets as shown: image However, the class files for the individual Custom API actions are badly formed: image The key issue is the badly formed string on line 3, which is actually part of the serialisation attributes that crmsvcutil generates as shown on line 10453 in the monolithic file: image

Suspected Cause

The regex that splits classes in CodeSplitter.cs is not correctly able to deal with the schema being provided by crmsvcutil as part of the DataContractAttribute shown in the third screenshot above. The schema namespace Namespace="http://schemas.microsoft.com/xrm/2011/new/" is unique to these Custom APIs in the monolithic EarlyBoundTypes.cs file that the tool outputs. I think a fix to the regex in Spkl's SourceCodeTypeExtractor.cs located here, specifically the ClassRegex, should alleviate this problem.

MrCliffster commented 2 years ago

For those that stumble across this issue, the temporary workaround I use is to manually copy-paste the line that is broken into each custom action, each time I generate EBG files. The line is: [System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")]