Skip to content

Support generating DataFactoryElement<> properties in the Azure generator #54347

@JoshLove-msft

Description

@JoshLove-msft

In https://github.com/Azure/azure-sdk-for-net/blob/main/eng/packages/http-client-csharp/generator/Azure.Generator/src/AzureTypeFactory.cs#L66, we need to handle InputUnionType that has a variant type of InputExternalType where the identity is "Azure.Core.Expressions.DataFactoryElement" in a special way. The logic should be that we create a generic type DataFactoryElement<T> where T is given by the other variant in the union. If there is more than one variant we should just log a warning and not apply this specialized logic.

We should update our test spec https://github.com/Azure/azure-sdk-for-net/blob/main/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/Basic-TypeSpec.tsp

This shows the full set of supported T values https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryElementJsonConverter.cs

include uses of this pattern. Here is the tsp:

union Dfe<T> {
  T,
  DfeModel,
}
model DfeModel {
  kind: "Expression";
  value: string;
}

/** A widget. */
@resource("widgets")
model Widget {
  /** The widget name. */
  @key("widgetName")
  @visibility(Lifecycle.Read)
  name: string;

  fooString: Dfe<string>;
  
  fooInt: Dfe<int>;

  fooModel: Dfe<SomeModel>;

  fooList: Dfe<string[]>;


  /** The widget color. */
  color: WidgetColor;

  /** The ID of the widget's manufacturer. */
  manufacturerId: string;

Metadata

Metadata

Assignees

Labels

ClientThis issue is related to a non-management packageCodeGenIssues that relate to code generation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions