From 1260562a736eec175f50de608c6f99562a676dc3 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 11 Jul 2023 14:33:38 -0700 Subject: [PATCH 1/9] Use property reference type --- .../Azure.Core.Expressions.DataFactory.csproj | 2 +- .../src/DataFactoryKeyVaultSecretReference.cs | 2 +- .../src/DataFactoryLinkedServiceReference.cs | 2 +- .../src/DataFactorySecretBaseDefinition.cs | 2 +- .../src/DataFactorySecretString.cs | 2 +- .../Shared/PropertyReferenceTypeAttribute.cs | 17 +++++++++++++++-- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj index fdcaa96d7173..8aca39da28e0 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj @@ -29,7 +29,7 @@ - + diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs index 9d96351b84dc..81fa11d3499f 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs @@ -10,7 +10,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Key Vault secret reference. - [TypeReferenceType(false, new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseDefinition { /// Initializes a new instance of AzureKeyVaultSecretReference. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs index 5d8502b688fe..49aa94195a39 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs @@ -8,7 +8,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Linked service reference type. - [TypeReferenceType] + [PropertyReferenceType] public partial class DataFactoryLinkedServiceReference { /// Initializes a new instance of DataFactoryLinkedServiceReference. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs index d1425f57caae..5004034e5b3d 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs @@ -8,7 +8,7 @@ namespace Azure.Core.Expressions.DataFactory /// Please note 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 and . /// - [TypeReferenceType(false, new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public abstract partial class DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretBaseDefinition. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs index 9cc2dc1c0d6b..c7fa7d54286f 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs @@ -6,7 +6,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Data Factory secure string definition. The string value will be masked with asterisks '*' during Get or List API calls. - [TypeReferenceType(false, new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public partial class DataFactorySecretString : DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretString. diff --git a/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs b/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs index 3987820d7210..bc3ed5eb60d7 100644 --- a/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs +++ b/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs @@ -12,19 +12,32 @@ namespace Azure.Core internal class PropertyReferenceTypeAttribute : Attribute { /// - /// Instatiate a new reference type attribute. + /// Instantiate a new reference type attribute. /// /// An array of property names that are optional when comparing the type. public PropertyReferenceTypeAttribute(string[] optionalProperties) + : this(optionalProperties, Array.Empty()) + { + } + + /// + /// Instantiate a new reference type attribute. + /// + /// An array of property names that are optional when comparing the type. + /// + public PropertyReferenceTypeAttribute(string[] optionalProperties, string[] internalPropertiesToInclude) { OptionalProperties = optionalProperties; + InternalPropertiesToInclude = internalPropertiesToInclude; } + public string[] InternalPropertiesToInclude { get; } + /// /// Instantiate a new reference type attribute. /// public PropertyReferenceTypeAttribute() - : this(Array.Empty()) + : this(Array.Empty(), Array.Empty()) { } From edfb2c02c085e2e1df72e28155ea516f3cfdff3e Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 11 Jul 2023 14:45:55 -0700 Subject: [PATCH 2/9] docs --- .../Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs b/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs index bc3ed5eb60d7..141b350a5eae 100644 --- a/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs +++ b/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs @@ -24,7 +24,10 @@ public PropertyReferenceTypeAttribute(string[] optionalProperties) /// Instantiate a new reference type attribute. /// /// An array of property names that are optional when comparing the type. - /// + /// 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. public PropertyReferenceTypeAttribute(string[] optionalProperties, string[] internalPropertiesToInclude) { OptionalProperties = optionalProperties; From bf7f2901346e9449169330ba69eb25fd3ebd0395 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 11 Jul 2023 15:35:04 -0700 Subject: [PATCH 3/9] Add ctor attributes --- .../src/Azure.Core.Expressions.DataFactory.csproj | 2 ++ .../src/DataFactoryKeyVaultSecretReference.cs | 4 +++- .../src/DataFactoryLinkedServiceReference.cs | 2 ++ .../src/DataFactorySecretBaseDefinition.cs | 2 ++ .../src/DataFactorySecretString.cs | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj index 8aca39da28e0..c42a834e3325 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj @@ -30,6 +30,8 @@ + + diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs index 81fa11d3499f..b24faa8cdc20 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs @@ -17,7 +17,8 @@ public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseD /// The Azure Key Vault linked service reference. /// The name of the secret in Azure Key Vault. Type: string (or Expression with resultType string). /// or is null. - public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference store, DataFactoryElement secretName) + [InitializationConstructor] + public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference store, DataFactoryElement secretName) : base() { Argument.AssertNotNull(store, nameof(store)); Argument.AssertNotNull(secretName, nameof(secretName)); @@ -32,6 +33,7 @@ public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference stor /// The Azure Key Vault linked service reference. /// The name of the secret in Azure Key Vault. Type: string (or Expression with resultType string). /// 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). + [SerializationConstructor] internal DataFactoryKeyVaultSecretReference(string secretBaseType, DataFactoryLinkedServiceReference store, DataFactoryElement secretName, DataFactoryElement secretVersion) : base(secretBaseType) { Store = store; diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs index 49aa94195a39..953b5c08a0e6 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs @@ -15,6 +15,7 @@ public partial class DataFactoryLinkedServiceReference /// Linked service reference type. /// Reference LinkedService name. /// is null. + [InitializationConstructor] public DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType referenceType, string referenceName) { Argument.AssertNotNull(referenceName, nameof(referenceName)); @@ -28,6 +29,7 @@ public DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType r /// Linked service reference type. /// Reference LinkedService name. /// Arguments for LinkedService. + [SerializationConstructor] internal DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType referenceType, string? referenceName, IDictionary parameters) { ReferenceType = referenceType; diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs index 5004034e5b3d..c5dbf3be458e 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs @@ -12,12 +12,14 @@ namespace Azure.Core.Expressions.DataFactory public abstract partial class DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretBaseDefinition. + [InitializationConstructor] protected DataFactorySecretBaseDefinition() { } /// Initializes a new instance of DataFactorySecretBaseDefinition. /// Type of the secret. + [SerializationConstructor] internal DataFactorySecretBaseDefinition(string? secretBaseType) { SecretBaseType = secretBaseType; diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs index c7fa7d54286f..6b55f118c987 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs @@ -12,6 +12,7 @@ public partial class DataFactorySecretString : DataFactorySecretBaseDefinition /// Initializes a new instance of DataFactorySecretString. /// Value of secure string. /// is null. + [InitializationConstructor] public DataFactorySecretString(string value) { Argument.AssertNotNull(value, nameof(value)); @@ -23,6 +24,7 @@ public DataFactorySecretString(string value) /// Initializes a new instance of DataFactorySecretString. /// Type of the secret. /// Value of secure string. + [SerializationConstructor] internal DataFactorySecretString(string? secretBaseType, string? value) : base(secretBaseType) { Value = value; From ef7f4afeb7102877dfe6e568adb886e112e30867 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:17:58 -0700 Subject: [PATCH 4/9] Make discriminator property public --- .../api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs | 1 + .../src/DataFactoryKeyVaultSecretReference.cs | 2 +- .../src/DataFactorySecretBaseDefinition.cs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs b/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs index 984d64614b28..4e5857166081 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs @@ -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 { diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs index b24faa8cdc20..147eb3c0c9de 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs @@ -18,7 +18,7 @@ public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseD /// The name of the secret in Azure Key Vault. Type: string (or Expression with resultType string). /// or is null. [InitializationConstructor] - public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference store, DataFactoryElement secretName) : base() + public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference store, DataFactoryElement secretName) { Argument.AssertNotNull(store, nameof(store)); Argument.AssertNotNull(secretName, nameof(secretName)); diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs index c5dbf3be458e..45162fb08a3e 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs @@ -26,6 +26,6 @@ internal DataFactorySecretBaseDefinition(string? secretBaseType) } /// Type of the secret. - internal string? SecretBaseType { get; set; } + public string? SecretBaseType { get; set; } } } From 233acb39379e829796f904e737c6bc1343de364f Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:20:06 -0700 Subject: [PATCH 5/9] remove attribute args --- .../src/DataFactoryKeyVaultSecretReference.cs | 2 +- .../src/DataFactorySecretBaseDefinition.cs | 2 +- .../src/DataFactorySecretString.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs index 147eb3c0c9de..fea9a78151e0 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs @@ -10,7 +10,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Key Vault secret reference. - [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType] public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseDefinition { /// Initializes a new instance of AzureKeyVaultSecretReference. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs index 45162fb08a3e..9b7652f01d35 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs @@ -8,7 +8,7 @@ namespace Azure.Core.Expressions.DataFactory /// Please note 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 and . /// - [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType] public abstract partial class DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretBaseDefinition. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs index 6b55f118c987..b7d2a215e482 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs @@ -6,7 +6,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Data Factory secure string definition. The string value will be masked with asterisks '*' during Get or List API calls. - [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType] public partial class DataFactorySecretString : DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretString. From cdfc5456211069fce6c5f961a71d19ee8f50b177 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 11 Jul 2023 21:24:33 -0700 Subject: [PATCH 6/9] Try referenceType --- .../src/Azure.Core.Expressions.DataFactory.csproj | 2 +- .../src/DataFactoryKeyVaultSecretReference.cs | 2 +- .../src/DataFactoryLinkedServiceReference.cs | 2 +- .../src/DataFactorySecretBaseDefinition.cs | 2 +- .../src/DataFactorySecretString.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj index c42a834e3325..058c9dd4c097 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj @@ -29,7 +29,7 @@ - + diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs index fea9a78151e0..70f5d0fe9dfe 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs @@ -10,7 +10,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Key Vault secret reference. - [PropertyReferenceType] + [ReferenceType] public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseDefinition { /// Initializes a new instance of AzureKeyVaultSecretReference. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs index 953b5c08a0e6..283d3752ffc9 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs @@ -8,7 +8,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Linked service reference type. - [PropertyReferenceType] + [ReferenceType] public partial class DataFactoryLinkedServiceReference { /// Initializes a new instance of DataFactoryLinkedServiceReference. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs index 9b7652f01d35..801a43c39a49 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs @@ -8,7 +8,7 @@ namespace Azure.Core.Expressions.DataFactory /// Please note 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 and . /// - [PropertyReferenceType] + [ReferenceType] public abstract partial class DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretBaseDefinition. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs index b7d2a215e482..49b48d2e1c2a 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs @@ -6,7 +6,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Data Factory secure string definition. The string value will be masked with asterisks '*' during Get or List API calls. - [PropertyReferenceType] + [ReferenceType] public partial class DataFactorySecretString : DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretString. From ed2dbe3845a8c62e80ef3a650dd82f6943d249a0 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 12 Jul 2023 14:07:25 -0700 Subject: [PATCH 7/9] Revert attribute changes and add model factory --- ....Expressions.DataFactory.netstandard2.0.cs | 8 ++- .../Azure.Core.Expressions.DataFactory.csproj | 2 +- .../src/DataFactoryKeyVaultSecretReference.cs | 2 +- .../src/DataFactoryLinkedServiceReference.cs | 2 +- .../src/DataFactoryModelFactory.cs | 56 +++++++++++++++++++ .../src/DataFactorySecretBaseDefinition.cs | 4 +- .../src/DataFactorySecretString.cs | 2 +- 7 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs b/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs index 4e5857166081..457451c1fa96 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs @@ -64,10 +64,16 @@ 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 secretName, Azure.Core.Expressions.DataFactory.DataFactoryElement secretVersion) { throw null; } + public static Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReference DataFactoryLinkedServiceReference(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReferenceType referenceType, string? referenceName, System.Collections.Generic.IDictionary 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() { } - public string? SecretBaseType { get { throw null; } set { } } } public partial class DataFactorySecretString : Azure.Core.Expressions.DataFactory.DataFactorySecretBaseDefinition { diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj index 058c9dd4c097..c42a834e3325 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj @@ -29,7 +29,7 @@ - + diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs index 70f5d0fe9dfe..147eb3c0c9de 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs @@ -10,7 +10,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Key Vault secret reference. - [ReferenceType] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseDefinition { /// Initializes a new instance of AzureKeyVaultSecretReference. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs index 283d3752ffc9..953b5c08a0e6 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs @@ -8,7 +8,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Linked service reference type. - [ReferenceType] + [PropertyReferenceType] public partial class DataFactoryLinkedServiceReference { /// Initializes a new instance of DataFactoryLinkedServiceReference. diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs new file mode 100644 index 000000000000..0a354a3b084a --- /dev/null +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs @@ -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 +{ + /// + /// + /// + public static class DataFactoryModelFactory + { + /// + /// + /// + /// + /// + public static DataFactorySecretString DataFactorySecretString(string value) => + new DataFactorySecretString(value); + + /// + /// + /// + /// + /// + /// + /// + public static DataFactoryKeyVaultSecretReference DataFactoryKeyVaultSecretReference( + DataFactoryLinkedServiceReference store, + DataFactoryElement secretName, + DataFactoryElement secretVersion) => + new DataFactoryKeyVaultSecretReference(store, secretName) { SecretVersion = secretVersion }; + + /// + /// + /// + /// + /// + public static DataFactorySecretBaseDefinition DataFactorySecretBaseDefinition(string secretBaseType) => + new UnknownSecretBase(secretBaseType); + + /// + /// + /// + /// + /// + /// + /// + public static DataFactoryLinkedServiceReference DataFactoryLinkedServiceReference( + DataFactoryLinkedServiceReferenceType referenceType, + string? referenceName, + IDictionary parameters) => + new DataFactoryLinkedServiceReference(referenceType, referenceName, parameters); + } +} \ No newline at end of file diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs index 801a43c39a49..c5dbf3be458e 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs @@ -8,7 +8,7 @@ namespace Azure.Core.Expressions.DataFactory /// Please note 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 and . /// - [ReferenceType] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public abstract partial class DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretBaseDefinition. @@ -26,6 +26,6 @@ internal DataFactorySecretBaseDefinition(string? secretBaseType) } /// Type of the secret. - public string? SecretBaseType { get; set; } + internal string? SecretBaseType { get; set; } } } diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs index 49b48d2e1c2a..6b55f118c987 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs @@ -6,7 +6,7 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Data Factory secure string definition. The string value will be masked with asterisks '*' during Get or List API calls. - [ReferenceType] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public partial class DataFactorySecretString : DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretString. From 7fd7f3c877e3ff5af1978ce4728deee3767553a4 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:29:11 -0700 Subject: [PATCH 8/9] Add ref docs --- .../src/DataFactoryModelFactory.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs index 0a354a3b084a..16fb8e8e6fe6 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs @@ -7,25 +7,25 @@ namespace Azure.Core.Expressions.DataFactory { /// - /// + /// Model factory to construct types for mocking. /// public static class DataFactoryModelFactory { /// - /// + /// Constructs a for mocking. /// - /// - /// + /// The secret string value. + /// The constructed . public static DataFactorySecretString DataFactorySecretString(string value) => new DataFactorySecretString(value); /// - /// + /// Constructs a for mocking. /// - /// - /// - /// - /// + /// The linked store. + /// The secret name. + /// The secret version. + /// The constructed . public static DataFactoryKeyVaultSecretReference DataFactoryKeyVaultSecretReference( DataFactoryLinkedServiceReference store, DataFactoryElement secretName, @@ -33,20 +33,20 @@ public static DataFactoryKeyVaultSecretReference DataFactoryKeyVaultSecretRefere new DataFactoryKeyVaultSecretReference(store, secretName) { SecretVersion = secretVersion }; /// - /// + /// Constructs a for mocking. /// - /// - /// + /// The secret base type. + /// The constructed . public static DataFactorySecretBaseDefinition DataFactorySecretBaseDefinition(string secretBaseType) => new UnknownSecretBase(secretBaseType); /// - /// + /// Constructs a for mocking. /// - /// - /// - /// - /// + /// The reference type. + /// The reference name. + /// The reference parameters. + /// The constructed . public static DataFactoryLinkedServiceReference DataFactoryLinkedServiceReference( DataFactoryLinkedServiceReferenceType referenceType, string? referenceName, From c91e53958a46a533c85cb1800ca77a383c58a138 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:48:20 -0700 Subject: [PATCH 9/9] Update change log --- sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md b/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md index 5c646f09c221..1d71153793ce 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md +++ b/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md @@ -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)