Skip to content

Commit af0e9fd

Browse files
authored
Merge pull request #391 from microsoftgraph/bugfixes/duplicateKey
Bugfixes: Duplicate Key
2 parents 755e785 + f9ee125 commit af0e9fd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/readme.graph.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ directive:
426426
- from: source-file-csharp
427427
where: $
428428
transform: >
429-
if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*\d*.json.cs/gm))
429+
if (!$documentPath.match(/generated%5Capi%5CModels%5C\w*MicrosoftGraph\w*\d*.json.cs/gm))
430430
{
431431
return $;
432432
} else {
@@ -439,6 +439,18 @@ directive:
439439
// Pass exclusion properties to base classes during serialization.
440440
let baseClassInitializerRegex = /(new\s*Microsoft.Graph.PowerShell.Models.MicrosoftGraph\w*\(\s*json\s*,\s*new\s*global::System.Collections.Generic.HashSet<string>\()(\){\W.*}\);)/gm
441441
$ = $.replace(baseClassInitializerRegex, '$1(exclusions ?? new System.Collections.Generic.HashSet<string>())$2');
442+
443+
// Fix additional properties deserialization in Complex Types.
444+
let complexTypeHintRegex = /(\s*)(Microsoft\.Graph\.PowerShell\.Runtime\.JsonSerializable\.FromJson)/gm
445+
if($.match(complexTypeHintRegex)) {
446+
let classNameRegex = /partial\s*class\s*(\w*)\s*{/gm
447+
let match = classNameRegex.exec($);
448+
let interfaceName = "I" + match[1] + "Internal";
449+
450+
let getExclusionsDynamically = '\n$1if (exclusions == null) { exclusions = new System.Collections.Generic.HashSet<string>(global::System.StringComparer.OrdinalIgnoreCase); var properties = typeof('+interfaceName+').GetProperties(); foreach (var property in properties) { exclusions.Add(property.Name);}}'
451+
$ = $.replace(complexTypeHintRegex, getExclusionsDynamically + '\n$1$2');
452+
}
453+
442454
return $;
443455
}
444456
# Modify generated .cs model classes.
@@ -560,6 +572,20 @@ directive:
560572
return $;
561573
}
562574
575+
# Modify generated runtime IJsonSerializable class.
576+
- from: source-file-csharp
577+
where: $
578+
transform: >
579+
if (!$documentPath.match(/generated%5Cruntime%5CCustomizations%5CIJsonSerializable.cs/gm))
580+
{
581+
return $;
582+
} else {
583+
// Changes excludes hashset to a case-insensitive hashset.
584+
let fromJsonRegex = /(\s*FromJson<\w*>\s*\(JsonObject\s*json\s*,\s*System\.Collections\.Generic\.IDictionary.*)(\s*)({)/gm
585+
$ = $.replace(fromJsonRegex, '$1$2$3\n$2 if (excludes != null){ excludes = new System.Collections.Generic.HashSet<string>(excludes, global::System.StringComparer.OrdinalIgnoreCase);}');
586+
return $;
587+
}
588+
563589
# Serialize all $count parameter to lowercase true or false.
564590
- from: source-file-csharp
565591
where: $

0 commit comments

Comments
 (0)