Policy.Autorest/custom/BackCompatTypes.cs
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information. namespace Microsoft.Azure.PowerShell.Cmdlets.Policy.Models { // ── Back-compatibility marker types ───────────────────────────────────────── // Before the TypeSpec migration these free-form object properties were exposed as // distinct named interfaces. The current emitter collapses them all to the shared // <see cref="IAny"/>, which is a breaking change for consumers that referenced the // named types. These interfaces restore those public surface names. They carry no // members of their own — each is simply a named view over the free-form IAny bag. // The corresponding generated property is renamed to <Name>Raw in tspconfig.yaml so // a custom partial (see custom/<Model>.cs) can re-expose the original name typed as // the marker interface below. public partial interface IPolicyAssignmentPropertiesMetadata : IAny { } public partial interface IPolicyDefinitionPropertiesMetadata : IAny { } public partial interface IPolicyExemptionPropertiesMetadata : IAny { } public partial interface IPolicySetDefinitionPropertiesMetadata : IAny { } public partial interface IPolicyDefinitionPropertiesPolicyRule : IAny { } public partial interface IExternalEvaluationEndpointSettingsDetails : IAny { } /// <summary> /// Make the concrete free-form <see cref="Any"/> dictionary satisfy every back-compat /// marker interface. Because each <see cref="IAny"/> value produced by generation and /// deserialization is an <see cref="Any"/> instance, the re-exposed strongly named /// properties can return the underlying value with a simple cast — no data copying or /// wrapper allocation required. /// </summary> public partial class Any : IPolicyAssignmentPropertiesMetadata, IPolicyDefinitionPropertiesMetadata, IPolicyExemptionPropertiesMetadata, IPolicySetDefinitionPropertiesMetadata, IPolicyDefinitionPropertiesPolicyRule, IExternalEvaluationEndpointSettingsDetails { } // The TypeSpec migration renamed several named property types (a breaking change // for consumers referencing the old names). These interfaces recreate the old // public names with the same shape the new generated interfaces carry, so the // corresponding concrete generated classes satisfy them without any new members. // The generated property is renamed to <Name>Raw in tspconfig.yaml so a custom // partial (see custom/<Model>.cs) can re-expose the original name typed as the old // interface below. /// <summary> /// Pre-migration name for the policy assignment / policy definition reference parameter /// values dictionary (renamed to I*PropertiesParameters / IPolicyDefinitionReferenceParameters). /// </summary> public partial interface IParameterValues : Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.IJsonSerializable, Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.IAssociativeArray<Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IParameterValuesValue> { } /// <summary> /// Pre-migration name for the policy definition / policy set definition parameter /// definitions dictionary (renamed to I*PropertiesParameters). /// </summary> public partial interface IParameterDefinitions : Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.IJsonSerializable, Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.IAssociativeArray<Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IParameterDefinitionsValue> { } /// <summary> /// Pre-migration name for the selector expression element type (renamed to ISelector). It is the /// old public name for the current ISelector and carries the identical shape, so the concrete /// generated Selector class satisfies it without any new members. /// </summary> public partial interface ISelectorAutoGenerated : Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.ISelector { new System.Collections.Generic.List<string> In { get; set; } new System.Collections.Generic.List<string> NotIn { get; set; } new string Kind { get; set; } } /// <summary> /// Pre-migration name for the resource selector (renamed to IResourceSelector). It is the old /// public name for the current IResourceSelector. The members are re-declared here (rather than /// only inherited) so the breaking-change surface diff, which walks interface members declared-only, /// still sees Name and Selector on this type. Selector is restored to its pre-migration element /// type <see cref="ISelectorAutoGenerated"/> (the emitter renamed the element type to ISelector). /// </summary> public partial interface IResourceSelectorAutoGenerated : Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector { new string Name { get; set; } new System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.ISelectorAutoGenerated> Selector { get; set; } } // Make the current concrete generated types also satisfy the recreated old interfaces. // Each class already implements the identical member set (IAssociativeArray<...> / // IResourceSelector / ISelector), so these declarations add no members and cost nothing at runtime. public partial class PolicyAssignmentPropertiesParameters : IParameterValues { } public partial class PolicyDefinitionReferenceParameters : IParameterValues { } public partial class PolicyDefinitionPropertiesParameters : IParameterDefinitions { } public partial class PolicySetDefinitionPropertiesParameters : IParameterDefinitions { } public partial class Selector : ISelectorAutoGenerated { } /// <summary> /// Satisfies <see cref="IResourceSelectorAutoGenerated"/> whose Selector is typed with the /// pre-migration element type. Because List<A> is not assignable to List<B> even when the /// element types are compatible, the list is projected; the underlying elements are the same /// concrete <see cref="Selector"/> instances. /// </summary> public partial class ResourceSelector : IResourceSelectorAutoGenerated { System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.ISelectorAutoGenerated> Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelectorAutoGenerated.Selector { get { var __raw = ((Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector)this).Selector; return __raw == null ? null : System.Linq.Enumerable.ToList(System.Linq.Enumerable.OfType<Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.ISelectorAutoGenerated>(__raw)); } set => ((Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector)this).Selector = value == null ? null : System.Linq.Enumerable.ToList(System.Linq.Enumerable.OfType<Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.ISelector>(value)); } string Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelectorAutoGenerated.Name { get => ((Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector)this).Name; set => ((Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector)this).Name = value; } } } |