Skip to content

Flatten generation issues with nested inheritance #55437

@mzhongl524

Description

@mzhongl524

In RedisEnterprise, the RedisEnterpriseClusterData class generates the following properties

public partial class RedisEnterpriseClusterData : TrackedResourceData
{
   ...


    /// <summary> Other properties of the cluster. </summary>
    [WirePath("properties")]
    internal ClusterCreateProperties Properties { get; set; }

   ...

    /// <summary> Encryption-at-rest configuration for the cluster. </summary>
    [WirePath("properties.encryption")]
    public ClusterPropertiesEncryption Encryption
    {
        get
        {
            return Properties is null ? default : Properties.Encryption;
        }
        set
        {
            if (Properties is null)
            {
                Properties = new ClusterCreateProperties();
            }
            Properties.Encryption = value;
        }
    }

   ....
}

public partial class ClusterPropertiesEncryption
{
    /// <summary> Keeps track of any properties unknown to the library. </summary>
    private protected readonly IDictionary<string, BinaryData> _additionalBinaryDataProperties;

    /// <summary> Initializes a new instance of <see cref="ClusterPropertiesEncryption"/>. </summary>
    public ClusterPropertiesEncryption()
    {
    }

    /// <summary> Initializes a new instance of <see cref="ClusterPropertiesEncryption"/>. </summary>
    /// <param name="customerManagedKeyEncryption"> All Customer-managed key encryption properties for the resource. Set this to an empty object to use Microsoft-managed key encryption. </param>
    /// <param name="additionalBinaryDataProperties"> Keeps track of any properties unknown to the library. </param>
    internal ClusterPropertiesEncryption(RedisEnterpriseCustomerManagedKeyEncryption customerManagedKeyEncryption, IDictionary<string, BinaryData> additionalBinaryDataProperties)
    {
        CustomerManagedKeyEncryption = customerManagedKeyEncryption;
        _additionalBinaryDataProperties = additionalBinaryDataProperties;
    }

    /// <summary> All Customer-managed key encryption properties for the resource. Set this to an empty object to use Microsoft-managed key encryption. </summary>
    [WirePath("customerManagedKeyEncryption")]
    public RedisEnterpriseCustomerManagedKeyEncryption CustomerManagedKeyEncryption { get; set; }
}

And the code we need is as follows (link here)

   public partial class RedisEnterpriseClusterData : TrackedResourceData
    {
        ....


        /// <summary> Encryption-at-rest configuration for the cluster. </summary>
        internal ClusterPropertiesEncryption Encryption { get; set; }
        /// <summary> All Customer-managed key encryption properties for the resource. Set this to an empty object to use Microsoft-managed key encryption. </summary>
        [WirePath("properties.encryption.customerManagedKeyEncryption")]
        public RedisEnterpriseCustomerManagedKeyEncryption CustomerManagedKeyEncryption
        {
            get => Encryption is null ? default : Encryption.CustomerManagedKeyEncryption;
            set
            {
                if (Encryption is null)
                    Encryption = new ClusterPropertiesEncryption();
                Encryption.CustomerManagedKeyEncryption = value;
            }
        }

        ...
    }

Metadata

Metadata

Labels

CodeGenIssues that relate to code generationMgmtThis issue is related to a management package.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions