[repo-assist] perf/test: avoid obj[] alloc in getPropertyNamesAndInfos; add HTTP method + schema compilation tests (+13 tests, 425→438)#444
Conversation
…nd schema compilation tests (+13 tests, 425→438) Task 8 (perf): replace GetCustomAttributes(type, bool) array-pattern in getPropertyNamesAndInfos with Attribute.GetCustomAttribute(prop, type), avoiding the obj[] allocation on each property during cache-fill. Task 9 (test): add 8 tests for HTTP method handling in CreateHttpRequestTests covering PATCH, HEAD, OPTIONS, TRACE, custom method normalisation, and multiple query parameter encoding. Task 10 (forward): add 6 tests for tryResolveSingle (allOf/oneOf/anyOf single-$ref resolution) in Schema.V2SchemaCompilationTests, verifying that wrapper schemas with a single reference collapse into the referenced type and do not produce spurious empty object types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves runtime reflection performance in RuntimeHelpers.getPropertyNamesAndInfos and expands unit test coverage around HTTP method normalization and schema compilation behavior for single-item allOf/oneOf/anyOf $ref wrappers.
Changes:
- Avoids per-property
obj[]allocations when readingJsonPropertyNameAttributeduring property-name cache fill. - Adds HTTP method + query-param encoding coverage for
createHttpRequest. - Adds schema compilation tests to ensure single
$refallOf/oneOf/anyOfwrappers resolve to the referenced type without emitting wrapper types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/SwaggerProvider.Runtime/RuntimeHelpers.fs |
Switches attribute lookup approach in cached reflection path to reduce allocations. |
tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs |
Adds more coverage for HTTP method resolution and multi-query-param encoding. |
tests/SwaggerProvider.Tests/Schema.V2SchemaCompilationTests.fs |
Adds tests validating tryResolveSingle behavior for single $ref allOf/oneOf/anyOf wrappers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot addresss inline comments |
…a, fix misleading comment Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/07dbe28c-84b0-4c45-a1c2-da0960998b6a Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
All three inline comments addressed in commit
All 438 tests pass. |
|
@copilot address inline comments |
…to Schema.V3SchemaCompilationTests.fs, fix section comments Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/4f4edf09-c80c-4daf-8348-e079cf17f3e4 Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
All three inline comments addressed in commit
All 438 tests pass. |
|
@copilot address applicable inline comments |
…move stale line numbers from test comments Agent-Logs-Url: https://github.com/fsprojects/SwaggerProvider/sessions/fd30f0f3-2e82-4986-acf3-53eab5c7b9fc Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
Two applicable comments addressed in commit
The third comment ( |
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Three improvements bundled as a single focused PR:
Task 8 — Performance: avoid
obj[]allocation ingetPropertyNamesAndInfosgetPropertyNamesAndInfospreviously calledprop.GetCustomAttributes(typeof<JsonPropertyNameAttribute>, false)which allocates anobj[]for every property during the cache-fill pass. Replaced withAttribute.GetCustomAttribute(prop, typeof<JsonPropertyNameAttribute>), which returns the attribute directly (ornull) without allocating an array.JsonPropertyNameAttributehasAllowMultiple = falseso at most one instance can be present — the old array pattern was unnecessary.Task 9 — Testing: HTTP method coverage in
CreateHttpRequestTestsAdded 8 new tests for the
createHttpRequest/resolveHttpMethodcode paths:PATCHmethod (cached standard method)HEADmethodOPTIONSmethodTRACEmethodpurge→PURGE)PATCHviapatchTask 10 — Forward:
tryResolveSingle(allOf/oneOf/anyOf) schema compilation testsAdded 6 tests to
Schema.V2SchemaCompilationTestsfor thetryResolveSinglehelper added in #441. These tests verify that an OpenAPI 3.0 schema usingallOf/oneOf/anyOfwith a single$refentry and no explicit properties:This directly tests the intended behaviour of the
tryResolveSingle+ReleaseNameReservationcode path introduced in the refactoring commit.Test Status