Skip to content

Commit 3c23712

Browse files
committed
fix: SFDC has some metadata fields with embedded newlines, fix the models and have model generator sanitize those string
1 parent 2e181b7 commit 3c23712

6 files changed

Lines changed: 18 additions & 152 deletions

File tree

‎src/NetCoreForce.ModelGenerator/Program.cs‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Net;
77
using System.Text;
8+
using System.Text.RegularExpressions;
89
using System.Threading.Tasks;
910
using McMaster.Extensions.CommandLineUtils;
1011
using NetCoreForce.Client;
@@ -585,7 +586,7 @@ public static async Task<string> GenClass(ForceClient client, string objectName,
585586
gen.AppendLine("{");
586587
}
587588
gen.AppendLine("\t///<summary>");
588-
gen.AppendLine($"\t/// {WebUtility.HtmlEncode(data.Label)}");
589+
gen.AppendLine($"\t/// {DocCommentText(data.Label)}");
589590
gen.AppendLine($"\t///<para>SObject Name: {data.Name}</para>");
590591
gen.AppendLine($"\t///<para>Custom Object: {data.Custom.ToString()}</para>");
591592
gen.AppendLine("\t///</summary>");
@@ -614,7 +615,7 @@ public static async Task<string> GenClass(ForceClient client, string objectName,
614615
}
615616

616617
gen.AppendLine("\t\t///<summary>");
617-
gen.AppendLine("\t\t/// " + WebUtility.HtmlEncode(field.Label));
618+
gen.AppendLine("\t\t/// " + DocCommentText(field.Label));
618619
gen.AppendLine("\t\t/// <para>Name: " + field.Name + "</para>");
619620
gen.AppendLine("\t\t/// <para>SF Type: " + field.Type + "</para>");
620621
if (field.AutoNumber)
@@ -720,6 +721,21 @@ private static string GetPrefixedSuffixed(GenConfig config, string name)
720721
return string.Format("{0}{1}{2}", config.ClassPrefix ?? string.Empty, name, config.ClassSuffix ?? string.Empty);
721722
}
722723

724+
/// <summary>
725+
/// Formats text for a single line XML doc comment - collapses line breaks and repeated whitespace, and encodes XML characters.
726+
/// <para>Some Salesforce labels contain line breaks, which would otherwise end the doc comment early and produce badly formed XML.</para>
727+
/// </summary>
728+
private static string DocCommentText(string text)
729+
{
730+
if (string.IsNullOrEmpty(text))
731+
{
732+
return string.Empty;
733+
}
734+
735+
string singleLine = Regex.Replace(text, @"\s+", " ").Trim();
736+
return WebUtility.HtmlEncode(singleLine);
737+
}
738+
723739
private static string JsonName(string fieldName)
724740
{
725741
string jsonName = fieldName;

‎src/NetCoreForce.Models/SfMutingPermissionSet.cs‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3701,7 +3701,6 @@ public static string SObjectTypeName
37013701

37023702
///<summary>
37033703
/// View Change Request Dashboard
3704-
37053704
/// <para>Name: PermissionsViewChangeRequestDshbrd</para>
37063705
/// <para>SF Type: boolean</para>
37073706
/// <para>Nillable: False</para>
@@ -3711,7 +3710,6 @@ public static string SObjectTypeName
37113710

37123711
///<summary>
37133712
/// View Incident Fulfiller Dashboard
3714-
37153713
/// <para>Name: PermissionsViewIncidentFulfrDshbrd</para>
37163714
/// <para>SF Type: boolean</para>
37173715
/// <para>Nillable: False</para>
@@ -3721,7 +3719,6 @@ public static string SObjectTypeName
37213719

37223720
///<summary>
37233721
/// View Problem Fulfiller Dashboard
3724-
37253722
/// <para>Name: PermissionsViewProblemFulfrDshbrd</para>
37263723
/// <para>SF Type: boolean</para>
37273724
/// <para>Nillable: False</para>
@@ -3731,7 +3728,6 @@ public static string SObjectTypeName
37313728

37323729
///<summary>
37333730
/// View Problem Manager Dashboard
3734-
37353731
/// <para>Name: PermissionsViewProblemMgrDshbrd</para>
37363732
/// <para>SF Type: boolean</para>
37373733
/// <para>Nillable: False</para>
@@ -3741,7 +3737,6 @@ public static string SObjectTypeName
37413737

37423738
///<summary>
37433739
/// View IT Leader Analytics Dashboard
3744-
37453740
/// <para>Name: PermissionsViewItLeaderAnlytDshbrd</para>
37463741
/// <para>SF Type: boolean</para>
37473742
/// <para>Nillable: False</para>
@@ -3751,7 +3746,6 @@ public static string SObjectTypeName
37513746

37523747
///<summary>
37533748
/// View Incident Analytics Dashboard
3754-
37553749
/// <para>Name: PermissionsViewIncidentAnlytDshbrd</para>
37563750
/// <para>SF Type: boolean</para>
37573751
/// <para>Nillable: False</para>
@@ -3761,7 +3755,6 @@ public static string SObjectTypeName
37613755

37623756
///<summary>
37633757
/// View Change Request Analytics Dashboard
3764-
37653758
/// <para>Name: PermissionsViewChangeRequestAnlytDshbrd</para>
37663759
/// <para>SF Type: boolean</para>
37673760
/// <para>Nillable: False</para>
@@ -3771,7 +3764,6 @@ public static string SObjectTypeName
37713764

37723765
///<summary>
37733766
/// View Case Analytics Dashboard
3774-
37753767
/// <para>Name: PermissionsViewCaseAnlytDshbrd</para>
37763768
/// <para>SF Type: boolean</para>
37773769
/// <para>Nillable: False</para>
@@ -3781,7 +3773,6 @@ public static string SObjectTypeName
37813773

37823774
///<summary>
37833775
/// Propose Major Incidents
3784-
37853776
/// <para>Name: PermissionsProposeMajorIncidents</para>
37863777
/// <para>SF Type: boolean</para>
37873778
/// <para>Nillable: False</para>
@@ -3791,7 +3782,6 @@ public static string SObjectTypeName
37913782

37923783
///<summary>
37933784
/// Delete Incident
3794-
37953785
/// <para>Name: PermissionsDeleteIncident</para>
37963786
/// <para>SF Type: boolean</para>
37973787
/// <para>Nillable: False</para>
@@ -3801,7 +3791,6 @@ public static string SObjectTypeName
38013791

38023792
///<summary>
38033793
/// Accept Risk For Problems
3804-
38053794
/// <para>Name: PermissionsAcceptRiskForProblems</para>
38063795
/// <para>SF Type: boolean</para>
38073796
/// <para>Nillable: False</para>
@@ -3811,7 +3800,6 @@ public static string SObjectTypeName
38113800

38123801
///<summary>
38133802
/// Reopen Problems
3814-
38153803
/// <para>Name: PermissionsReopenProblems</para>
38163804
/// <para>SF Type: boolean</para>
38173805
/// <para>Nillable: False</para>
@@ -3821,7 +3809,6 @@ public static string SObjectTypeName
38213809

38223810
///<summary>
38233811
/// Associate Incidents and Problems
3824-
38253812
/// <para>Name: PermissionsAssocIncAndProb</para>
38263813
/// <para>SF Type: boolean</para>
38273814
/// <para>Nillable: False</para>
@@ -3831,7 +3818,6 @@ public static string SObjectTypeName
38313818

38323819
///<summary>
38333820
/// Associate Incidents and Change Requests
3834-
38353821
/// <para>Name: PermissionsAssocIncAndChgRqst</para>
38363822
/// <para>SF Type: boolean</para>
38373823
/// <para>Nillable: False</para>
@@ -3841,7 +3827,6 @@ public static string SObjectTypeName
38413827

38423828
///<summary>
38433829
/// Delete Problem
3844-
38453830
/// <para>Name: PermissionsDeleteProblem</para>
38463831
/// <para>SF Type: boolean</para>
38473832
/// <para>Nillable: False</para>
@@ -3860,7 +3845,6 @@ public static string SObjectTypeName
38603845

38613846
///<summary>
38623847
/// Delete Change Request
3863-
38643848
/// <para>Name: PermissionsDeleteChangeRequest</para>
38653849
/// <para>SF Type: boolean</para>
38663850
/// <para>Nillable: False</para>
@@ -3870,7 +3854,6 @@ public static string SObjectTypeName
38703854

38713855
///<summary>
38723856
/// Allows user to read CMDB associations details.
3873-
38743857
/// <para>Name: PermissionsReadConfigurationItemInformation</para>
38753858
/// <para>SF Type: boolean</para>
38763859
/// <para>Nillable: False</para>
@@ -3880,7 +3863,6 @@ public static string SObjectTypeName
38803863

38813864
///<summary>
38823865
/// View Agentic IT Service Desk App Home Page
3883-
38843866
/// <para>Name: PermissionsViewItsmConsoleHmpg</para>
38853867
/// <para>SF Type: boolean</para>
38863868
/// <para>Nillable: False</para>
@@ -3890,7 +3872,6 @@ public static string SObjectTypeName
38903872

38913873
///<summary>
38923874
/// View Agentic IT Service Desk App as Fulfillers
3893-
38943875
/// <para>Name: PermissionsViewItsmConsoleAsFulfr</para>
38953876
/// <para>SF Type: boolean</para>
38963877
/// <para>Nillable: False</para>
@@ -3900,7 +3881,6 @@ public static string SObjectTypeName
39003881

39013882
///<summary>
39023883
/// View Omnichannel Analytics Dashboard
3903-
39043884
/// <para>Name: PermissionsViewOmnichnlAnlytDshbrd</para>
39053885
/// <para>SF Type: boolean</para>
39063886
/// <para>Nillable: False</para>
@@ -3910,7 +3890,6 @@ public static string SObjectTypeName
39103890

39113891
///<summary>
39123892
/// View Knowledge Analytics Dashboard
3913-
39143893
/// <para>Name: PermissionsViewKnwlgAnlytDshbrd</para>
39153894
/// <para>SF Type: boolean</para>
39163895
/// <para>Nillable: False</para>
@@ -3920,7 +3899,6 @@ public static string SObjectTypeName
39203899

39213900
///<summary>
39223901
/// View Agentforce Analytics Dashboard
3923-
39243902
/// <para>Name: PermissionsViewAgtfrceAnlytDshbrd</para>
39253903
/// <para>SF Type: boolean</para>
39263904
/// <para>Nillable: False</para>
@@ -3930,7 +3908,6 @@ public static string SObjectTypeName
39303908

39313909
///<summary>
39323910
/// View Incident Manager Dashboard
3933-
39343911
/// <para>Name: PermissionsViewIncidentMgrDshbrd</para>
39353912
/// <para>SF Type: boolean</para>
39363913
/// <para>Nillable: False</para>
@@ -3958,7 +3935,6 @@ public static string SObjectTypeName
39583935

39593936
///<summary>
39603937
/// Associate Change Requests and Problems
3961-
39623938
/// <para>Name: PermissionsAssocChgRqstAndProb</para>
39633939
/// <para>SF Type: boolean</para>
39643940
/// <para>Nillable: False</para>
@@ -3968,7 +3944,6 @@ public static string SObjectTypeName
39683944

39693945
///<summary>
39703946
/// Associate Releases and Problems
3971-
39723947
/// <para>Name: PermissionsAssocRelAndProb</para>
39733948
/// <para>SF Type: boolean</para>
39743949
/// <para>Nillable: False</para>
@@ -3978,7 +3953,6 @@ public static string SObjectTypeName
39783953

39793954
///<summary>
39803955
/// Associate Releases and Incidents
3981-
39823956
/// <para>Name: PermissionsAssocRelAndInc</para>
39833957
/// <para>SF Type: boolean</para>
39843958
/// <para>Nillable: False</para>
@@ -3988,7 +3962,6 @@ public static string SObjectTypeName
39883962

39893963
///<summary>
39903964
/// Associate Releases and Change Requests
3991-
39923965
/// <para>Name: PermissionsAssocRelAndChgRqst</para>
39933966
/// <para>SF Type: boolean</para>
39943967
/// <para>Nillable: False</para>
@@ -3998,7 +3971,6 @@ public static string SObjectTypeName
39983971

39993972
///<summary>
40003973
/// Resolve Incident Associations
4001-
40023974
/// <para>Name: PermissionsResolveIncAssoc</para>
40033975
/// <para>SF Type: boolean</para>
40043976
/// <para>Nillable: False</para>
@@ -4008,7 +3980,6 @@ public static string SObjectTypeName
40083980

40093981
///<summary>
40103982
/// Resolve Problem Associations
4011-
40123983
/// <para>Name: PermissionsResolveProbAssoc</para>
40133984
/// <para>SF Type: boolean</para>
40143985
/// <para>Nillable: False</para>
@@ -4018,7 +3989,6 @@ public static string SObjectTypeName
40183989

40193990
///<summary>
40203991
/// Resolve Change Request Associations
4021-
40223992
/// <para>Name: PermissionsResolveChgRqstAssoc</para>
40233993
/// <para>SF Type: boolean</para>
40243994
/// <para>Nillable: False</para>

0 commit comments

Comments
 (0)