Sample Generation - ExampleValueExpressionBuilder and OperationSample parity with autorest generator#10739
Open
MaiLinhP wants to merge 21 commits into
Open
Sample Generation - ExampleValueExpressionBuilder and OperationSample parity with autorest generator#10739MaiLinhP wants to merge 21 commits into
MaiLinhP wants to merge 21 commits into
Conversation
…y to be namespace aware
commit: |
Contributor
|
No changes needing a change description found. |
Contributor
jorgerangel-msft
left a comment
There was a problem hiding this comment.
Sorry if I missed this, but do you have a design doc of the proposed sample generation pipeline? I think that will help with understanding where these changes fit in the overall picture.
| ]; | ||
| } | ||
|
|
||
| protected virtual IReadOnlyList<OperationSample> BuildSamples() |
Contributor
There was a problem hiding this comment.
Is there a reason why this is protected virtual? Is it for testing? Also do you think the sample building should be decoupled from the client method construction we do here?
Contributor
|
Can we link to the design? |
Contributor
|
Can we add some example data to our test TSP? |
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.
Implements M1-M4 milestones for sample generation for the C# emitter — from mock value synthesis to emitting compilable Samples_{Client}.cs files. Based on the design document.
New Components
ExampleMockValueBuilder(M1) — GeneratesInputOperationExampleinstances for operations without spec-provided examples. ProducesShortVersion(required only) andAllParameters(with optional parameters) variants. This was simplified compared to autorest versions - instead of giving concrete mock values that matches the expected format for time/duration/different number types etc., mock values were simplified to "<{parameter name/encoded type hints}>" for strings, and 0 for numbers. This is because we're expecting AI based sample generator to read from deterministic samples and come up with scenario based mock values, hence a hint would be more useful than hardcoded mock values.ExampleValueExpressionBuilder(M2) — ConvertsInputExampleValue→ C#ValueExpressionAST nodes. Covers all primitives, collections, enums, models, credentialsApiKeyCredential,DefaultAzureCredential,BinaryContentanonymous objects, streams, etc.ExampleParameterValue(M2) — Dual-mode bridge holding either rawInputExampleValueor a pre-builtValueExpressionfor known parameters (credentials, endpoints).OperationSample(M3) — Resolves client construction chains (subclient → root), parameter value mappings (with spread support), inline/out-of-line decisions, and paging response type unwrapping.ClientSampleProvider(M4) —TypeProviderthat emitstests/Generated/Samples/Samples_{Client}.cswith sync+async [Test]/[Ignore] methods. Handles normal, pageable (foreach/await foreach), and LRO invocation patterns with JSON response parsing. Note: Per design doc,BuildSamplesshould live in
ScmMethodProviderCollection.cswhich is the equivalent of autorestOperationMethodChainBuilder.cs. However, coupling sample building with method building was purely for convenience, so it has been moved out to ClientSampleProvider for more clarity.Infrastructure Changes
ScmOutputLibrary— RegistersClientSampleProviderfor all clientsScmMethodProviderCollection— ExposedMethodProvidersfor sample provider access