[repo-assist] perf: avoid allOf double-isEmpty + Array.IndexOf in CallAsync; add V3 schema tests (+5 tests, 438→443)#445
Merged
sergey-tihon merged 3 commits intoMay 21, 2026
Conversation
… schema tests (+5 tests, 438→443) - DefinitionCompiler: cache Seq.isEmpty allOf result to avoid iterating the sequence twice when building schemaObjProperties and schemaObjRequired - ProvidedApiClientBase.CallAsync: replace Array.tryFindIndex((=) codeStr) with Array.IndexOf to avoid allocating a partial-application closure per error response - Schema.V3SchemaCompilationTests: add 5 new tests covering required vs optional property types, string enum compilation, and schema description as XmlDoc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR targets small performance improvements in runtime error handling and design-time schema compilation, and expands OpenAPI v3 schema compilation test coverage to validate required/optional property typing, string-enum generation, and XmlDoc emission.
Changes:
- Cache
Seq.isEmpty allOfinDefinitionCompiler.compileBySchemato avoid double enumeration. - Replace
Array.tryFindIndex ((=) codeStr)withSystem.Array.IndexOfinProvidedApiClientBase.CallAsyncto avoid per-call closure allocation on error responses. - Add 5 OpenAPI v3 schema compilation tests covering required vs optional property typing, string enum generation, and schema description → XmlDoc.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/SwaggerProvider.Tests/Schema.V3SchemaCompilationTests.fs | Adds 5 new unit tests for v3 schema compilation behavior (required/optional properties, string enums, XmlDoc). |
| src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs | Optimizes error-code lookup in CallAsync using System.Array.IndexOf. |
| src/SwaggerProvider.DesignTime/DefinitionCompiler.fs | Avoids repeated Seq.isEmpty allOf checks by caching the result during object type compilation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
3 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Three improvements across Tasks 8 (Performance) and 10 (Take Repository Forward).
Performance: cache
Seq.isEmpty allOfin DefinitionCompiler (Task 8)In
compileBySchema, theallOfsequence was evaluated withSeq.isEmptytwice — once forschemaObjPropertiesand once forschemaObjRequired. Each call iterates up to the first element. The result is now cached inallOfEmptyand reused:Performance:
Array.IndexOfinCallAsync(Task 8)ProvidedApiClientBase.CallAsyncusedArray.tryFindIndex((=) codeStr), which allocates a partial-application closure on every non-success HTTP response. Replaced withSystem.Array.IndexOf, which avoids the closure:New V3 schema compilation tests (Task 10)
Added 5 tests to
Schema.V3SchemaCompilationTests.fscovering previously untested compiler behaviour:required property compiles to non-option typerequired: [id]→int32optional property compiles to option typerequired→string optionstring enum schema compiles to a named enum typetype: string, enum: [...]→ type namedStatusstring enum type is an enumIsEnum = trueobject schema description is surfaced as XmlDocdescriptionfield → XmlDoc attributeTest Status
438 → 443 (+5 new tests). Build: 0 errors, 209 warnings (pre-existing).