From 2a4328efaac53c75a1401b1727f86dc51cfb7d06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 00:58:23 +0300 Subject: [PATCH 01/14] Bump MSTest.TestFramework from 3.2.0 to 3.2.1 (#1946) Bumps [MSTest.TestFramework](https://github.com/microsoft/testfx) from 3.2.0 to 3.2.1. - [Release notes](https://github.com/microsoft/testfx/releases) - [Changelog](https://github.com/microsoft/testfx/blob/main/docs/Changelog.md) - [Commits](https://github.com/microsoft/testfx/compare/v.3.2.0...v3.2.1) --- updated-dependencies: - dependency-name: MSTest.TestFramework dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ExceptionMiddleware/ExceptionMiddleware.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj index 84a0332a4..b97aceb47 100644 --- a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj +++ b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj @@ -13,7 +13,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive From 891d3438495d3be6d511bf5f57d0c07712b2dd03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 22:17:28 +0000 Subject: [PATCH 02/14] Bump Microsoft.AspNetCore.Authorization from 8.0.1 to 8.0.2 (#1944) Bumps [Microsoft.AspNetCore.Authorization](https://github.com/dotnet/aspnetcore) from 8.0.1 to 8.0.2. - [Release notes](https://github.com/dotnet/aspnetcore/releases) - [Changelog](https://github.com/dotnet/aspnetcore/blob/main/docs/ReleasePlanning.md) - [Commits](https://github.com/dotnet/aspnetcore/compare/v8.0.1...v8.0.2) --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Authorization dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- GraphWebApi/GraphWebApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GraphWebApi/GraphWebApi.csproj b/GraphWebApi/GraphWebApi.csproj index 8e1dd9629..fc2f999c9 100644 --- a/GraphWebApi/GraphWebApi.csproj +++ b/GraphWebApi/GraphWebApi.csproj @@ -46,7 +46,7 @@ - + From 7a633f79aff7bcffb5639d87f04af67cfe0f7d64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 01:52:48 +0300 Subject: [PATCH 03/14] Bump Microsoft.VisualStudio.Web.CodeGeneration.Design (#1943) Bumps [Microsoft.VisualStudio.Web.CodeGeneration.Design](https://github.com/dotnet/Scaffolding) from 7.0.11 to 7.0.12. - [Release notes](https://github.com/dotnet/Scaffolding/releases) - [Commits](https://github.com/dotnet/Scaffolding/commits) --- updated-dependencies: - dependency-name: Microsoft.VisualStudio.Web.CodeGeneration.Design dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- GraphWebApi/GraphWebApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GraphWebApi/GraphWebApi.csproj b/GraphWebApi/GraphWebApi.csproj index fc2f999c9..759177c87 100644 --- a/GraphWebApi/GraphWebApi.csproj +++ b/GraphWebApi/GraphWebApi.csproj @@ -51,7 +51,7 @@ - + From e4e58a1f0b4aee950565dd5b09b37463305132ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 01:53:55 +0300 Subject: [PATCH 04/14] Bump Microsoft.AspNetCore.Authentication.JwtBearer from 7.0.15 to 7.0.16 (#1942) Bumps [Microsoft.AspNetCore.Authentication.JwtBearer](https://github.com/dotnet/aspnetcore) from 7.0.15 to 7.0.16. - [Release notes](https://github.com/dotnet/aspnetcore/releases) - [Changelog](https://github.com/dotnet/aspnetcore/blob/main/docs/ReleasePlanning.md) - [Commits](https://github.com/dotnet/aspnetcore/compare/v7.0.15...v7.0.16) --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Authentication.JwtBearer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- GraphWebApi/GraphWebApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GraphWebApi/GraphWebApi.csproj b/GraphWebApi/GraphWebApi.csproj index 759177c87..be0689f3a 100644 --- a/GraphWebApi/GraphWebApi.csproj +++ b/GraphWebApi/GraphWebApi.csproj @@ -45,7 +45,7 @@ - + From fa00fc315fb6b2d0ca57ec2d0b726046355600c9 Mon Sep 17 00:00:00 2001 From: Millicent Achieng Date: Thu, 15 Feb 2024 10:02:29 +0300 Subject: [PATCH 05/14] Add permissions for GitHub workflows (#1948) --- .github/workflows/sonarcloud.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ad2d95bcd..75ebb0eae 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -9,6 +9,9 @@ on: pull_request: types: [opened, synchronize, reopened] paths-ignore: '.vscode/**' +permissions: + contents: read + pull-requests: write env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} jobs: From e2f12c8392118610b15ea4bb5a4b536e9df0fa83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 06:14:55 +0000 Subject: [PATCH 06/14] Bump xunit from 2.6.6 to 2.7.0 (#1951) Bumps [xunit](https://github.com/xunit/xunit) from 2.6.6 to 2.7.0. - [Commits](https://github.com/xunit/xunit/compare/2.6.6...2.7.0) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../CodeSnippetsReflection.OData.Test.csproj | 2 +- .../CodeSnippetsReflection.OpenAPI.Test.csproj | 2 +- ExceptionMiddleware/ExceptionMiddleware.Test.csproj | 2 +- FileService.Test/FileService.Test.csproj | 2 +- KnownIssuesService.Test/KnownIssuesService.Test.csproj | 2 +- OpenAPIService.Test/OpenAPIService.Test.csproj | 2 +- PermissionsService.Test/PermissionsService.Test.csproj | 2 +- SamplesService.Test/SamplesService.Test.csproj | 2 +- TelemetryService.Test/TelemetrySanitizerService.Test.csproj | 2 +- UriMatchService.Test/UriMatchingService.Test.csproj | 2 +- UtilityService.Test/UtilityService.Test.csproj | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj index fedff16de..5c0a9b2e3 100644 --- a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj +++ b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj @@ -13,7 +13,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj index f82072c16..3494dabb5 100644 --- a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj +++ b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj @@ -13,7 +13,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj index b97aceb47..741901e94 100644 --- a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj +++ b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj @@ -14,7 +14,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/FileService.Test/FileService.Test.csproj b/FileService.Test/FileService.Test.csproj index 7493ee5f8..559336560 100644 --- a/FileService.Test/FileService.Test.csproj +++ b/FileService.Test/FileService.Test.csproj @@ -13,7 +13,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/KnownIssuesService.Test/KnownIssuesService.Test.csproj b/KnownIssuesService.Test/KnownIssuesService.Test.csproj index bf9195163..7d6299498 100644 --- a/KnownIssuesService.Test/KnownIssuesService.Test.csproj +++ b/KnownIssuesService.Test/KnownIssuesService.Test.csproj @@ -24,7 +24,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/OpenAPIService.Test/OpenAPIService.Test.csproj b/OpenAPIService.Test/OpenAPIService.Test.csproj index 90ad89052..d96f78047 100644 --- a/OpenAPIService.Test/OpenAPIService.Test.csproj +++ b/OpenAPIService.Test/OpenAPIService.Test.csproj @@ -28,7 +28,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/PermissionsService.Test/PermissionsService.Test.csproj b/PermissionsService.Test/PermissionsService.Test.csproj index 4bd34868f..738b99205 100644 --- a/PermissionsService.Test/PermissionsService.Test.csproj +++ b/PermissionsService.Test/PermissionsService.Test.csproj @@ -34,7 +34,7 @@ all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SamplesService.Test/SamplesService.Test.csproj b/SamplesService.Test/SamplesService.Test.csproj index 3cab8e358..81df6fbf2 100644 --- a/SamplesService.Test/SamplesService.Test.csproj +++ b/SamplesService.Test/SamplesService.Test.csproj @@ -57,7 +57,7 @@ all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj index 4a2d1e5a6..deb3df137 100644 --- a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj +++ b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj @@ -27,7 +27,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/UriMatchService.Test/UriMatchingService.Test.csproj b/UriMatchService.Test/UriMatchingService.Test.csproj index e4b2e4765..d4349c6c3 100644 --- a/UriMatchService.Test/UriMatchingService.Test.csproj +++ b/UriMatchService.Test/UriMatchingService.Test.csproj @@ -16,7 +16,7 @@ all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UtilityService.Test/UtilityService.Test.csproj b/UtilityService.Test/UtilityService.Test.csproj index a41c99645..43e0c01f7 100644 --- a/UtilityService.Test/UtilityService.Test.csproj +++ b/UtilityService.Test/UtilityService.Test.csproj @@ -12,7 +12,7 @@ all - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 6caf0811b3f8a458d7ba705c99133cae4b95197b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 06:26:59 +0000 Subject: [PATCH 07/14] Bump xunit.runner.visualstudio from 2.5.6 to 2.5.7 (#1952) Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.5.6 to 2.5.7. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/2.5.6...2.5.7) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../CodeSnippetsReflection.OData.Test.csproj | 2 +- .../CodeSnippetsReflection.OpenAPI.Test.csproj | 2 +- ExceptionMiddleware/ExceptionMiddleware.Test.csproj | 2 +- FileService.Test/FileService.Test.csproj | 2 +- KnownIssuesService.Test/KnownIssuesService.Test.csproj | 2 +- OpenAPIService.Test/OpenAPIService.Test.csproj | 2 +- PermissionsService.Test/PermissionsService.Test.csproj | 2 +- SamplesService.Test/SamplesService.Test.csproj | 2 +- TelemetryService.Test/TelemetrySanitizerService.Test.csproj | 2 +- UriMatchService.Test/UriMatchingService.Test.csproj | 2 +- UtilityService.Test/UtilityService.Test.csproj | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj index 5c0a9b2e3..bc9d2db48 100644 --- a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj +++ b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj @@ -14,7 +14,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj index 3494dabb5..418f4ca4f 100644 --- a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj +++ b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj @@ -14,7 +14,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj index 741901e94..9c3799cb8 100644 --- a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj +++ b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj @@ -15,7 +15,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/FileService.Test/FileService.Test.csproj b/FileService.Test/FileService.Test.csproj index 559336560..f618131b3 100644 --- a/FileService.Test/FileService.Test.csproj +++ b/FileService.Test/FileService.Test.csproj @@ -14,7 +14,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/KnownIssuesService.Test/KnownIssuesService.Test.csproj b/KnownIssuesService.Test/KnownIssuesService.Test.csproj index 7d6299498..e1439ea86 100644 --- a/KnownIssuesService.Test/KnownIssuesService.Test.csproj +++ b/KnownIssuesService.Test/KnownIssuesService.Test.csproj @@ -25,7 +25,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/OpenAPIService.Test/OpenAPIService.Test.csproj b/OpenAPIService.Test/OpenAPIService.Test.csproj index d96f78047..640eec05e 100644 --- a/OpenAPIService.Test/OpenAPIService.Test.csproj +++ b/OpenAPIService.Test/OpenAPIService.Test.csproj @@ -29,7 +29,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/PermissionsService.Test/PermissionsService.Test.csproj b/PermissionsService.Test/PermissionsService.Test.csproj index 738b99205..f19107f48 100644 --- a/PermissionsService.Test/PermissionsService.Test.csproj +++ b/PermissionsService.Test/PermissionsService.Test.csproj @@ -35,7 +35,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SamplesService.Test/SamplesService.Test.csproj b/SamplesService.Test/SamplesService.Test.csproj index 81df6fbf2..f6d05b3bd 100644 --- a/SamplesService.Test/SamplesService.Test.csproj +++ b/SamplesService.Test/SamplesService.Test.csproj @@ -58,7 +58,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj index deb3df137..7559e54fc 100644 --- a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj +++ b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj @@ -28,7 +28,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/UriMatchService.Test/UriMatchingService.Test.csproj b/UriMatchService.Test/UriMatchingService.Test.csproj index d4349c6c3..4b8f0203e 100644 --- a/UriMatchService.Test/UriMatchingService.Test.csproj +++ b/UriMatchService.Test/UriMatchingService.Test.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UtilityService.Test/UtilityService.Test.csproj b/UtilityService.Test/UtilityService.Test.csproj index 43e0c01f7..cbca4d486 100644 --- a/UtilityService.Test/UtilityService.Test.csproj +++ b/UtilityService.Test/UtilityService.Test.csproj @@ -13,7 +13,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all From 3fc42898ac4c07345d750b1713c76e43f06420c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:26:01 +0300 Subject: [PATCH 08/14] Bump coverlet.msbuild from 6.0.0 to 6.0.1 (#1957) Bumps [coverlet.msbuild](https://github.com/coverlet-coverage/coverlet) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: coverlet.msbuild dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../CodeSnippetsReflection.OData.Test.csproj | 2 +- .../CodeSnippetsReflection.OpenAPI.Test.csproj | 2 +- ExceptionMiddleware/ExceptionMiddleware.Test.csproj | 2 +- FileService.Test/FileService.Test.csproj | 2 +- KnownIssuesService.Test/KnownIssuesService.Test.csproj | 2 +- OpenAPIService.Test/OpenAPIService.Test.csproj | 2 +- PermissionsService.Test/PermissionsService.Test.csproj | 2 +- SamplesService.Test/SamplesService.Test.csproj | 2 +- TelemetryService.Test/TelemetrySanitizerService.Test.csproj | 2 +- UriMatchService.Test/UriMatchingService.Test.csproj | 2 +- UtilityService.Test/UtilityService.Test.csproj | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj index bc9d2db48..f00e6ea70 100644 --- a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj +++ b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj @@ -7,7 +7,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj index 418f4ca4f..6a55fd50e 100644 --- a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj +++ b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj @@ -7,7 +7,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj index 9c3799cb8..df2436945 100644 --- a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj +++ b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj @@ -7,7 +7,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/FileService.Test/FileService.Test.csproj b/FileService.Test/FileService.Test.csproj index f618131b3..d45928a48 100644 --- a/FileService.Test/FileService.Test.csproj +++ b/FileService.Test/FileService.Test.csproj @@ -7,7 +7,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/KnownIssuesService.Test/KnownIssuesService.Test.csproj b/KnownIssuesService.Test/KnownIssuesService.Test.csproj index e1439ea86..410daf276 100644 --- a/KnownIssuesService.Test/KnownIssuesService.Test.csproj +++ b/KnownIssuesService.Test/KnownIssuesService.Test.csproj @@ -15,7 +15,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/OpenAPIService.Test/OpenAPIService.Test.csproj b/OpenAPIService.Test/OpenAPIService.Test.csproj index 640eec05e..b959915d6 100644 --- a/OpenAPIService.Test/OpenAPIService.Test.csproj +++ b/OpenAPIService.Test/OpenAPIService.Test.csproj @@ -21,7 +21,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/PermissionsService.Test/PermissionsService.Test.csproj b/PermissionsService.Test/PermissionsService.Test.csproj index f19107f48..3fe50360b 100644 --- a/PermissionsService.Test/PermissionsService.Test.csproj +++ b/PermissionsService.Test/PermissionsService.Test.csproj @@ -29,7 +29,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/SamplesService.Test/SamplesService.Test.csproj b/SamplesService.Test/SamplesService.Test.csproj index f6d05b3bd..1af8374fd 100644 --- a/SamplesService.Test/SamplesService.Test.csproj +++ b/SamplesService.Test/SamplesService.Test.csproj @@ -52,7 +52,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj index 7559e54fc..f7113c672 100644 --- a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj +++ b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj @@ -20,7 +20,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/UriMatchService.Test/UriMatchingService.Test.csproj b/UriMatchService.Test/UriMatchingService.Test.csproj index 4b8f0203e..b3318edcd 100644 --- a/UriMatchService.Test/UriMatchingService.Test.csproj +++ b/UriMatchService.Test/UriMatchingService.Test.csproj @@ -11,7 +11,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/UtilityService.Test/UtilityService.Test.csproj b/UtilityService.Test/UtilityService.Test.csproj index cbca4d486..14f8dcdee 100644 --- a/UtilityService.Test/UtilityService.Test.csproj +++ b/UtilityService.Test/UtilityService.Test.csproj @@ -7,7 +7,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all From a02a0dd07ce9dd76c9726d9852153ab3de9b3bd5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:43:21 +0300 Subject: [PATCH 09/14] Bump coverlet.collector from 6.0.0 to 6.0.1 (#1959) Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj | 2 +- .../CodeSnippetsReflection.OData.Test.csproj | 2 +- .../CodeSnippetsReflection.OpenAPI.Test.csproj | 2 +- ExceptionMiddleware/ExceptionMiddleware.Test.csproj | 2 +- FileService.Test/FileService.Test.csproj | 2 +- KnownIssuesService.Test/KnownIssuesService.Test.csproj | 2 +- OpenAPIService.Test/OpenAPIService.Test.csproj | 2 +- PermissionsService.Test/PermissionsService.Test.csproj | 2 +- SamplesService.Test/SamplesService.Test.csproj | 2 +- TelemetryService.Test/TelemetrySanitizerService.Test.csproj | 2 +- UriMatchService.Test/UriMatchingService.Test.csproj | 2 +- UtilityService.Test/UtilityService.Test.csproj | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj b/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj index faca17e6e..dc2966dc4 100644 --- a/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj +++ b/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj index f00e6ea70..67fe9d7b1 100644 --- a/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj +++ b/CodeSnippetsReflection.OData.Test/CodeSnippetsReflection.OData.Test.csproj @@ -11,7 +11,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj index 6a55fd50e..b4c9794c4 100644 --- a/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj +++ b/CodeSnippetsReflection.OpenAPI.Test/CodeSnippetsReflection.OpenAPI.Test.csproj @@ -18,7 +18,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj index df2436945..59d2699ea 100644 --- a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj +++ b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj @@ -19,7 +19,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/FileService.Test/FileService.Test.csproj b/FileService.Test/FileService.Test.csproj index d45928a48..0beacb15a 100644 --- a/FileService.Test/FileService.Test.csproj +++ b/FileService.Test/FileService.Test.csproj @@ -18,7 +18,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/KnownIssuesService.Test/KnownIssuesService.Test.csproj b/KnownIssuesService.Test/KnownIssuesService.Test.csproj index 410daf276..9bcf9d229 100644 --- a/KnownIssuesService.Test/KnownIssuesService.Test.csproj +++ b/KnownIssuesService.Test/KnownIssuesService.Test.csproj @@ -29,7 +29,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/OpenAPIService.Test/OpenAPIService.Test.csproj b/OpenAPIService.Test/OpenAPIService.Test.csproj index b959915d6..e78874f94 100644 --- a/OpenAPIService.Test/OpenAPIService.Test.csproj +++ b/OpenAPIService.Test/OpenAPIService.Test.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/PermissionsService.Test/PermissionsService.Test.csproj b/PermissionsService.Test/PermissionsService.Test.csproj index 3fe50360b..00d4a1210 100644 --- a/PermissionsService.Test/PermissionsService.Test.csproj +++ b/PermissionsService.Test/PermissionsService.Test.csproj @@ -25,7 +25,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SamplesService.Test/SamplesService.Test.csproj b/SamplesService.Test/SamplesService.Test.csproj index 1af8374fd..e95ea438a 100644 --- a/SamplesService.Test/SamplesService.Test.csproj +++ b/SamplesService.Test/SamplesService.Test.csproj @@ -48,7 +48,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj index f7113c672..b485b2bee 100644 --- a/TelemetryService.Test/TelemetrySanitizerService.Test.csproj +++ b/TelemetryService.Test/TelemetrySanitizerService.Test.csproj @@ -32,7 +32,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/UriMatchService.Test/UriMatchingService.Test.csproj b/UriMatchService.Test/UriMatchingService.Test.csproj index b3318edcd..5f1ce547b 100644 --- a/UriMatchService.Test/UriMatchingService.Test.csproj +++ b/UriMatchService.Test/UriMatchingService.Test.csproj @@ -7,7 +7,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UtilityService.Test/UtilityService.Test.csproj b/UtilityService.Test/UtilityService.Test.csproj index 14f8dcdee..904d4645c 100644 --- a/UtilityService.Test/UtilityService.Test.csproj +++ b/UtilityService.Test/UtilityService.Test.csproj @@ -17,7 +17,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all From ae480482dc716d4f0af1d1f9012cec9f640b73cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 09:16:00 +0300 Subject: [PATCH 10/14] Bump MSTest.TestFramework from 3.2.1 to 3.2.2 (#1962) Bumps [MSTest.TestFramework](https://github.com/microsoft/testfx) from 3.2.1 to 3.2.2. - [Release notes](https://github.com/microsoft/testfx/releases) - [Changelog](https://github.com/microsoft/testfx/blob/main/docs/Changelog.md) - [Commits](https://github.com/microsoft/testfx/compare/v3.2.1...v3.2.2) --- updated-dependencies: - dependency-name: MSTest.TestFramework dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ExceptionMiddleware/ExceptionMiddleware.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj index 59d2699ea..64e8c6f3b 100644 --- a/ExceptionMiddleware/ExceptionMiddleware.Test.csproj +++ b/ExceptionMiddleware/ExceptionMiddleware.Test.csproj @@ -13,7 +13,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive From 52d66a34956a30ae2b1f31dea64a8401c4753d7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 25 Feb 2024 03:15:49 +0300 Subject: [PATCH 11/14] Bump System.Text.Json from 8.0.1 to 8.0.2 (#1963) Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 8.0.1 to 8.0.2. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v8.0.1...v8.0.2) --- updated-dependencies: - dependency-name: System.Text.Json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../CodeSnippetsReflection.OpenAPI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodeSnippetsReflection.OpenAPI/CodeSnippetsReflection.OpenAPI.csproj b/CodeSnippetsReflection.OpenAPI/CodeSnippetsReflection.OpenAPI.csproj index 76661e7f5..3e0181ee6 100644 --- a/CodeSnippetsReflection.OpenAPI/CodeSnippetsReflection.OpenAPI.csproj +++ b/CodeSnippetsReflection.OpenAPI/CodeSnippetsReflection.OpenAPI.csproj @@ -8,7 +8,7 @@ - + From 511cadddb13979c753c889611bd0b602493fdf94 Mon Sep 17 00:00:00 2001 From: Faith Kangai Date: Mon, 26 Feb 2024 13:16:09 +0300 Subject: [PATCH 12/14] Replace Obsolete GetAsync With New Replacers (#1953) * ReplaceObsoleteGetAsyncWithNewReplacers * Fix syntax errors and improve sonar cloud intentionality score * Replace enumerable.count with length * Add check for content-type header in get requests * Refactor check into schema extensions class --- .../CSharpGeneratorTests.cs | 56 ++++++---- .../KiotaOpenApiSchemaExtensions.cs | 9 +- .../LanguageGenerators/CSharpGenerator.cs | 49 ++++---- .../ModelGraph/SnippetCodeGraph.cs | 105 ++++++++++++------ .../SnippetModel.cs | 15 ++- .../StringExtensions.cs | 37 ++++-- 6 files changed, 174 insertions(+), 97 deletions(-) diff --git a/CodeSnippetsReflection.OpenAPI.Test/CSharpGeneratorTests.cs b/CodeSnippetsReflection.OpenAPI.Test/CSharpGeneratorTests.cs index bfccd42a5..775e42608 100644 --- a/CodeSnippetsReflection.OpenAPI.Test/CSharpGeneratorTests.cs +++ b/CodeSnippetsReflection.OpenAPI.Test/CSharpGeneratorTests.cs @@ -9,7 +9,7 @@ namespace CodeSnippetsReflection.OpenAPI.Test public class CSharpGeneratorTests : OpenApiSnippetGeneratorTestBase { private readonly CSharpGenerator _generator = new(); - + [Fact] public async Task GeneratesTheCorrectFluentApiPath() { using var requestPayload = new HttpRequestMessage(HttpMethod.Get, $"{ServiceRootUrl}/me/messages"); @@ -39,7 +39,7 @@ public async Task GeneratesTheSnippetHeader() { var result = _generator.GenerateCodeSnippet(snippetModel); Assert.DoesNotContain("var graphClient = new GraphServiceClient(requestAdapter)", result); // no initialization statement present Assert.Contains("// Code snippets are only available for the latest version. Current version is", result);// ensure version comment is present - Assert.Contains("// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client", result);// ensure initialization guidance is present + Assert.Contains("// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client", result);// ensure initialization guidance is present } [Fact] public async Task GeneratesTheGetMethodCall() { @@ -255,6 +255,18 @@ public async Task GeneratesSnippetForRequestWithSearchQueryOptionWithANDLogicalC Assert.Contains("requestConfiguration.QueryParameters.Search", result); Assert.Contains("requestConfiguration.QueryParameters.Search = \"\\\"displayName:di\\\" AND \\\"displayName:al\\\"\";", result); } + + [Theory] + [InlineData("/users/some-id/mailFolders/delta","GetAsDeltaGetResponseAsync")] + [InlineData("/appCatalogs/teamsApps?requiresReview=true","await graphClient.AppCatalogs.TeamsApps.PostAsync(", "POST")] + [InlineData("/me/photos/48x48/$value","Content.GetAsync(")] + public async Task ObsoleteGetAsyncReplacedWithGetAsLastNodeNameGetResponseAsync(string inputPath, string expectedSuffix, string method = "") { + using var requestPayload = new HttpRequestMessage(string.IsNullOrEmpty(method) ? HttpMethod.Get : new HttpMethod(method), $"{ServiceRootUrl}{inputPath}"); + var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); + var result = _generator.GenerateCodeSnippet(snippetModel); + Assert.Contains(expectedSuffix, result); + } + [Fact] public async Task HandlesOdataTypeWhenGenerating() { var sampleJson = @" @@ -389,7 +401,7 @@ public async Task GenerateFindMeetingTime() Assert.Contains("IsRequired = false,", result); Assert.Contains("LocationEmailAddress = \"conf32room1368@imgeek.onmicrosoft.com\",", result); } - + [Theory] [InlineData("sendMail")] [InlineData("microsoft.graph.sendMail")] @@ -432,7 +444,7 @@ public async Task FullyQualifiesActionRequestBodyType(string sendMailString) Assert.Contains("using Microsoft.Graph.Users.Item.SendMail", result); Assert.Contains("ToRecipients = new List", result); } - + [Fact] public async Task TypeArgumentsForListArePlacedCorrectly() { @@ -452,7 +464,7 @@ public async Task TypeArgumentsForListArePlacedCorrectly() Assert.Contains("new List", result); } - + [Fact] public async Task ModelsInNestedNamespacesAreDisambiguated() { @@ -473,7 +485,7 @@ public async Task ModelsInNestedNamespacesAreDisambiguated() Assert.Contains("Type = IdentityType.ExternalGroup", result); Assert.Contains("using Microsoft.Graph.Models.ExternalConnectors;", result); } - + [Fact] public async Task ReplacesReservedTypeNames() { @@ -484,7 +496,7 @@ public async Task ReplacesReservedTypeNames() // Assert `Directory` is replaced with `DirectoryObject` Assert.Contains("await graphClient.Directory.AdministrativeUnits[\"{administrativeUnit-id}\"].ScopedRoleMembers.GetAsync()", result); } - + [Fact] public async Task CorrectlyGeneratesEnumMember() { @@ -518,7 +530,7 @@ public async Task CorrectlyGeneratesEnumMember() Assert.Contains("Type = RecurrencePatternType.Weekly,", result); Assert.Contains("Type = RecurrenceRangeType.NoEnd,", result); } - + [Fact] public async Task CorrectlyGeneratesMultipleFlagsEnumMembers() { @@ -536,7 +548,7 @@ public async Task CorrectlyGeneratesMultipleFlagsEnumMembers() Assert.Contains("Status = RecordingStatus.NotRecording | RecordingStatus.Recording | RecordingStatus.Failed", result); } - + [Fact] public async Task CorrectlyOptionalRequestBodyParameter() { @@ -546,7 +558,7 @@ public async Task CorrectlyOptionalRequestBodyParameter() Assert.Contains("await graphClient.Teams[\"{team-id}\"].Archive.PostAsync(null);", result); } - + [Fact] public async Task CorrectlyEvaluatesDatePropertyTypeRequestBodyParameter() { @@ -570,7 +582,7 @@ public async Task CorrectlyEvaluatesDatePropertyTypeRequestBodyParameter() Assert.Contains("StartDate = new Date(DateTime.Parse(\"2017-09-04\")),", result); Assert.Contains("EndDate = new Date(DateTime.Parse(\"2017-12-31\")),", result); } - + [Fact] public async Task CorrectlyEvaluatesOdataActionRequestBodyParameter() { @@ -654,10 +666,10 @@ public async Task CorrectlyHandlesOdataFunction() var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); var result = _generator.GenerateCodeSnippet(snippetModel); - Assert.Contains("await graphClient.Users.Delta.GetAsync", result); + Assert.Contains("await graphClient.Users.Delta.GetAsDeltaGetResponseAsync", result); Assert.Contains("requestConfiguration.QueryParameters.Select = new string []{ \"displayName\",\"jobTitle\",\"mobilePhone\" };", result); } - + [Fact] public async Task CorrectlyHandlesDateTimeOffsetInUrl() { @@ -665,7 +677,7 @@ public async Task CorrectlyHandlesDateTimeOffsetInUrl() var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); var result = _generator.GenerateCodeSnippet(snippetModel); - Assert.Contains("await graphClient.Reports.GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTime(DateTimeOffset.Parse(\"{endDateTime}\"),DateTimeOffset.Parse(\"{startDateTime}\"),\"{userId}\").GetAsync()", result); + Assert.Contains("await graphClient.Reports.GetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTime(DateTimeOffset.Parse(\"{endDateTime}\"),DateTimeOffset.Parse(\"{startDateTime}\"),\"{userId}\").GetAsGetUserArchivedPrintJobsWithUserIdWithStartDateTimeWithEndDateTimeGetResponseAsync()", result); } [Fact] @@ -693,7 +705,7 @@ public async Task CorrectlyHandlesDateInUrl2() var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); var result = _generator.GenerateCodeSnippet(snippetModel); - Assert.Contains("await graphClient.Communications.CallRecords.MicrosoftGraphCallRecordsGetPstnCallsWithFromDateTimeWithToDateTime(DateTimeOffset.Parse(\"{fromDateTime}\"),DateTimeOffset.Parse(\"{toDateTime}\")).GetAsync();", result); + Assert.Contains("await graphClient.Communications.CallRecords.MicrosoftGraphCallRecordsGetPstnCallsWithFromDateTimeWithToDateTime(DateTimeOffset.Parse(\"{fromDateTime}\"),DateTimeOffset.Parse(\"{toDateTime}\")).GetAsGetPstnCallsWithFromDateTimeWithToDateTimeGetResponseAsync()", result); } [Fact] public async Task CorrectlyHandlesEnumInUrl() @@ -702,7 +714,7 @@ public async Task CorrectlyHandlesEnumInUrl() var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); var result = _generator.GenerateCodeSnippet(snippetModel); - Assert.Contains("await graphClient.IdentityGovernance.AppConsent.AppConsentRequests.FilterByCurrentUserWithOn(\"reviewer\").GetAsync", result); + Assert.Contains("await graphClient.IdentityGovernance.AppConsent.AppConsentRequests.FilterByCurrentUserWithOn(\"reviewer\").GetAsFilterByCurrentUserWithOnGetResponseAsync", result); } [Fact] public async Task GeneratesObjectsInArray() { @@ -851,7 +863,7 @@ public async Task GeneratesPropertiesWithSpecialCharacters() { Assert.Contains("MinimumSupportedOperatingSystem = new IosMinimumOperatingSystem", result); Assert.Contains("V80 = true,", result);//Assert that the property was pascal cased } - + [Fact] public async Task GeneratesCorrectTypeInCollectionInitializer() { var sampleJson = @"{ @@ -901,7 +913,7 @@ public async Task GeneratesCorrectTypeInCollectionInitializer() { Assert.Contains("new List", result);//Assert the type is escaped in the collection initializzer. Assert.Contains("using Microsoft.Graph.Models.IdentityGovernance", result);//Assert the type is escaped in the collection initializzer. } - + [Fact] public async Task CorrectlyHandlesTypeFromInUrl() { @@ -921,7 +933,7 @@ public async Task MatchesPathWithPathParameter() Assert.Contains("var result = await graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].Workbook.Worksheets[\"{workbookWorksheet-id}\"].RangeWithAddress(\"{address}\").GetAsync()", result); } - + [Fact] public async Task MatchesPathAlternateKeys() { @@ -932,7 +944,7 @@ public async Task MatchesPathAlternateKeys() Assert.Contains("await graphClient.ApplicationsWithAppId(\"{appId}\").GetAsync(", result); } [Theory] - [InlineData("/me/drive/root/delta","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].Delta.GetAsync()")] + [InlineData("/me/drive/root/delta","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].Delta.GetAsDeltaGetResponseAsync()")] [InlineData("/groups/{group-id}/drive/items/{item-id}/children","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].Children.GetAsync()")] [InlineData("/me/drive","graphClient.Me.Drive.GetAsync()")] [InlineData("/sites/{site-id}/drive/items/{item-id}/children","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].Children.GetAsync()")] @@ -941,9 +953,9 @@ public async Task MatchesPathAlternateKeys() [InlineData("/me/drive/items/{item-id}/children","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].Children.GetAsync()")] [InlineData("/drive/bundles","graphClient.Drives[\"{drive-id}\"].Bundles.GetAsync()")] [InlineData("/me/drive/special/documents","graphClient.Drives[\"{drive-id}\"].Special[\"{driveItem-id}\"].GetAsync()")] - [InlineData("/me/drive/root/search(q='Contoso%20Project')","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].SearchWithQ(\"{q}\").GetAsync()")] + [InlineData("/me/drive/root/search(q='Contoso%20Project')","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].SearchWithQ(\"{q}\").GetAsSearchWithQGetResponseAsync()")] [InlineData("/me/drive/items/{id}/workbook/application/calculate","graphClient.Drives[\"{drive-id}\"].Items[\"{driveItem-id}\"].Workbook.Application.Calculate", "POST")] - public async Task GeneratesSnippetWithRemappedDriveCall(string inputPath, string expected, string method = "") + public async Task GeneratesSnippetWithRemappedDriveCall(string inputPath, string expected, string method = "") { using var requestPayload = new HttpRequestMessage(string.IsNullOrEmpty(method) ? HttpMethod.Get : new HttpMethod(method), $"{ServiceRootUrl}{inputPath}"); var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, await GetV1SnippetMetadata()); diff --git a/CodeSnippetsReflection.OpenAPI/KiotaOpenApiSchemaExtensions.cs b/CodeSnippetsReflection.OpenAPI/KiotaOpenApiSchemaExtensions.cs index 476b73f3c..4fb5476d1 100644 --- a/CodeSnippetsReflection.OpenAPI/KiotaOpenApiSchemaExtensions.cs +++ b/CodeSnippetsReflection.OpenAPI/KiotaOpenApiSchemaExtensions.cs @@ -3,9 +3,12 @@ // ------------------------------------------------------------------------------------------------------------------------------------------------------ using System; +using System.Text; using System.Collections.Generic; using System.Linq; using Microsoft.OpenApi.Models; +using CodeSnippetsReflection.StringExtensions; +using CodeSnippetsReflection.OpenAPI.ModelGraph; // THIS CLASS IS COPIED FROM KIOTA TO GET THE SAME NAMING CONVENTIONS, WE SHOULD FIND A WAY TO MUTUALIZE THE CODE namespace CodeSnippetsReflection.OpenAPI { @@ -35,7 +38,7 @@ private static IEnumerable FlattenIfRequired(this IList s var resultSet = schemas; if(schemas.Count == 1 && string.IsNullOrEmpty(schemas.First().Title)) resultSet = schemas.FlattenEmptyEntries(subsequentGetter, 1); - + return resultSet.Select(x => x.Title).Where(x => !string.IsNullOrEmpty(x)); } @@ -72,7 +75,7 @@ public static bool IsOneOf(this OpenApiSchema schema) } public static IEnumerable GetSchemaReferenceIds(this OpenApiSchema schema, HashSet visitedSchemas = null) { - visitedSchemas ??= new(); + visitedSchemas ??= new(); if(schema != null && !visitedSchemas.Contains(schema)) { visitedSchemas.Add(schema); var result = new List(); @@ -92,7 +95,7 @@ public static IEnumerable GetSchemaReferenceIds(this OpenApiSchema schem if(subSchemaReferences.Any()) result.AddRange(subSchemaReferences); return result.Distinct(); - } else + } else return Enumerable.Empty(); } internal static IList FlattenEmptyEntries(this IList schemas, Func> subsequentGetter, int? maxDepth = default) { diff --git a/CodeSnippetsReflection.OpenAPI/LanguageGenerators/CSharpGenerator.cs b/CodeSnippetsReflection.OpenAPI/LanguageGenerators/CSharpGenerator.cs index 126012da9..fc1c24cb6 100644 --- a/CodeSnippetsReflection.OpenAPI/LanguageGenerators/CSharpGenerator.cs +++ b/CodeSnippetsReflection.OpenAPI/LanguageGenerators/CSharpGenerator.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using CodeSnippetsReflection.OpenAPI; using CodeSnippetsReflection.OpenAPI.ModelGraph; using CodeSnippetsReflection.StringExtensions; using Microsoft.OpenApi.Services; @@ -18,17 +19,17 @@ public class CSharpGenerator : ILanguageGenerator GetSystemTypeNames() { return typeof(string).Assembly.GetTypes() - .Where(static type => type.Namespace == "System" + .Where(static type => type.Namespace == "System" && type.IsPublic // get public(we can only import public type in external code) && !type.IsGenericType)// non generic types(generic type names have special character like `) .Select(static type => type.Name) .ToHashSet(); } - + private static readonly HashSet CustomDefinedValues = new(StringComparer.OrdinalIgnoreCase) { "file", //system.io static types @@ -39,13 +40,13 @@ private static HashSet GetSystemTypeNames() "thread", "integer" }; - + private static readonly Lazy> ReservedNames = new(static () => { CustomDefinedValues.UnionWith(GetSystemTypeNames()); return CustomDefinedValues; }); - + public string GenerateCodeSnippet(SnippetModel snippetModel) { var usedNamespaces = new HashSet();// list of used namespaces in generation @@ -55,11 +56,11 @@ public string GenerateCodeSnippet(SnippetModel snippetModel) var requestPayloadAndVariableNameBuilder = WriteRequestPayloadAndVariableNameBuilder(codeGraph, indentManager, usedNamespaces); var requestExecutionPathBuilder = WriteRequestExecutionPathBuilder(codeGraph, indentManager,usedNamespaces); var dependenciesBuilder = WriteDependenciesBuilder(usedNamespaces.Where( static ns => !string.IsNullOrEmpty(ns)).ToArray()); - + return codeSnippetBuilder.Append(dependenciesBuilder) // dependencies first .Append(requestPayloadAndVariableNameBuilder) // request body .AppendLine(InitializationInfoString) - .Append(requestExecutionPathBuilder)// request executor + .Append(requestExecutionPathBuilder)// request executor .ToString(); } @@ -83,20 +84,20 @@ private static StringBuilder WriteRequestExecutionPathBuilder(SnippetCodeGraph c { var payloadSb = new StringBuilder(); var responseAssignment = codeGraph.HasReturnedBody() ? "var result = " : string.Empty; - var methodName = codeGraph.HttpMethod.Method.ToLower().ToFirstCharacterUpperCase() + "Async"; var requestPayloadParameterName = codeGraph.HasBody() ? RequestBodyVarName : default; if (string.IsNullOrEmpty(requestPayloadParameterName) && ((codeGraph.RequestSchema?.Properties?.Any() ?? false) || (codeGraph.RequestSchema?.AllOf?.Any(schema => schema.Properties.Any()) ?? false))) requestPayloadParameterName = "null";// pass a null parameter if we have a request schema expected but there is not body provided string pathSegment = $"{ClientVarName}.{GetFluentApiPath(codeGraph.Nodes, codeGraph,usedNamespaces)}"; - if(codeGraph.Parameters.Any( static property => property.Name.Equals("skiptoken",StringComparison.OrdinalIgnoreCase) || + var methodName = codeGraph.GetInlinedSchemaFunctionCallPrefix() + "Async"; + if(codeGraph.Parameters.Any( static property => property.Name.Equals("skiptoken",StringComparison.OrdinalIgnoreCase) || property.Name.Equals("deltatoken",StringComparison.OrdinalIgnoreCase))) {// its a delta query and needs the opaque url passed over. payloadSb.AppendLine("// Note: The URI string parameter used with WithUrl() can be retrieved using the OdataNextLink or OdataDeltaLink property from a response object"); pathSegment = $"{pathSegment}.WithUrl(\"{codeGraph.RequestUrl}\")"; codeGraph.Parameters = new List();// clear the query parameters as these will be provided in the url directly. } - + var requestConfigurationPayload = GetRequestConfiguration(codeGraph, indentManager); var parametersList = GetActionParametersList(requestPayloadParameterName , requestConfigurationPayload); payloadSb.AppendLine($"{responseAssignment}await {pathSegment}.{methodName}({parametersList});"); @@ -125,7 +126,7 @@ private static string GetActionParametersList(params string[] parameters) private static void WriteRequestHeaders(SnippetCodeGraph snippetCodeGraph, IndentManager indentManager, StringBuilder stringBuilder) { - if (!snippetCodeGraph.HasHeaders()) + if (!snippetCodeGraph.HasHeaders()) return ; indentManager.Indent(); @@ -142,7 +143,7 @@ private static void WriteRequestQueryParameters(SnippetCodeGraph snippetCodeGrap return; indentManager.Indent(); - foreach(var queryParam in snippetCodeGraph.Parameters) + foreach(var queryParam in snippetCodeGraph.Parameters) { stringBuilder.AppendLine($"{indentManager.GetIndent()}{RequestConfigurationVarName}.{RequestParametersPropertyName}.{queryParam.Name.ToFirstCharacterUpperCase()} = {GetQueryParameterValue(queryParam)};"); } @@ -160,7 +161,7 @@ private static string GetQueryParameterValue(CodeProperty queryParam) case PropertyType.Double: case PropertyType.Float32: case PropertyType.Float64: - return queryParam.Value; // Numbers stay as is + return queryParam.Value; // Numbers stay as is case PropertyType.Array: return $"new string []{{ {string.Join(",", queryParam.Children.Select(static x => $"\"{x.Value}\"" ).ToList())} }}"; // deconstruct arrays default: @@ -173,7 +174,7 @@ private static StringBuilder WriteRequestPayloadAndVariableNameBuilder(SnippetCo if (!snippetCodeGraph.HasBody()) return new StringBuilder();// No body - if(indentManager == null) + if(indentManager == null) throw new ArgumentNullException(nameof(indentManager)); var snippetBuilder = new StringBuilder(); @@ -196,7 +197,7 @@ private static StringBuilder WriteRequestPayloadAndVariableNameBuilder(SnippetCo return snippetBuilder.AppendLine(); } - private static void WriteObjectFromCodeProperty(CodeProperty parentProperty, CodeProperty codeProperty,StringBuilder snippetBuilder, IndentManager indentManager, string apiVersion, HashSet usedNamespaces) + private static void WriteObjectFromCodeProperty(CodeProperty parentProperty, CodeProperty codeProperty,StringBuilder snippetBuilder, IndentManager indentManager, string apiVersion, HashSet usedNamespaces) { indentManager.Indent(); var isParentArray = parentProperty.PropertyType == PropertyType.Array; @@ -314,9 +315,9 @@ private static string GetTypeString(CodeProperty codeProperty) var collectionTypeString = codeProperty.Children.Any() && codeProperty.Children[0].PropertyType != PropertyType.Object ? GetTypeString(codeProperty.Children[0]) : ReplaceIfReservedTypeName(typeString); - if(string.IsNullOrEmpty(collectionTypeString)) + if(string.IsNullOrEmpty(collectionTypeString)) collectionTypeString = "object"; - else if(typeString.Equals(StringTypeName,StringComparison.OrdinalIgnoreCase)) + else if(typeString.Equals(StringTypeName,StringComparison.OrdinalIgnoreCase)) collectionTypeString = StringTypeName; // use the conventional casing if need be return $"List<{collectionTypeString}>"; case PropertyType.Object: @@ -345,7 +346,7 @@ private static string GetNamespaceName(string namespaceName, string apiVersion) //strip the default namespace name from the original as the models are typically already in Microsoft.Graph namespace namespaceName = namespaceName.Replace(DefaultNamespace,string.Empty, StringComparison.OrdinalIgnoreCase); - + var normalizedNameSpaceName = namespaceName.TrimStart('.').Split('.',StringSplitOptions.RemoveEmptyEntries) .Select(static x => ReplaceIfReservedTypeName(x, "Namespace").ToFirstCharacterUpperCase()) .Aggregate(static (z, y) => z + '.' + y); @@ -355,20 +356,20 @@ private static string GetNamespaceName(string namespaceName, string apiVersion) private static string GetDefaultNamespaceName(string apiVersion) => apiVersion.Equals("beta", StringComparison.OrdinalIgnoreCase) ? $"{DefaultNamespace}.Beta" : DefaultNamespace; - + private static string ReplaceIfReservedTypeName(string originalString, string suffix = "Object") => ReservedNames.Value.Contains(originalString) ? $"{originalString}{suffix}" : originalString; private static string GetFluentApiPath(IEnumerable nodes, SnippetCodeGraph snippetCodeGraph, HashSet usedNamespaces) { - if(!(nodes?.Any() ?? false)) + if(!(nodes?.Any() ?? false)) return string.Empty; return nodes.Select(x => { if (x.Segment.IsCollectionIndex()) { //Handle cases where the indexer is an integer type - var isIntParam = false; + var isIntParam = false; if (x.PathItems.TryGetValue("default", out var pathItem)) { isIntParam = pathItem.Parameters.Any(parameter => x.Segment.Contains(parameter.Name) && parameter.Schema.Type.Equals("integer", StringComparison.OrdinalIgnoreCase)); @@ -382,9 +383,7 @@ private static string GetFluentApiPath(IEnumerable nodes, Sn functionName = functionName.Split(".",StringSplitOptions.RemoveEmptyEntries) .Select(static s => s.ToFirstCharacterUpperCase()) .Aggregate(static (a, b) => $"{a}{b}"); - var parameters = snippetCodeGraph.PathParameters - .Select(static s => $"With{s.Name.ToFirstCharacterUpperCase()}") - .Aggregate(static (a, b) => $"{a}{b}"); + var parameters = snippetCodeGraph.AggregatePathParametersIntoString(); // use the existing WriteObjectFromCodeProperty functionality to write the parameters as if they were a comma seperated array so as to automatically infer type handling from the codeDom :) var parametersBuilder = new StringBuilder(); @@ -394,7 +393,7 @@ private static string GetFluentApiPath(IEnumerable nodes, Sn WriteObjectFromCodeProperty(new CodeProperty{PropertyType = PropertyType.Array}, codeProperty, parameter, new IndentManager(), snippetCodeGraph.ApiVersion, usedNamespaces); parametersBuilder.Append(parameter.ToString().Trim());//Do this to trim the surrounding whitespace generated } - + return functionName.ToFirstCharacterUpperCase() + parameters + $"({parametersBuilder.ToString().TrimEnd(',')})" ; diff --git a/CodeSnippetsReflection.OpenAPI/ModelGraph/SnippetCodeGraph.cs b/CodeSnippetsReflection.OpenAPI/ModelGraph/SnippetCodeGraph.cs index 22e7d3aff..b4244219c 100644 --- a/CodeSnippetsReflection.OpenAPI/ModelGraph/SnippetCodeGraph.cs +++ b/CodeSnippetsReflection.OpenAPI/ModelGraph/SnippetCodeGraph.cs @@ -4,6 +4,7 @@ using System.Collections.Specialized; using System.Linq; using System.Net.Http; +using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using System.Web; @@ -37,9 +38,9 @@ public record SnippetCodeGraph {"time", PropertyType.TimeOnly}, {"date", PropertyType.DateOnly} }; - + private static readonly char NamespaceNameSeparator = '.'; - + public SnippetCodeGraph(HttpRequestMessage requestPayload, string serviceRootUrl, OpenApiSnippetMetadata openApiSnippetMetadata) : this(new SnippetModel(requestPayload, serviceRootUrl, openApiSnippetMetadata)) {} public SnippetCodeGraph(SnippetModel snippetModel) @@ -61,17 +62,17 @@ public OpenApiSchema ResponseSchema { get; set; } - + public OpenApiSchema RequestSchema { get; set; } - + public string RequestUrl { get; set; } - + public string ApiVersion { get; set; @@ -95,7 +96,7 @@ public IEnumerable Parameters { get; set; } - + public IEnumerable PathParameters { get; set; @@ -111,7 +112,7 @@ public IEnumerable Nodes get; set; } - + public Boolean HasHeaders() { return Headers.Any(); @@ -168,7 +169,7 @@ private static List parseParameters(SnippetModel snippetModel) .Where(operation => operation.Key.ToString().Equals(snippetModel.Method.ToString(), StringComparison.OrdinalIgnoreCase)) // get the operations that match the method .SelectMany(static operation => operation.Value.Parameters) .Where(static parameter => parameter.In == ParameterLocation.Query); // find the parameters in the path - + var ArrayParameters = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase,"select", "expand", "orderby"); var NumberParameters = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase,"skip", "top"); @@ -191,14 +192,14 @@ private static List parseParameters(SnippetModel snippetModel) schema = "integer"; else if(ArrayParameters.Contains(name)) schema = "array"; - + // use values from the schema if match is found if (queryParam != null) { schema = queryParam.Schema.Type.ToLowerInvariant(); name = NormalizeQueryParameterName(queryParam.Name).Trim(); } - + switch (schema) { case "string": @@ -224,7 +225,7 @@ private static List parseParameters(SnippetModel snippetModel) } return parameters; } - + private static List parsePathParameters(SnippetModel snippetModel) { @@ -235,11 +236,11 @@ private static List parsePathParameters(SnippetModel snippetModel) .SelectMany(static operation => operation.Value.Parameters) .Where(static parameter => parameter.In == ParameterLocation.Path)// find the parameters in the path based on operation .Union(snippetModel.EndPathNode.PathItems.Values.SelectMany(static pathItem => pathItem.Parameters) - .Where(parameter => parameter.In == ParameterLocation.Path && + .Where(parameter => parameter.In == ParameterLocation.Path && snippetModel.EndPathNode.Segment.IsFunctionWithParameters() && // don't include indexers snippetModel.EndPathNode.Segment.Contains(parameter.Name,StringComparison.OrdinalIgnoreCase))// alternate keys will show up in the path item and not the operation ); - + var parameters = new List(); foreach (var parameter in pathParameters) { @@ -307,19 +308,19 @@ private static string ComputeRequestBody(SnippetModel snippetModel) var nodes = snippetModel.PathNodes; if (!(nodes?.Any() ?? false)) return string.Empty; - + var nodeName = nodes.Where(x => !x.Segment.IsCollectionIndex()) .Select(x => { if (x.Segment.IsFunction()) - return x.Segment.Split('.').Last(); + return x.Segment.Split('.')[^1]; else return x.Segment; }) .Last() .ToFirstCharacterUpperCase(); - var singularNodeName = nodeName[nodeName.Length - 1] == 's' ? nodeName.Substring(0, nodeName.Length - 1) : nodeName; + var singularNodeName = nodeName[^1] == 's' ? nodeName[..^1] : nodeName; if (nodes.Last()?.Segment?.IsCollectionIndex() == true) return singularNodeName; @@ -350,7 +351,7 @@ private static CodeProperty parseJsonObjectValue(string rootPropertyName, JsonEl if (!string.IsNullOrEmpty(discriminatorValue) && snippetModelSchemas.TryGetValue(discriminatorValue, out OpenApiSchema specifiedSchema)) { // use the schema explictly stated as the payload may be a derived type and the metadata defines the base type which does not define all properties. - schema = specifiedSchema; + schema = specifiedSchema; } } @@ -369,9 +370,9 @@ private static CodeProperty parseJsonObjectValue(string rootPropertyName, JsonEl foreach (var property in propertiesWithoutSchema) { OpenApiSchema openApiSchema = null; - if (property.Value.ValueKind == JsonValueKind.Object && + if (property.Value.ValueKind == JsonValueKind.Object && property.Value.TryGetProperty("@odata.type", out var discriminatorValue) && - snippetModelSchemas.TryGetValue(discriminatorValue.GetString()?.TrimStart('#') ?? string.Empty, out OpenApiSchema specifiedSchema)) + snippetModelSchemas.TryGetValue(discriminatorValue.GetString()?.TrimStart('#') ?? string.Empty, out OpenApiSchema specifiedSchema)) { openApiSchema = specifiedSchema; //property object may have a discriminator value that can be used to determine the schema for additionalData items. } @@ -383,10 +384,10 @@ private static CodeProperty parseJsonObjectValue(string rootPropertyName, JsonEl return new CodeProperty { - Name = rootPropertyName, - PropertyType = PropertyType.Object, - Children = children, - TypeDefinition = schema.GetSchemaTitle()?.ToFirstCharacterUpperCase() ?? GetComposedSchema(schema).GetSchemaTitle()?.ToFirstCharacterUpperCase() ?? rootPropertyName, + Name = rootPropertyName, + PropertyType = PropertyType.Object, + Children = children, + TypeDefinition = schema.GetSchemaTitle()?.ToFirstCharacterUpperCase() ?? GetComposedSchema(schema).GetSchemaTitle()?.ToFirstCharacterUpperCase() ?? rootPropertyName, NamespaceName = GetNamespaceFromSchema(schema) ?? currentNode.GetNodeNamespaceFromPath(string.Empty) }; } @@ -395,7 +396,7 @@ private static OpenApiSchema GetComposedSchema(OpenApiSchema schema) { if (schema == null) return null; - + var typesCount = schema.AnyOf?.Count ?? schema.OneOf?.Count ?? 0; if ((typesCount == 1 && schema.Nullable && schema.IsAnyOf()) || // nullable on the root schema outside of anyOf @@ -426,11 +427,11 @@ private static String escapeSpecialCharacters(string value) { return value?.EscapeQuotes()?.Replace("\n", "\\n")?.Replace("\r", "\\r"); } - + private static string GetModelsNamespaceNameFromReferenceId(string referenceId) { - if (string.IsNullOrEmpty(referenceId)) + if (string.IsNullOrEmpty(referenceId)) return referenceId; - + referenceId = referenceId.Trim(NamespaceNameSeparator); var lastDotIndex = referenceId.LastIndexOf(NamespaceNameSeparator); var namespaceSuffix = lastDotIndex != -1 ? $".{referenceId[..lastDotIndex]}" : string.Empty; @@ -451,7 +452,7 @@ private static CodeProperty evaluateStringProperty(string propertyName, string v bool isFlagsEnum = enumSchema.Extensions.TryGetValue(OpenApiEnumFlagsExtension.Name, out var rawExtension) && rawExtension is OpenApiEnumFlagsExtension { IsFlags: true }; - // Pass the list of options in the enum as children so that the language generators may use them for validation if need be, + // Pass the list of options in the enum as children so that the language generators may use them for validation if need be, var enumValueOptions = enumSchema?.Enum.Where(option => option is OpenApiString) .Select(option => new CodeProperty{Name = ((OpenApiString)option).Value,Value = ((OpenApiString)option).Value,PropertyType = PropertyType.String}) .ToList() ?? new List(); @@ -462,19 +463,19 @@ private static CodeProperty evaluateStringProperty(string propertyName, string v private static CodeProperty evaluateNumericProperty(string propertyName, JsonElement value, OpenApiSchema propSchema) { - if(propSchema == null) + if(propSchema == null) return new CodeProperty { Name = propertyName, Value = $"{value}", PropertyType = PropertyType.Int32, Children = new List() }; var schemas = (propSchema.AnyOf ?? Enumerable.Empty()) .Union(propSchema.AllOf ?? Enumerable.Empty()) .Union(propSchema.OneOf ?? Enumerable.Empty()) .ToList(); - + schemas.Add(propSchema); var types = schemas.Select(item => item.Type).Where(static x => !string.IsNullOrEmpty(x)).ToList(); var formats = schemas.Select(item => item.Format).Where(static x => !string.IsNullOrEmpty(x)).ToList(); - + var (propertyType, propertyValue) = types switch { _ when types.Contains("integer") && formats.Contains("int32") => (PropertyType.Int32 , value.GetInt32().ToString()), @@ -516,12 +517,12 @@ private static CodeProperty parseProperty(string propertyName, JsonElement value private static CodeProperty parseJsonArrayValue(string propertyName, JsonElement value, OpenApiSchema schema, IDictionary snippetModelSchemas) { var alternativeType = schema?.Items?.AnyOf?.FirstOrDefault()?.AllOf?.LastOrDefault()?.Title; - // uuid schemas + // uuid schemas var genericType = schema.GetSchemaTitle().ToFirstCharacterUpperCase() ?? (value.EnumerateArray().Any() ? evaluatePropertyTypeDefinition(value.EnumerateArray().First().ValueKind.ToString(), schema?.Items) : schema?.Items?.Type); - + var typeDefinition = string.IsNullOrEmpty(genericType) || genericType.Equals("Object", StringComparison.OrdinalIgnoreCase) // try to use alternativeType for objects if we couldn't find a useful name. ? alternativeType : genericType; @@ -562,6 +563,44 @@ private static CodeProperty parseAnonymousObjectValues(string propertyName, Json return new CodeProperty { Name = propertyName, Value = null, PropertyType = PropertyType.Object, Children = children }; } + + public string AggregatePathParametersIntoString() + { + if (!PathParameters.Any()) + return string.Empty; + var parameterString = PathParameters.Select( + static s => $"With{s.Name.ToFirstCharacterUpperCase()}" + ).Aggregate( + static (a, b) => $"{a}{b}" + ); + return parameterString; + } + public string GetInlinedSchemaFunctionCallPrefix(){ + var methodNameinPascalCase = HttpMethod.Method.ToLowerInvariant().ToFirstCharacterUpperCase(); + var functionNamePrefix = methodNameinPascalCase; + //if codeGraph.ResponseSchema.Reference is null then recreate functionNamePrefix for inline schema with the following format + //methodNameinPascalCase + "As" + functionName + methodNameinPascalCase + "Response" + bool someNodeInPathHasReference = ResponseSchema?.AnyOf?.Any(static x => x.Reference is not null) ?? false; + if (ResponseSchema?.Reference is null && !someNodeInPathHasReference) + { + var lastItemInPath = Nodes.Last(); + var functionName = new StringBuilder(); + if (lastItemInPath.Segment.Contains('.')) + { + functionName.Append( + lastItemInPath.Segment.GetPartFunctionNameFromNameSpacedSegmentString() + ); + } + else + { + functionName.Append(lastItemInPath.Segment.Split('(')[0].ToFirstCharacterUpperCase()); + } + var parameters = AggregatePathParametersIntoString(); + functionName = functionName.Append(parameters); + functionNamePrefix = methodNameinPascalCase + "As" + functionName + methodNameinPascalCase + "Response"; + } + return functionNamePrefix; + } } } diff --git a/CodeSnippetsReflection.OpenAPI/SnippetModel.cs b/CodeSnippetsReflection.OpenAPI/SnippetModel.cs index 3fdecc0e1..effa456e3 100644 --- a/CodeSnippetsReflection.OpenAPI/SnippetModel.cs +++ b/CodeSnippetsReflection.OpenAPI/SnippetModel.cs @@ -21,7 +21,7 @@ public class SnippetModel : SnippetBaseModel /// node representing the {user-id} segment. /// public OpenApiUrlTreeNode EndPathNode => PathNodes.LastOrDefault(); - + /// /// An OpenAPI node that represents the root segment in the request URL. /// @@ -33,7 +33,7 @@ public class SnippetModel : SnippetBaseModel public OpenApiUrlTreeNode RootPathNode => PathNodes.FirstOrDefault(); public List PathNodes { get; private set; } = new List(); public IDictionary Schemas{ get; private set; } - + public SnippetModel(HttpRequestMessage requestPayload, string serviceRootUrl, OpenApiSnippetMetadata openApiSnippetMetadata) : base(requestPayload, serviceRootUrl) { if (openApiSnippetMetadata == null) throw new ArgumentNullException(nameof(openApiSnippetMetadata)); @@ -61,7 +61,7 @@ public SnippetModel(HttpRequestMessage requestPayload, string serviceRootUrl, Op { new Regex(@"/users/[A-z0-9{}\-]+/drive/",RegexOptions.Compiled, TimeSpan.FromMilliseconds(200)), "/drives/driveId/" }, { new Regex(@"/drive/",RegexOptions.Compiled, TimeSpan.FromMilliseconds(200)), "/drives/driveId/" }, }; - + private static HttpRequestMessage RemapKnownPathsIfNeeded(HttpRequestMessage originalRequest) { var originalUri = originalRequest.RequestUri.OriginalString; @@ -95,6 +95,11 @@ public OpenApiSchema ResponseSchema { var contentType = ContentType ?? defaultContentType; var operationType = GetOperationType(Method); + //GET requests don't have a request body, so ignore the content type if set + if (operationType == OperationType.Get && contentType != defaultContentType) + { + contentType = defaultContentType; + } _responseSchema = GetOperation(operationType) ?.Responses ?.Where(x => !x.Key.Equals("204", StringComparison.OrdinalIgnoreCase) && //204 doesn't have content @@ -175,7 +180,7 @@ private void LoadPathNodes(OpenApiUrlTreeNode node, IEnumerable pathSegm throw new EntryPointNotFoundException($"HTTP Method '{httpMethod}' not found for path.");//path exists but Method does not } - + var pathSegment = HttpUtility.UrlDecode(pathSegments.First()); var childNode = node.Children.FirstOrDefault(x => TrimNamespace(x.Key).Equals(pathSegment)).Value; if (childNode != null) @@ -218,7 +223,7 @@ private void LoadPathNodes(OpenApiUrlTreeNode node, IEnumerable pathSegm return; } } - + throw new EntryPointNotFoundException($"Path segment '{pathSegment}' not found in path"); } private void LoadNextNode(OpenApiUrlTreeNode node, IEnumerable pathSegments, HttpMethod httpMethod) diff --git a/CodeSnippetsReflection.OpenAPI/StringExtensions.cs b/CodeSnippetsReflection.OpenAPI/StringExtensions.cs index 57568834f..f7ef5802f 100644 --- a/CodeSnippetsReflection.OpenAPI/StringExtensions.cs +++ b/CodeSnippetsReflection.OpenAPI/StringExtensions.cs @@ -6,14 +6,14 @@ namespace CodeSnippetsReflection.OpenAPI; -internal static class StringExtensions +internal static class StringExtensions { internal static bool IsCollectionIndex(this string pathSegment) => !string.IsNullOrEmpty(pathSegment) && pathSegment.StartsWith('{') && pathSegment.EndsWith('}'); internal static bool IsFunction(this string pathSegment) => !string.IsNullOrEmpty(pathSegment) && pathSegment.Contains('.'); private static readonly Regex FunctionWithParameterRegex = new(@"\([\w\s\d=':${}<>|\-,""@]+\)", RegexOptions.Compiled, TimeSpan.FromMilliseconds(200)); - internal static bool IsFunctionWithParameters(this string pathSegment) => !string.IsNullOrEmpty(pathSegment) + internal static bool IsFunctionWithParameters(this string pathSegment) => !string.IsNullOrEmpty(pathSegment) && FunctionWithParameterRegex.Match(pathSegment).Success; internal static bool IsFunctionWithParametersMatch(this string pathSegment, string segment) @@ -21,15 +21,15 @@ internal static bool IsFunctionWithParametersMatch(this string pathSegment, stri // verify both have parameters if (!pathSegment.IsFunctionWithParameters() || !segment.IsFunctionWithParameters()) return false; - + // verify both have same prefix/name - if (!pathSegment.Split('(').First().Equals(segment.Split('(').First(), StringComparison.OrdinalIgnoreCase)) + if (!pathSegment.Split('(')[0].Equals(segment.Split('(')[0], StringComparison.OrdinalIgnoreCase)) return false; - var originalParameters = pathSegment.Split('(').Last().TrimEnd(')').Split(',').Select(static s => s.Split('=').First()); - var compareParameters = segment.Split('(').Last().TrimEnd(')').Split(',').Select(static s => s.Split('=').First()); + var originalParameters = pathSegment.Split('(')[^1].TrimEnd(')').Split(',').Select(static s => s.Split('=')[0]); + var compareParameters = segment.Split('(')[^1].TrimEnd(')').Split(',').Select(static s => s.Split('=')[0]); - return compareParameters.All(parameter => originalParameters.Contains(parameter.Split('=').First(), StringComparer.OrdinalIgnoreCase)); + return compareParameters.All(parameter => originalParameters.Contains(parameter.Split('=')[0], StringComparer.OrdinalIgnoreCase)); } internal static string RemoveFunctionBraces(this string pathSegment) => pathSegment.TrimEnd('(',')'); internal static string ReplaceValueIdentifier(this string original) => @@ -83,7 +83,7 @@ internal static Tuple> GetFunctionWi internal static string Append(this string original, string suffix) => string.IsNullOrEmpty(original) ? original : original + suffix; - + private static readonly Regex PropertyCleanupRegex = new(@"[""\s!#$%&'()*+,./:;<=>?@\[\]\\^`{}|~-](?\w)?", RegexOptions.Compiled, TimeSpan.FromSeconds(5)); private const string CleanupGroupName = "followingLetter"; internal static string CleanupSymbolName(this string original) @@ -91,10 +91,29 @@ internal static string CleanupSymbolName(this string original) if (string.IsNullOrEmpty(original)) return original; - var result = PropertyCleanupRegex.Replace(original, static x => x.Groups.Keys.Contains(CleanupGroupName) ? + var result = PropertyCleanupRegex.Replace(original, static x => x.Groups.Keys.Contains(CleanupGroupName) ? x.Groups[CleanupGroupName].Value.ToFirstCharacterUpperCase() : string.Empty); //strip out any invalid characters, and replace any following one by its uppercase version return result; } + + /// + /// Returns the last portion of a namespaced segment string + /// + /// + /// + public static string GetPartFunctionNameFromNameSpacedSegmentString(this string segmentString) + { + var nameOptions = segmentString.Split( + '(' //remove function brackets + )[0].Split( + ".", //split by namespace + StringSplitOptions.RemoveEmptyEntries + ); + var splitOptionsCount = nameOptions.Length; + // retain only last part of the namespace and Capitalize first Character + var functionName = nameOptions[splitOptionsCount-1].ToFirstCharacterUpperCase(); + return functionName; + } } From 0b49d1befd406c093f108006f0043e38b4495b94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:20:02 +0300 Subject: [PATCH 13/14] Bump apidoctor from `5b50d6d` to `843c371` (#1966) Bumps [apidoctor](https://github.com/OneDrive/apidoctor) from `5b50d6d` to `843c371`. - [Commits](https://github.com/OneDrive/apidoctor/compare/5b50d6d155cd357e8b1139dbf39915368fed0a44...843c37175bc36086156f08a1921ec5c00fcff512) --- updated-dependencies: - dependency-name: apidoctor dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- apidoctor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apidoctor b/apidoctor index 5b50d6d15..843c37175 160000 --- a/apidoctor +++ b/apidoctor @@ -1 +1 @@ -Subproject commit 5b50d6d155cd357e8b1139dbf39915368fed0a44 +Subproject commit 843c37175bc36086156f08a1921ec5c00fcff512 From a70f416cb38e3fb2d8825a15b3e0360461b91e34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:21:01 +0300 Subject: [PATCH 14/14] Bump NUnit from 4.0.1 to 4.1.0 (#1965) Bumps [NUnit](https://github.com/nunit/nunit) from 4.0.1 to 4.1.0. - [Release notes](https://github.com/nunit/nunit/releases) - [Changelog](https://github.com/nunit/nunit/blob/master/CHANGES.md) - [Commits](https://github.com/nunit/nunit/compare/v4.0.1...4.1.0) --- updated-dependencies: - dependency-name: NUnit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj b/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj index dc2966dc4..87b3ec214 100644 --- a/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj +++ b/CodeSnippetsPipeline.Test/CodeSnippetsPipeline.Test.csproj @@ -10,7 +10,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive