You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Pass exclusion properties to base classes during serialization.
379
+
let baseClassInitializerRegex = /(new\s*Microsoft.Graph.PowerShell.Models.MicrosoftGraph\w*\(\s*json\s*,\s*new\s*global::System.Collections.Generic.HashSet<string>\()(\){\W.*}\);)/gm
380
+
$ = $.replace(baseClassInitializerRegex, '$1(exclusions ?? new System.Collections.Generic.HashSet<string>())$2');
376
381
return $;
377
382
}
383
+
# Modify generated .cs model classes.
378
384
- from: source-file-csharp
379
385
where: $
380
386
transform: >
@@ -388,6 +394,24 @@ directive:
388
394
$ = $.replace(valuesPropertiesRegex, '$1$2 new $3');
389
395
}
390
396
397
+
// Add new modifier to 'additionalProperties' properties of classes that derive from an IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
398
+
let additionalPropertiesRegex = /(SerializedName\s*=\s*@"additionalProperties".*\s*.*)(\s*)(.*AdditionalProperties\s*{\s*get;\s*set;\s*})/gmi
399
+
if($.match(additionalPropertiesRegex)) {
400
+
$ = $.replace(additionalPropertiesRegex, '$1$2 new $3');
401
+
}
402
+
403
+
// Add new modifier to 'keys' properties of classes that derive from an IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
404
+
let keysRegex = /(SerializedName\s*=\s*@"keys".*\s*.*)(\s*)(.*Keys\s*{\s*get;\s*set;\s*})/gmi
405
+
if($.match(keysRegex)) {
406
+
$ = $.replace(keysRegex, '$1$2 new $3');
407
+
}
408
+
409
+
// Add new modifier to 'count' properties of classes that derive from an IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
410
+
let countRegex = /(SerializedName\s*=\s*@"count".*\s*.*)(\s*)(.*Count\s*{\s*get;\s*set;\s*})/gmi
411
+
if($.match(countRegex)) {
412
+
$ = $.replace(countRegex, '$1$2 new $3');
413
+
}
414
+
391
415
let regexPattern = /^\s*public\s*partial\s*class\s*MicrosoftGraph(?<EntityName>.*):$/gm;
392
416
let regexArray;
393
417
while ((regexArray = regexPattern.exec($)) !== null) {
@@ -404,29 +428,36 @@ directive:
404
428
}
405
429
return $;
406
430
}
407
-
#Override OnDefault to handle all success, 2xx responses, as success and not error.
431
+
#Modify generated .cs cmdlets.
408
432
- from: source-file-csharp
409
433
where: $
410
434
transform: >
411
435
if (!$documentPath.match(/generated%2Fcmdlets%2F\w*\d*.cs/gm))
412
436
{
413
437
return $;
414
438
} else {
439
+
// Initialize AdditionalProperties prop to a new Hashtable by default.
440
+
let additionalPropertiesPropRegex = /System.Collections.Hashtable\s*AdditionalProperties\s*{\s*get;\s*set;\s*}$/gmi
441
+
let newAdditionalPropertiesProp = "System.Collections.Hashtable AdditionalProperties { get; set; } = new System.Collections.Hashtable();"
0 commit comments