-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Support generating DataFactoryElement<> properties in the Azure generator #54348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…alType Co-authored-by: JoshLove-msft <[email protected]>
Co-authored-by: JoshLove-msft <[email protected]>
| return base.CreateCSharpTypeCore(inputType); | ||
| } | ||
|
|
||
| private const string DataFactoryElementIdentity = "Azure.Core.Expressions.DataFactoryElement"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot move this to the top of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7074a2b.
| // If there is more than one other variant, log a warning and don't apply specialized logic | ||
| if (otherVariantCount != 1 || otherVariantType == null) | ||
| { | ||
| // TODO: Add proper logging when logging infrastructure is available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot we can log this with AzureClientGenerator.Instance.Emitter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0ea2c90. Using AzureClientGenerator.Instance.Emitter.ReportDiagnostic("DFE001", message) to log the warning.
| } | ||
| } | ||
| else if (inputType is InputExternalType inputExternalType) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot we can remove this branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0ea2c90. Removed the InputExternalType branch.
|
@copilot please also add models/properties using alternateType with Dfe to https://github.com/Azure/azure-sdk-for-net/blob/main/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/Basic-TypeSpec.tsp |
| } | ||
|
|
||
| [Test] | ||
| public void DataFactoryElementNotAppliedForNonDataFactoryExternalType() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot let's also add a test where the inner type is a model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0ea2c90. Added DataFactoryElementWithModel() test that verifies the union type with an InputModelType inner type.
Co-authored-by: JoshLove-msft <[email protected]>
|
@copilot we need to update KnownAzureTypes to handle serialization/deserialization. |
Or is this already handled automatically? We should add a test that validates ModelReaderWriter is used for these properties. |
…te TypeSpec Co-authored-by: JoshLove-msft <[email protected]>
Done in 0ea2c90. Added:
|
… patterns Co-authored-by: JoshLove-msft <[email protected]>
Yes, it's handled automatically by the base generator. Added tests in b1eebe7 that validate:
No changes to |
| package: "Azure.Core.Expressions.DataFactory", | ||
| }, "csharp"); | ||
|
|
||
| @@alternateType(DfeStringArrayUnion, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this shouldn't be repeated on each of the unions. It should instead go on DfeExpressionModel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add it inline rather than using an augment decorator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 18c9019. Moved the @@alternateType decorator to DfeExpressionModel instead of repeating it on each union.
Co-authored-by: JoshLove-msft <[email protected]>
DataFactoryElement<T>properties from InputUnionType with InputExternalType identity "Azure.Core.Expressions.DataFactoryElement"AzureTypeFactory.CreateCSharpTypeCore()Summary
This PR adds support for generating
DataFactoryElement<T>properties in the Azure generator when encountering anInputUnionTypethat contains anInputExternalTypevariant with identity"Azure.Core.Expressions.DataFactoryElement".Key Changes:
AzureTypeFactory.cs:
TryCreateDataFactoryElementTypeFromUnion()methodDataFactoryElement<T>whereTis derived from the other union variantAzure.Generator.csproj: Added reference to
Azure.Core.Expressions.DataFactorypackageTests: 9 comprehensive unit tests covering:
Basic-TypeSpec.tsp: Added DataFactoryElement union patterns with alternateType decorator on DfeExpressionModel
Serialization/Deserialization
The base generator automatically handles
DataFactoryElement<T>serialization and deserialization because:WriteObjectValue<T>which leveragesIJsonModel<T>internallyDeserializeDataFactoryElementstatic methodNo changes to
KnownAzureTypes.cswere needed.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.