Skip to content

fix: performance issue with enum parsing during deserialization#670

Merged
baywet merged 9 commits into
mainfrom
perf/enum-deserialization
Mar 19, 2026
Merged

fix: performance issue with enum parsing during deserialization#670
baywet merged 9 commits into
mainfrom
perf/enum-deserialization

Conversation

@baywet

@baywet baywet commented Mar 10, 2026

Copy link
Copy Markdown
Member

partial #632

Signed-off-by: Vincent Biret <vibiret@microsoft.com>
@baywet baywet force-pushed the perf/enum-deserialization branch from cc5d273 to 4ff0582 Compare March 11, 2026 15:39
@baywet baywet marked this pull request as ready for review March 11, 2026 20:39
@baywet baywet requested a review from a team as a code owner March 11, 2026 20:39
@baywet baywet enabled auto-merge (squash) March 11, 2026 20:39
@baywet baywet disabled auto-merge March 11, 2026 20:41
@baywet baywet marked this pull request as draft March 11, 2026 21:37
adrian05-ms
adrian05-ms previously approved these changes Mar 11, 2026
@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Mar 11, 2026
baywet added 2 commits March 13, 2026 12:14
* fix: avoid multiple strings allocations when deserializing flag enums

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* fix: avoid assigning parse nodes for collections of primitive values in json

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* fix: avoid allocation of parse nodes in form deserialization of collections

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* fix: further reduction of node assignments in cases where it's not necessary

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

* fix: cleaner branching in loops to reduce padding

Signed-off-by: Vincent Biret <vibiret@microsoft.com>

---------

Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Comment thread src/abstractions/Helpers/EnumHelpers.cs Dismissed
@baywet

baywet commented Mar 13, 2026

Copy link
Copy Markdown
Member Author

@copilot the code coverage is low for the following methods, add some unit tests

FormParseNode -> GetCollectionOfPrimitiveValues
FormParseNode -> GetScalarValue (DateTimeOffset, Double, Date, Decimal, Guid, Float, Int, Long)

JsonParseNode -> GetScalarValue (Bool, Byte, SByte, ByteArray)
JsonParseNode -> GetCollectionOfEnumValues
JsonParseNode -> GetCollectionOfPrimitiveValues (missing types)

Copilot AI commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

@baywet I've opened a new pull request, #684, to work on those changes. Once the pull request is ready, I'll request review from you.

…lection methods (#684)

* Initial plan

* test: add missing unit tests for FormParseNode and JsonParseNode methods

- Add long? support to FormParseNode.GetCollectionOfPrimitiveValues
- Add private GetLongValue(string) helper to FormParseNode
- Add GetCollectionOfLongPrimitiveValuesFromForm test
- Add GetCollectionOfDateTimeOffsetPrimitiveValuesFromForm test
- Add GetCollectionOfDatePrimitiveValuesFromForm test
- Add JsonParseNode scalar tests: GetBoolValue, GetByteValue, GetSbyteValue, GetByteArrayValue
- Add JsonParseNode GetCollectionOfEnumValues tests
- Add JsonParseNode GetCollectionOfPrimitiveValues tests for bool?, byte?, sbyte?"

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

* test: rename GetByteArrayValue test method to better reflect its intent

Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Comment thread tests/serialization/form/FormParseNodeTests.cs Fixed
Comment thread tests/serialization/form/FormParseNodeTests.cs Fixed
Comment thread tests/serialization/form/FormParseNodeTests.cs Fixed
baywet added 2 commits March 13, 2026 13:18
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
@baywet baywet marked this pull request as ready for review March 13, 2026 17:43
@baywet baywet enabled auto-merge (squash) March 13, 2026 17:44
github-actions Bot pushed a commit to EelcoLos/nx-tinkering that referenced this pull request May 12, 2026
Updated
[Microsoft.Kiota.Abstractions](https://github.com/microsoft/kiota-dotnet)
from 1.22.0 to 1.22.2.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.Kiota.Abstractions's
releases](https://github.com/microsoft/kiota-dotnet/releases)._

## 1.22.2

##
[1.22.2](microsoft/kiota-dotnet@v1.22.1...v1.22.2)
(2026-05-05)


### Bug Fixes

* Set CLSCompliant attribute where possible
([#​705](microsoft/kiota-dotnet#705))
([f6c21e4](microsoft/kiota-dotnet@f6c21e4))

## 1.22.1

##
[1.22.1](microsoft/kiota-dotnet@v1.22.0...v1.22.1)
(2026-03-19)


### Bug Fixes

* adds missing parentheses in pattern matching
([#​671](microsoft/kiota-dotnet#671))
([50d535e](microsoft/kiota-dotnet@50d535e))
* performance issue with enum parsing during deserialization
([#​670](microsoft/kiota-dotnet#670))
([3a09234](microsoft/kiota-dotnet@3a09234))

Commits viewable in [compare
view](microsoft/kiota-dotnet@v1.22.0...v1.22.2).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.Kiota.Abstractions&package-manager=nuget&previous-version=1.22.0&new-version=1.22.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eelco Los <5102501+EelcoLos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants