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 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public DataFactoryLinkedServiceReference(Azure.Core.Expressions.DataFactory.Data
public abstract partial class DataFactorySecretBaseDefinition
{
protected DataFactorySecretBaseDefinition() { }
public string? SecretBaseType { get { throw null; } set { } }
}
public partial class DataFactorySecretString : Azure.Core.Expressions.DataFactory.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)ReferenceTypeAttribute.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)})]
[ReferenceType]
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]
[ReferenceType]
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
Expand Up @@ -8,22 +8,24 @@ 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)})]
[ReferenceType]
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;
}

/// <summary> Type of the secret. </summary>
internal string? SecretBaseType { get; set; }
public string? SecretBaseType { get; set; }
}
}
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)})]
[ReferenceType]
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