Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service Module Response Count #542

Merged
merged 4 commits into from
Feb 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 39 additions & 20 deletions src/readme.graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,20 @@ directive:
$ = $.replace(complexTypeHintRegex, getExclusionsDynamically + '\n$1$2');
}

return $;
}
# Modify generated .dictionary.cs model classes.
- from: source-file-csharp
where: $
transform: >
if (!$documentPath.match(/generated%5Capi%5CModels%5C\w*\d*.dictionary.cs/gm))
{
return $;
} else {
// Remove Count, Keys, and Values properties from implementations of an IAssociativeArray in models.
let propertiesToRemoveRegex = /^.*Microsoft\.Graph\.PowerShell\.Runtime\.IAssociativeArray<global::System\.Object>\.(Count|Keys|Values).*$/gm
$ = $.replace(propertiesToRemoveRegex, '');

return $;
}
# Modify generated .cs model classes.
Expand All @@ -479,30 +493,12 @@ directive:
{
return $;
} else {
// Add new modifier to 'values' properties of classes that derive from an IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
let valuesPropertiesRegex = /(SerializedName\s*=\s*@"values".*\s*.*)(\s*)(.*Values\s*{\s*get;\s*set;\s*})/gmi
if($.match(valuesPropertiesRegex)) {
$ = $.replace(valuesPropertiesRegex, '$1$2 new $3');
}

// Add new modifier to 'additionalProperties' properties of classes that derive from an IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
// Add new modifier to 'additionalProperties' properties of classes that implement IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
let additionalPropertiesRegex = /(SerializedName\s*=\s*@"additionalProperties".*\s*.*)(\s*)(.*AdditionalProperties\s*{\s*get;\s*set;\s*})/gmi
if($.match(additionalPropertiesRegex)) {
$ = $.replace(additionalPropertiesRegex, '$1$2 new $3');
}

// Add new modifier to 'keys' properties of classes that derive from an IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
let keysRegex = /(SerializedName\s*=\s*@"keys".*\s*.*)(\s*)(.*Keys\s*{\s*get;\s*set;\s*})/gmi
if($.match(keysRegex)) {
$ = $.replace(keysRegex, '$1$2 new $3');
}

// Add new modifier to 'count' properties of classes that derive from an IAssociativeArray. See example https://regex101.com/r/hnX7xO/2.
let countRegex = /(SerializedName\s*=\s*@"count".*\s*.*)(\s*)(.*Count\s*{\s*get;\s*set;\s*})/gmi
if($.match(countRegex)) {
$ = $.replace(countRegex, '$1$2 new $3');
}

let regexPattern = /^\s*public\s*partial\s*class\s*MicrosoftGraph(?<EntityName>.*):$/gm;
let regexArray;
while ((regexArray = regexPattern.exec($)) !== null) {
Expand Down Expand Up @@ -637,7 +633,7 @@ directive:
return $;
}

# Modify generated runtime IJsonSerializable class.
# Modify generated runtime IJsonSerializable interface.
- from: source-file-csharp
where: $
transform: >
Expand All @@ -651,6 +647,29 @@ directive:
return $;
}

# Modify generated runtime IAssociativeArray interface.
- from: source-file-csharp
where: $
transform: >
if (!$documentPath.match(/generated%5Cruntime%5CIAssociativeArray.cs/gm))
{
return $;
} else {
// Remove Count from IAssociativeArray interface.
let countRegex = /int\s*Count\s*{\s*get;\s*}/gm
$ = $.replace(countRegex, '');

// Remove Keys from IAssociativeArray interface.
let keysRegex = /System\.Collections\.Generic\.IEnumerable<string>\s*Keys\s*{\s*get;\s*}/gm
$ = $.replace(keysRegex, '');

// Remove Values from IAssociativeArray interface.
let valuesRegex = /System\.Collections\.Generic\.IEnumerable<T>\s*Values\s*{\s*get;\s*}/gm
$ = $.replace(valuesRegex, '');

return $;
}

# Serialize all $count parameter to lowercase true or false.
- from: source-file-csharp
where: $
Expand Down