-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workaround for kiota nullability bug at microsoft/kiota#3944 (com…
- Loading branch information
Showing
711 changed files
with
6,830 additions
and
19,161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<# | ||
Patches C# code generated by kiota. | ||
Workaround for bug at https://github.com/microsoft/kiota/issues/3944#issuecomment-2597201229. | ||
#> | ||
param ( | ||
# Path to directory where kiota generated C# code. | ||
[Parameter(Mandatory=$true)] | ||
[string]$kiotaOutputDir | ||
) | ||
|
||
$osLineBreak = [System.Environment]::NewLine | ||
$files = Get-ChildItem -Path $kiotaOutputDir -Recurse -Include *.cs | ||
|
||
foreach ($file in $files) | ||
{ | ||
$content = Get-Content $file -Raw | ||
|
||
# add #nullable enable, suppress warning CS8625: Cannot convert null literal to non-nullable reference type. | ||
$content = ($content -replace '// <auto-generated/>', "// <auto-generated/>$osLineBreak#nullable enable$osLineBreak#pragma warning disable CS8625") | ||
|
||
# remove conditionals | ||
$content = ($content -replace "(?s)#if NETSTANDARD2_1_OR_GREATER .*?$osLineBreak#nullable enable$osLineBreak(?<ifBody>.*?)$osLineBreak#nullable restore$osLineBreak#else$osLineBreak(?<elseBody>.*?)$osLineBreak#endif", "`$1") | ||
|
||
# insert new line between member and next summary | ||
$content = ($content -replace "}$osLineBreak(?<indentedSummary>\s+/// <summary>)", "}$osLineBreak$osLineBreak`$1") | ||
|
||
Set-Content -Path $file -Value $content | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.