@@ -27,6 +27,7 @@ prefix: Mg
2727module-name : Microsoft.Graph.$(service-name)
2828subject-prefix : $(service-name)
2929namespace : Microsoft.Graph.PowerShell
30+ sanitize-names : false
3031` ` `
3132
3233> Folders
@@ -51,7 +52,9 @@ directive:
5152 - microsoft.graph.post
5253 - microsoft.graph.sectionGroup
5354 - microsoft.graph.team
54- # Formart cmdlet response.
55+ - microsoft.graph.recipient
56+
57+ # Format cmdlet response.
5558 - where :
5659 model-name : MicrosoftGraphUser
5760 set :
@@ -289,13 +292,41 @@ directive:
289292 set :
290293 verb : Get
291294 subject : $2$1
292-
293- # Alias entityIds as Ids
294- - where :
295- verb : Get|Remove
296- subject : (.*)
297- parameter-name : Id$
298- set :
299- alias :
300- - Id
295+ # Add AfterToJson
296+ - from : source-file-csharp
297+ where : $
298+ transform : >
299+ if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*.cs/gm))
300+ {
301+ return $;
302+ } else {
303+ let regexPattern = /^\s*public\s*partial\s*class\s*MicrosoftGraph(?<EntityName>.*):$/gm;
304+ let regexArray;
305+ while ((regexArray = regexPattern.exec($)) !== null) {
306+ if (regexArray['groups'] != null)
307+ {
308+ let EntityName = regexArray['groups'].EntityName.trim();
309+ let newEntityId = EntityName + 'Id';
310+ let newEntityIdPropRegex = new RegExp("^\\s*public\\s*string\\s*"+newEntityId+"\\.*","gm");
311+ let existingIdPropRegex = /(^\s*)(public\s*string\s*Id\s.*)/gm;
312+ if ((!$.match(newEntityIdPropRegex)) && $.match(existingIdPropRegex) && (newEntityId != "DirectoryObjectId") && (newEntityId != "EntityId") && (newEntityId != "BaseItemId")) {
313+ $ = $.replace(existingIdPropRegex, '$1$2\n$1partial void AfterToJson(ref Microsoft.Graph.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.PowerShell.Runtime.SerializationMode serializationMode) { if (serializationMode == Microsoft.Graph.PowerShell.Runtime.SerializationMode.IncludeAll) { AddIf(null != this.Id ? (Microsoft.Graph.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.PowerShell.Runtime.Json.JsonString(this.Id) : null, "'+ EntityName.toLowerCase() +'-id", container.Add); }\n}\n');
314+ }
315+ }
316+ }
317+ return $;
318+ }
319+ - from : source-file-csharp
320+ where : $
321+ transform : >
322+ if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*.json.cs/gm))
323+ {
324+ return $;
325+ } else {
326+ let afterJsonDeclarationRegex = /(^\s*)(partial\s*void\s*AfterFromJson\s*\(Microsoft.Graph.PowerShell.Runtime.Json.JsonObject\s*json\s*\);$)/gm
327+ $ = $.replace(afterJsonDeclarationRegex, '$1$2\n$1partial void AfterToJson(ref Microsoft.Graph.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.PowerShell.Runtime.SerializationMode serializationMode);\n');
328+ let afterJsonRegex = /(^\s*)(AfterToJson\(ref\s*container\s*\);$)/gm
329+ $ = $.replace(afterJsonRegex, '$1$2\n$1AfterToJson(ref container, serializationMode);\n');
330+ return $;
331+ }
301332` ` `
0 commit comments