Skip to content
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

Use property reference type #37542

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Release History

## 1.0.0-beta.4 (2023-07-10)
## 1.0.0-beta.4 (2023-07-13)

### Other Changes

- Added `TypeReferenceTypeAttribute` to Data Factory types to support code generation.
- Added `PropertyReferenceTypeAttribute` to Data Factory types to support code generation.
- Added `DataFactoryModelFactory` to support mocking.

## 1.0.0-beta.3 (2023-06-27)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public DataFactoryLinkedServiceReference(Azure.Core.Expressions.DataFactory.Data
public static bool operator !=(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReferenceType left, Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReferenceType right) { throw null; }
public override string ToString() { throw null; }
}
public static partial class DataFactoryModelFactory
{
public static Azure.Core.Expressions.DataFactory.DataFactoryKeyVaultSecretReference DataFactoryKeyVaultSecretReference(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReference store, Azure.Core.Expressions.DataFactory.DataFactoryElement<string> secretName, Azure.Core.Expressions.DataFactory.DataFactoryElement<string> secretVersion) { throw null; }
public static Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReference DataFactoryLinkedServiceReference(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReferenceType referenceType, string? referenceName, System.Collections.Generic.IDictionary<string, System.BinaryData?> parameters) { throw null; }
public static Azure.Core.Expressions.DataFactory.DataFactorySecretBaseDefinition DataFactorySecretBaseDefinition(string secretBaseType) { throw null; }
public static Azure.Core.Expressions.DataFactory.DataFactorySecretString DataFactorySecretString(string value) { throw null; }
}
public abstract partial class DataFactorySecretBaseDefinition
{
protected DataFactorySecretBaseDefinition() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
<Compile Include="$(AutoRestSharedCodeDirectory)ChangeTrackingDictionary.cs" LinkBase="Shared\AutoRest" />
<Compile Include="$(AutoRestSharedCodeDirectory)ChangeTrackingList.cs" LinkBase="Shared\AutoRest" />
<Compile Include="$(AzureCoreSharedSources)Argument.cs" LinkBase="Shared\Core" />
<Compile Include="$(AzureCoreSharedSources)TypeReferenceTypeAttribute.cs" LinkBase="Shared\Core" />
<Compile Include="$(AzureCoreSharedSources)PropertyReferenceTypeAttribute.cs" LinkBase="Shared\Core" />
<Compile Include="$(AzureCoreSharedSources)InitializationConstructorAttribute.cs" LinkBase="Shared\Core" />
<Compile Include="$(AzureCoreSharedSources)SerializationConstructorAttribute.cs" LinkBase="Shared\Core" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
namespace Azure.Core.Expressions.DataFactory
{
/// <summary> Azure Key Vault secret reference. </summary>
[TypeReferenceType(false, new[]{ nameof(SecretBaseType)})]
[PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})]
public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseDefinition
{
/// <summary> Initializes a new instance of AzureKeyVaultSecretReference. </summary>
/// <param name="store"> The Azure Key Vault linked service reference. </param>
/// <param name="secretName"> The name of the secret in Azure Key Vault. Type: string (or Expression with resultType string). </param>
/// <exception cref="ArgumentNullException"> <paramref name="store"/> or <paramref name="secretName"/> is null. </exception>
[InitializationConstructor]
public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference store, DataFactoryElement<string> secretName)
{
Argument.AssertNotNull(store, nameof(store));
Expand All @@ -32,6 +33,7 @@ public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference stor
/// <param name="store"> The Azure Key Vault linked service reference. </param>
/// <param name="secretName"> The name of the secret in Azure Key Vault. Type: string (or Expression with resultType string). </param>
/// <param name="secretVersion"> The version of the secret in Azure Key Vault. The default value is the latest version of the secret. Type: string (or Expression with resultType string). </param>
[SerializationConstructor]
internal DataFactoryKeyVaultSecretReference(string secretBaseType, DataFactoryLinkedServiceReference store, DataFactoryElement<string> secretName, DataFactoryElement<string> secretVersion) : base(secretBaseType)
{
Store = store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
namespace Azure.Core.Expressions.DataFactory
{
/// <summary> Linked service reference type. </summary>
[TypeReferenceType]
[PropertyReferenceType]
public partial class DataFactoryLinkedServiceReference
{
/// <summary> Initializes a new instance of DataFactoryLinkedServiceReference. </summary>
/// <param name="referenceType"> Linked service reference type. </param>
/// <param name="referenceName"> Reference LinkedService name. </param>
/// <exception cref="ArgumentNullException"> <paramref name="referenceName"/> is null. </exception>
[InitializationConstructor]
public DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType referenceType, string referenceName)
{
Argument.AssertNotNull(referenceName, nameof(referenceName));
Expand All @@ -28,6 +29,7 @@ public DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType r
/// <param name="referenceType"> Linked service reference type. </param>
/// <param name="referenceName"> Reference LinkedService name. </param>
/// <param name="parameters"> Arguments for LinkedService. </param>
[SerializationConstructor]
internal DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType referenceType, string? referenceName, IDictionary<string, BinaryData?> parameters)
{
ReferenceType = referenceType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;

namespace Azure.Core.Expressions.DataFactory
{
/// <summary>
/// Model factory to construct types for mocking.
/// </summary>
public static class DataFactoryModelFactory
{
/// <summary>
/// Constructs a <see cref="DataFactorySecretString"/> for mocking.
/// </summary>
/// <param name="value">The secret string value.</param>
/// <returns>The constructed <see cref="DataFactorySecretString"/>.</returns>
public static DataFactorySecretString DataFactorySecretString(string value) =>
new DataFactorySecretString(value);

/// <summary>
/// Constructs a <see cref="DataFactoryKeyVaultSecretReference"/> for mocking.
/// </summary>
/// <param name="store">The linked store.</param>
/// <param name="secretName">The secret name.</param>
/// <param name="secretVersion">The secret version.</param>
/// <returns>The constructed <see cref="DataFactoryKeyVaultSecretReference"/>.</returns>
public static DataFactoryKeyVaultSecretReference DataFactoryKeyVaultSecretReference(
DataFactoryLinkedServiceReference store,
DataFactoryElement<string> secretName,
DataFactoryElement<string> secretVersion) =>
new DataFactoryKeyVaultSecretReference(store, secretName) { SecretVersion = secretVersion };

/// <summary>
/// Constructs a <see cref="DataFactorySecretBaseDefinition"/> for mocking.
/// </summary>
/// <param name="secretBaseType">The secret base type.</param>
/// <returns>The constructed <see cref="DataFactorySecretBaseDefinition"/>.</returns>
public static DataFactorySecretBaseDefinition DataFactorySecretBaseDefinition(string secretBaseType) =>
new UnknownSecretBase(secretBaseType);

/// <summary>
/// Constructs a <see cref="DataFactoryLinkedServiceReference"/> for mocking.
/// </summary>
/// <param name="referenceType">The reference type.</param>
/// <param name="referenceName">The reference name.</param>
/// <param name="parameters">The reference parameters.</param>
/// <returns>The constructed <see cref="DataFactoryLinkedServiceReference"/>.</returns>
public static DataFactoryLinkedServiceReference DataFactoryLinkedServiceReference(
DataFactoryLinkedServiceReferenceType referenceType,
string? referenceName,
IDictionary<string, BinaryData?> parameters) =>
new DataFactoryLinkedServiceReference(referenceType, referenceName, parameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ namespace Azure.Core.Expressions.DataFactory
/// Please note <see cref="DataFactorySecretBaseDefinition"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
/// The available derived classes include <see cref="DataFactorySecretString"/> and <see cref="DataFactoryKeyVaultSecretReference"/>.
/// </summary>
[TypeReferenceType(false, new[]{ nameof(SecretBaseType)})]
[PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})]
public abstract partial class DataFactorySecretBaseDefinition
{
/// <summary> Initializes a new instance of DataFactorySecretBaseDefinition. </summary>
[InitializationConstructor]
protected DataFactorySecretBaseDefinition()
{
}

/// <summary> Initializes a new instance of DataFactorySecretBaseDefinition. </summary>
/// <param name="secretBaseType"> Type of the secret. </param>
[SerializationConstructor]
internal DataFactorySecretBaseDefinition(string? secretBaseType)
{
SecretBaseType = secretBaseType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
namespace Azure.Core.Expressions.DataFactory
{
/// <summary> Azure Data Factory secure string definition. The string value will be masked with asterisks '*' during Get or List API calls. </summary>
[TypeReferenceType(false, new[]{ nameof(SecretBaseType)})]
[PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})]
public partial class DataFactorySecretString : DataFactorySecretBaseDefinition
{
/// <summary> Initializes a new instance of DataFactorySecretString. </summary>
/// <param name="value"> Value of secure string. </param>
/// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception>
[InitializationConstructor]
public DataFactorySecretString(string value)
{
Argument.AssertNotNull(value, nameof(value));
Expand All @@ -23,6 +24,7 @@ public DataFactorySecretString(string value)
/// <summary> Initializes a new instance of DataFactorySecretString. </summary>
/// <param name="secretBaseType"> Type of the secret. </param>
/// <param name="value"> Value of secure string. </param>
[SerializationConstructor]
internal DataFactorySecretString(string? secretBaseType, string? value) : base(secretBaseType)
{
Value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,35 @@ namespace Azure.Core
internal class PropertyReferenceTypeAttribute : Attribute
{
/// <summary>
/// Instatiate a new reference type attribute.
/// Instantiate a new reference type attribute.
/// </summary>
/// <param name="optionalProperties"> An array of property names that are optional when comparing the type. </param>
public PropertyReferenceTypeAttribute(string[] optionalProperties)
: this(optionalProperties, Array.Empty<string>())
{
}

/// <summary>
/// Instantiate a new reference type attribute.
/// </summary>
/// <param name="optionalProperties"> An array of property names that are optional when comparing the type. </param>
/// <param name="internalPropertiesToInclude">An array of internal properties to include for the reference type when evaluating whether type
/// replacement should occur. When evaluating a type for replacement with a reference type, all internal properties are considered on the
/// type to be replaced. Thus this parameter can be used to specify internal properties to allow replacement to occur on a type with internal
/// properties.</param>
public PropertyReferenceTypeAttribute(string[] optionalProperties, string[] internalPropertiesToInclude)
{
OptionalProperties = optionalProperties;
InternalPropertiesToInclude = internalPropertiesToInclude;
}

public string[] InternalPropertiesToInclude { get; }

/// <summary>
/// Instantiate a new reference type attribute.
/// </summary>
public PropertyReferenceTypeAttribute()
: this(Array.Empty<string>())
: this(Array.Empty<string>(), Array.Empty<string>())
{
}

Expand Down