This commit is contained in:
Pavel Krymets 2020-07-27 12:27:39 -07:00 коммит произвёл GitHub
Родитель 4bb34678f1
Коммит 236193e312
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
119 изменённых файлов: 2395 добавлений и 561 удалений

Просмотреть файл

@ -10,14 +10,8 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class BlobRestoreStatus : IUtf8JsonSerializable
public partial class BlobRestoreStatus
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static BlobRestoreStatus DeserializeBlobRestoreStatus(JsonElement element)
{
Optional<BlobRestoreProgressStatus> status = default;

Просмотреть файл

@ -11,7 +11,7 @@ namespace Azure.Management.Storage.Models
public partial class BlobRestoreStatus
{
/// <summary> Initializes a new instance of BlobRestoreStatus. </summary>
public BlobRestoreStatus()
internal BlobRestoreStatus()
{
}

Просмотреть файл

@ -10,7 +10,7 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class DeletedShare : IUtf8JsonSerializable
internal partial class DeletedShare : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{

Просмотреть файл

@ -10,7 +10,7 @@ using System;
namespace Azure.Management.Storage.Models
{
/// <summary> The deleted share to be restored. </summary>
public partial class DeletedShare
internal partial class DeletedShare
{
/// <summary> Initializes a new instance of DeletedShare. </summary>
/// <param name="deletedShareName"> Required. Identify the name of the deleted share that will be restored. </param>

Просмотреть файл

@ -10,24 +10,8 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class Endpoints : IUtf8JsonSerializable
public partial class Endpoints
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(MicrosoftEndpoints))
{
writer.WritePropertyName("microsoftEndpoints");
writer.WriteObjectValue(MicrosoftEndpoints);
}
if (Optional.IsDefined(InternetEndpoints))
{
writer.WritePropertyName("internetEndpoints");
writer.WriteObjectValue(InternetEndpoints);
}
writer.WriteEndObject();
}
internal static Endpoints DeserializeEndpoints(JsonElement element)
{
Optional<string> blob = default;

Просмотреть файл

@ -11,7 +11,7 @@ namespace Azure.Management.Storage.Models
public partial class Endpoints
{
/// <summary> Initializes a new instance of Endpoints. </summary>
public Endpoints()
internal Endpoints()
{
}
@ -49,8 +49,8 @@ namespace Azure.Management.Storage.Models
/// <summary> Gets the dfs endpoint. </summary>
public string Dfs { get; }
/// <summary> Gets the microsoft routing storage endpoints. </summary>
public StorageAccountMicrosoftEndpoints MicrosoftEndpoints { get; set; }
public StorageAccountMicrosoftEndpoints MicrosoftEndpoints { get; }
/// <summary> Gets the internet routing storage endpoints. </summary>
public StorageAccountInternetEndpoints InternetEndpoints { get; set; }
public StorageAccountInternetEndpoints InternetEndpoints { get; }
}
}

Просмотреть файл

@ -11,14 +11,8 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class GeoReplicationStats : IUtf8JsonSerializable
public partial class GeoReplicationStats
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static GeoReplicationStats DeserializeGeoReplicationStats(JsonElement element)
{
Optional<GeoReplicationStatus> status = default;

Просмотреть файл

@ -13,7 +13,7 @@ namespace Azure.Management.Storage.Models
public partial class GeoReplicationStats
{
/// <summary> Initializes a new instance of GeoReplicationStats. </summary>
public GeoReplicationStats()
internal GeoReplicationStats()
{
}

Просмотреть файл

@ -11,31 +11,12 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class ImmutabilityPolicyProperties : IUtf8JsonSerializable
public partial class ImmutabilityPolicyProperties
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WritePropertyName("properties");
writer.WriteStartObject();
if (Optional.IsDefined(ImmutabilityPeriodSinceCreationInDays))
{
writer.WritePropertyName("immutabilityPeriodSinceCreationInDays");
writer.WriteNumberValue(ImmutabilityPeriodSinceCreationInDays.Value);
}
if (Optional.IsDefined(AllowProtectedAppendWrites))
{
writer.WritePropertyName("allowProtectedAppendWrites");
writer.WriteBooleanValue(AllowProtectedAppendWrites.Value);
}
writer.WriteEndObject();
writer.WriteEndObject();
}
internal static ImmutabilityPolicyProperties DeserializeImmutabilityPolicyProperties(JsonElement element)
{
Optional<string> etag = default;
Optional<IList<UpdateHistoryProperty>> updateHistory = default;
Optional<IReadOnlyList<UpdateHistoryProperty>> updateHistory = default;
Optional<int> immutabilityPeriodSinceCreationInDays = default;
Optional<ImmutabilityPolicyState> state = default;
Optional<bool> allowProtectedAppendWrites = default;

Просмотреть файл

@ -14,7 +14,7 @@ namespace Azure.Management.Storage.Models
public partial class ImmutabilityPolicyProperties
{
/// <summary> Initializes a new instance of ImmutabilityPolicyProperties. </summary>
public ImmutabilityPolicyProperties()
internal ImmutabilityPolicyProperties()
{
UpdateHistory = new ChangeTrackingList<UpdateHistoryProperty>();
}
@ -25,7 +25,7 @@ namespace Azure.Management.Storage.Models
/// <param name="immutabilityPeriodSinceCreationInDays"> The immutability period for the blobs in the container since the policy creation, in days. </param>
/// <param name="state"> The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. </param>
/// <param name="allowProtectedAppendWrites"> This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API. </param>
internal ImmutabilityPolicyProperties(string etag, IList<UpdateHistoryProperty> updateHistory, int? immutabilityPeriodSinceCreationInDays, ImmutabilityPolicyState? state, bool? allowProtectedAppendWrites)
internal ImmutabilityPolicyProperties(string etag, IReadOnlyList<UpdateHistoryProperty> updateHistory, int? immutabilityPeriodSinceCreationInDays, ImmutabilityPolicyState? state, bool? allowProtectedAppendWrites)
{
Etag = etag;
UpdateHistory = updateHistory;
@ -37,12 +37,12 @@ namespace Azure.Management.Storage.Models
/// <summary> ImmutabilityPolicy Etag. </summary>
public string Etag { get; }
/// <summary> The ImmutabilityPolicy update history of the blob container. </summary>
public IList<UpdateHistoryProperty> UpdateHistory { get; }
public IReadOnlyList<UpdateHistoryProperty> UpdateHistory { get; }
/// <summary> The immutability period for the blobs in the container since the policy creation, in days. </summary>
public int? ImmutabilityPeriodSinceCreationInDays { get; set; }
public int? ImmutabilityPeriodSinceCreationInDays { get; }
/// <summary> The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. </summary>
public ImmutabilityPolicyState? State { get; }
/// <summary> This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy API. </summary>
public bool? AllowProtectedAppendWrites { get; set; }
public bool? AllowProtectedAppendWrites { get; }
}
}

Просмотреть файл

@ -11,28 +11,12 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class LegalHoldProperties : IUtf8JsonSerializable
public partial class LegalHoldProperties
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsCollectionDefined(Tags))
{
writer.WritePropertyName("tags");
writer.WriteStartArray();
foreach (var item in Tags)
{
writer.WriteObjectValue(item);
}
writer.WriteEndArray();
}
writer.WriteEndObject();
}
internal static LegalHoldProperties DeserializeLegalHoldProperties(JsonElement element)
{
Optional<bool> hasLegalHold = default;
Optional<IList<TagProperty>> tags = default;
Optional<IReadOnlyList<TagProperty>> tags = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("hasLegalHold"))

Просмотреть файл

@ -14,7 +14,7 @@ namespace Azure.Management.Storage.Models
public partial class LegalHoldProperties
{
/// <summary> Initializes a new instance of LegalHoldProperties. </summary>
public LegalHoldProperties()
internal LegalHoldProperties()
{
Tags = new ChangeTrackingList<TagProperty>();
}
@ -22,7 +22,7 @@ namespace Azure.Management.Storage.Models
/// <summary> Initializes a new instance of LegalHoldProperties. </summary>
/// <param name="hasLegalHold"> The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. </param>
/// <param name="tags"> The list of LegalHold tags of a blob container. </param>
internal LegalHoldProperties(bool? hasLegalHold, IList<TagProperty> tags)
internal LegalHoldProperties(bool? hasLegalHold, IReadOnlyList<TagProperty> tags)
{
HasLegalHold = hasLegalHold;
Tags = tags;
@ -31,6 +31,6 @@ namespace Azure.Management.Storage.Models
/// <summary> The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold public property is set to false by SRP if all existing legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. </summary>
public bool? HasLegalHold { get; }
/// <summary> The list of LegalHold tags of a blob container. </summary>
public IList<TagProperty> Tags { get; }
public IReadOnlyList<TagProperty> Tags { get; }
}
}

Просмотреть файл

@ -38,7 +38,7 @@ namespace Azure.Management.Storage.Models
Optional<string> name = default;
Optional<string> type = default;
Optional<string> groupId = default;
Optional<IList<string>> requiredMembers = default;
Optional<IReadOnlyList<string>> requiredMembers = default;
Optional<IList<string>> requiredZoneNames = default;
foreach (var property in element.EnumerateObject())
{

Просмотреть файл

@ -27,7 +27,7 @@ namespace Azure.Management.Storage.Models
/// <param name="groupId"> The private link resource group id. </param>
/// <param name="requiredMembers"> The private link resource required member names. </param>
/// <param name="requiredZoneNames"> The private link resource Private link DNS zone name. </param>
internal PrivateLinkResource(string id, string name, string type, string groupId, IList<string> requiredMembers, IList<string> requiredZoneNames) : base(id, name, type)
internal PrivateLinkResource(string id, string name, string type, string groupId, IReadOnlyList<string> requiredMembers, IList<string> requiredZoneNames) : base(id, name, type)
{
GroupId = groupId;
RequiredMembers = requiredMembers;
@ -37,7 +37,7 @@ namespace Azure.Management.Storage.Models
/// <summary> The private link resource group id. </summary>
public string GroupId { get; }
/// <summary> The private link resource required member names. </summary>
public IList<string> RequiredMembers { get; }
public IReadOnlyList<string> RequiredMembers { get; }
/// <summary> The private link resource Private link DNS zone name. </summary>
public IList<string> RequiredZoneNames { get; }
}

Просмотреть файл

@ -95,7 +95,7 @@ namespace Azure.Management.Storage.Models
Optional<GeoReplicationStats> geoReplicationStats = default;
Optional<bool> failoverInProgress = default;
Optional<LargeFileSharesState> largeFileSharesState = default;
Optional<IList<PrivateEndpointConnection>> privateEndpointConnections = default;
Optional<IReadOnlyList<PrivateEndpointConnection>> privateEndpointConnections = default;
Optional<RoutingPreference> routingPreference = default;
Optional<BlobRestoreStatus> blobRestoreStatus = default;
foreach (var property in element.EnumerateObject())

Просмотреть файл

@ -58,7 +58,7 @@ namespace Azure.Management.Storage.Models
/// <param name="privateEndpointConnections"> List of private endpoint connection associated with the specified storage account. </param>
/// <param name="routingPreference"> Maintains information about the network routing choice opted by the user for data transfer. </param>
/// <param name="blobRestoreStatus"> Blob restore status. </param>
internal StorageAccount(string id, string name, string type, IDictionary<string, string> tags, string location, Sku sku, Kind? kind, Identity identity, ProvisioningState? provisioningState, Endpoints primaryEndpoints, string primaryLocation, AccountStatus? statusOfPrimary, DateTimeOffset? lastGeoFailoverTime, string secondaryLocation, AccountStatus? statusOfSecondary, DateTimeOffset? creationTime, CustomDomain customDomain, Endpoints secondaryEndpoints, Encryption encryption, AccessTier? accessTier, AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication, bool? enableHttpsTrafficOnly, NetworkRuleSet networkRuleSet, bool? isHnsEnabled, GeoReplicationStats geoReplicationStats, bool? failoverInProgress, LargeFileSharesState? largeFileSharesState, IList<PrivateEndpointConnection> privateEndpointConnections, RoutingPreference routingPreference, BlobRestoreStatus blobRestoreStatus) : base(id, name, type, tags, location)
internal StorageAccount(string id, string name, string type, IDictionary<string, string> tags, string location, Sku sku, Kind? kind, Identity identity, ProvisioningState? provisioningState, Endpoints primaryEndpoints, string primaryLocation, AccountStatus? statusOfPrimary, DateTimeOffset? lastGeoFailoverTime, string secondaryLocation, AccountStatus? statusOfSecondary, DateTimeOffset? creationTime, CustomDomain customDomain, Endpoints secondaryEndpoints, Encryption encryption, AccessTier? accessTier, AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication, bool? enableHttpsTrafficOnly, NetworkRuleSet networkRuleSet, bool? isHnsEnabled, GeoReplicationStats geoReplicationStats, bool? failoverInProgress, LargeFileSharesState? largeFileSharesState, IReadOnlyList<PrivateEndpointConnection> privateEndpointConnections, RoutingPreference routingPreference, BlobRestoreStatus blobRestoreStatus) : base(id, name, type, tags, location)
{
Sku = sku;
Kind = kind;
@ -132,7 +132,7 @@ namespace Azure.Management.Storage.Models
/// <summary> Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. </summary>
public LargeFileSharesState? LargeFileSharesState { get; set; }
/// <summary> List of private endpoint connection associated with the specified storage account. </summary>
public IList<PrivateEndpointConnection> PrivateEndpointConnections { get; }
public IReadOnlyList<PrivateEndpointConnection> PrivateEndpointConnections { get; }
/// <summary> Maintains information about the network routing choice opted by the user for data transfer. </summary>
public RoutingPreference RoutingPreference { get; set; }
/// <summary> Blob restore status. </summary>

Просмотреть файл

@ -10,7 +10,7 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class StorageAccountCheckNameAvailabilityParameters : IUtf8JsonSerializable
internal partial class StorageAccountCheckNameAvailabilityParameters : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{

Просмотреть файл

@ -10,7 +10,7 @@ using System;
namespace Azure.Management.Storage.Models
{
/// <summary> The parameters used to check the availability of the storage account name. </summary>
public partial class StorageAccountCheckNameAvailabilityParameters
internal partial class StorageAccountCheckNameAvailabilityParameters
{
/// <summary> Initializes a new instance of StorageAccountCheckNameAvailabilityParameters. </summary>
/// <param name="name"> The storage account name. </param>

Просмотреть файл

@ -10,14 +10,8 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class StorageAccountInternetEndpoints : IUtf8JsonSerializable
public partial class StorageAccountInternetEndpoints
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static StorageAccountInternetEndpoints DeserializeStorageAccountInternetEndpoints(JsonElement element)
{
Optional<string> blob = default;

Просмотреть файл

@ -11,7 +11,7 @@ namespace Azure.Management.Storage.Models
public partial class StorageAccountInternetEndpoints
{
/// <summary> Initializes a new instance of StorageAccountInternetEndpoints. </summary>
public StorageAccountInternetEndpoints()
internal StorageAccountInternetEndpoints()
{
}

Просмотреть файл

@ -10,14 +10,8 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class StorageAccountMicrosoftEndpoints : IUtf8JsonSerializable
public partial class StorageAccountMicrosoftEndpoints
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static StorageAccountMicrosoftEndpoints DeserializeStorageAccountMicrosoftEndpoints(JsonElement element)
{
Optional<string> blob = default;

Просмотреть файл

@ -11,7 +11,7 @@ namespace Azure.Management.Storage.Models
public partial class StorageAccountMicrosoftEndpoints
{
/// <summary> Initializes a new instance of StorageAccountMicrosoftEndpoints. </summary>
public StorageAccountMicrosoftEndpoints()
internal StorageAccountMicrosoftEndpoints()
{
}

Просмотреть файл

@ -10,7 +10,7 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class StorageAccountRegenerateKeyParameters : IUtf8JsonSerializable
internal partial class StorageAccountRegenerateKeyParameters : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{

Просмотреть файл

@ -10,7 +10,7 @@ using System;
namespace Azure.Management.Storage.Models
{
/// <summary> The parameters used to regenerate the storage account key. </summary>
public partial class StorageAccountRegenerateKeyParameters
internal partial class StorageAccountRegenerateKeyParameters
{
/// <summary> Initializes a new instance of StorageAccountRegenerateKeyParameters. </summary>
/// <param name="keyName"> The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. </param>

Просмотреть файл

@ -11,14 +11,8 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class TagProperty : IUtf8JsonSerializable
public partial class TagProperty
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static TagProperty DeserializeTagProperty(JsonElement element)
{
Optional<string> tag = default;

Просмотреть файл

@ -13,7 +13,7 @@ namespace Azure.Management.Storage.Models
public partial class TagProperty
{
/// <summary> Initializes a new instance of TagProperty. </summary>
public TagProperty()
internal TagProperty()
{
}

Просмотреть файл

@ -11,14 +11,8 @@ using Azure.Core;
namespace Azure.Management.Storage.Models
{
public partial class UpdateHistoryProperty : IUtf8JsonSerializable
public partial class UpdateHistoryProperty
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static UpdateHistoryProperty DeserializeUpdateHistoryProperty(JsonElement element)
{
Optional<ImmutabilityPolicyUpdateType> update = default;

Просмотреть файл

@ -13,7 +13,7 @@ namespace Azure.Management.Storage.Models
public partial class UpdateHistoryProperty
{
/// <summary> Initializes a new instance of UpdateHistoryProperty. </summary>
public UpdateHistoryProperty()
internal UpdateHistoryProperty()
{
}

Просмотреть файл

@ -48,7 +48,7 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> etag = default;
Optional<string> type = default;
Optional<string> id = default;
Optional<IList<NetworkInterfaceIPConfiguration>> backendIPConfigurations = default;
Optional<IReadOnlyList<NetworkInterfaceIPConfiguration>> backendIPConfigurations = default;
Optional<IList<ApplicationGatewayBackendAddress>> backendAddresses = default;
Optional<ProvisioningState> provisioningState = default;
foreach (var property in element.EnumerateObject())

Просмотреть файл

@ -28,7 +28,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="backendIPConfigurations"> Collection of references to IPs defined in network interfaces. </param>
/// <param name="backendAddresses"> Backend addresses. </param>
/// <param name="provisioningState"> The provisioning state of the backend address pool resource. </param>
internal ApplicationGatewayBackendAddressPool(string id, string name, string etag, string type, IList<NetworkInterfaceIPConfiguration> backendIPConfigurations, IList<ApplicationGatewayBackendAddress> backendAddresses, ProvisioningState? provisioningState) : base(id)
internal ApplicationGatewayBackendAddressPool(string id, string name, string etag, string type, IReadOnlyList<NetworkInterfaceIPConfiguration> backendIPConfigurations, IList<ApplicationGatewayBackendAddress> backendAddresses, ProvisioningState? provisioningState) : base(id)
{
Name = name;
Etag = etag;
@ -45,7 +45,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> Type of the resource. </summary>
public string Type { get; }
/// <summary> Collection of references to IPs defined in network interfaces. </summary>
public IList<NetworkInterfaceIPConfiguration> BackendIPConfigurations { get; }
public IReadOnlyList<NetworkInterfaceIPConfiguration> BackendIPConfigurations { get; }
/// <summary> Backend addresses. </summary>
public IList<ApplicationGatewayBackendAddress> BackendAddresses { get; }
/// <summary> The provisioning state of the backend address pool resource. </summary>

Просмотреть файл

@ -38,10 +38,10 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> etag = default;
Optional<string> type = default;
Optional<string> id = default;
Optional<IList<NetworkInterfaceIPConfiguration>> backendIPConfigurations = default;
Optional<IList<SubResource>> loadBalancingRules = default;
Optional<IReadOnlyList<NetworkInterfaceIPConfiguration>> backendIPConfigurations = default;
Optional<IReadOnlyList<SubResource>> loadBalancingRules = default;
Optional<SubResource> outboundRule = default;
Optional<IList<SubResource>> outboundRules = default;
Optional<IReadOnlyList<SubResource>> outboundRules = default;
Optional<ProvisioningState> provisioningState = default;
foreach (var property in element.EnumerateObject())
{

Просмотреть файл

@ -31,7 +31,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="outboundRule"> A reference to an outbound rule that uses this backend address pool. </param>
/// <param name="outboundRules"> An array of references to outbound rules that use this backend address pool. </param>
/// <param name="provisioningState"> The provisioning state of the backend address pool resource. </param>
internal BackendAddressPool(string id, string name, string etag, string type, IList<NetworkInterfaceIPConfiguration> backendIPConfigurations, IList<SubResource> loadBalancingRules, SubResource outboundRule, IList<SubResource> outboundRules, ProvisioningState? provisioningState) : base(id)
internal BackendAddressPool(string id, string name, string etag, string type, IReadOnlyList<NetworkInterfaceIPConfiguration> backendIPConfigurations, IReadOnlyList<SubResource> loadBalancingRules, SubResource outboundRule, IReadOnlyList<SubResource> outboundRules, ProvisioningState? provisioningState) : base(id)
{
Name = name;
Etag = etag;
@ -50,13 +50,13 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> Type of the resource. </summary>
public string Type { get; }
/// <summary> An array of references to IP addresses defined in network interfaces. </summary>
public IList<NetworkInterfaceIPConfiguration> BackendIPConfigurations { get; }
public IReadOnlyList<NetworkInterfaceIPConfiguration> BackendIPConfigurations { get; }
/// <summary> An array of references to load balancing rules that use this backend address pool. </summary>
public IList<SubResource> LoadBalancingRules { get; }
public IReadOnlyList<SubResource> LoadBalancingRules { get; }
/// <summary> A reference to an outbound rule that uses this backend address pool. </summary>
public SubResource OutboundRule { get; }
/// <summary> An array of references to outbound rules that use this backend address pool. </summary>
public IList<SubResource> OutboundRules { get; }
public IReadOnlyList<SubResource> OutboundRules { get; }
/// <summary> The provisioning state of the backend address pool resource. </summary>
public ProvisioningState? ProvisioningState { get; }
}

Просмотреть файл

@ -43,7 +43,7 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> etag = default;
Optional<string> id = default;
Optional<string> serviceName = default;
Optional<IList<string>> actions = default;
Optional<IReadOnlyList<string>> actions = default;
Optional<ProvisioningState> provisioningState = default;
foreach (var property in element.EnumerateObject())
{

Просмотреть файл

@ -26,7 +26,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="serviceName"> The name of the service to whom the subnet should be delegated (e.g. Microsoft.Sql/servers). </param>
/// <param name="actions"> The actions permitted to the service upon delegation. </param>
/// <param name="provisioningState"> The provisioning state of the service delegation resource. </param>
internal Delegation(string id, string name, string etag, string serviceName, IList<string> actions, ProvisioningState? provisioningState) : base(id)
internal Delegation(string id, string name, string etag, string serviceName, IReadOnlyList<string> actions, ProvisioningState? provisioningState) : base(id)
{
Name = name;
Etag = etag;
@ -42,7 +42,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> The name of the service to whom the subnet should be delegated (e.g. Microsoft.Sql/servers). </summary>
public string ServiceName { get; set; }
/// <summary> The actions permitted to the service upon delegation. </summary>
public IList<string> Actions { get; }
public IReadOnlyList<string> Actions { get; }
/// <summary> The provisioning state of the service delegation resource. </summary>
public ProvisioningState? ProvisioningState { get; }
}

Просмотреть файл

@ -79,10 +79,10 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> type = default;
Optional<IList<string>> zones = default;
Optional<string> id = default;
Optional<IList<SubResource>> inboundNatRules = default;
Optional<IList<SubResource>> inboundNatPools = default;
Optional<IList<SubResource>> outboundRules = default;
Optional<IList<SubResource>> loadBalancingRules = default;
Optional<IReadOnlyList<SubResource>> inboundNatRules = default;
Optional<IReadOnlyList<SubResource>> inboundNatPools = default;
Optional<IReadOnlyList<SubResource>> outboundRules = default;
Optional<IReadOnlyList<SubResource>> loadBalancingRules = default;
Optional<string> privateIPAddress = default;
Optional<IPAllocationMethod> privateIPAllocationMethod = default;
Optional<IPVersion> privateIPAddressVersion = default;

Просмотреть файл

@ -40,7 +40,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="publicIPAddress"> The reference to the Public IP resource. </param>
/// <param name="publicIPPrefix"> The reference to the Public IP Prefix resource. </param>
/// <param name="provisioningState"> The provisioning state of the frontend IP configuration resource. </param>
internal FrontendIPConfiguration(string id, string name, string etag, string type, IList<string> zones, IList<SubResource> inboundNatRules, IList<SubResource> inboundNatPools, IList<SubResource> outboundRules, IList<SubResource> loadBalancingRules, string privateIPAddress, IPAllocationMethod? privateIPAllocationMethod, IPVersion? privateIPAddressVersion, Subnet subnet, PublicIPAddress publicIPAddress, SubResource publicIPPrefix, ProvisioningState? provisioningState) : base(id)
internal FrontendIPConfiguration(string id, string name, string etag, string type, IList<string> zones, IReadOnlyList<SubResource> inboundNatRules, IReadOnlyList<SubResource> inboundNatPools, IReadOnlyList<SubResource> outboundRules, IReadOnlyList<SubResource> loadBalancingRules, string privateIPAddress, IPAllocationMethod? privateIPAllocationMethod, IPVersion? privateIPAddressVersion, Subnet subnet, PublicIPAddress publicIPAddress, SubResource publicIPPrefix, ProvisioningState? provisioningState) : base(id)
{
Name = name;
Etag = etag;
@ -68,13 +68,13 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> A list of availability zones denoting the IP allocated for the resource needs to come from. </summary>
public IList<string> Zones { get; }
/// <summary> An array of references to inbound rules that use this frontend IP. </summary>
public IList<SubResource> InboundNatRules { get; }
public IReadOnlyList<SubResource> InboundNatRules { get; }
/// <summary> An array of references to inbound pools that use this frontend IP. </summary>
public IList<SubResource> InboundNatPools { get; }
public IReadOnlyList<SubResource> InboundNatPools { get; }
/// <summary> An array of references to outbound rules that use this frontend IP. </summary>
public IList<SubResource> OutboundRules { get; }
public IReadOnlyList<SubResource> OutboundRules { get; }
/// <summary> An array of references to load balancing rules that use this frontend IP. </summary>
public IList<SubResource> LoadBalancingRules { get; }
public IReadOnlyList<SubResource> LoadBalancingRules { get; }
/// <summary> The private IP address of the IP configuration. </summary>
public string PrivateIPAddress { get; set; }
/// <summary> The Private IP allocation method. </summary>

Просмотреть файл

@ -85,13 +85,13 @@ namespace Azure.Network.Management.Interface.Models
Optional<NetworkSecurityGroup> networkSecurityGroup = default;
Optional<PrivateEndpoint> privateEndpoint = default;
Optional<IList<NetworkInterfaceIPConfiguration>> ipConfigurations = default;
Optional<IList<NetworkInterfaceTapConfiguration>> tapConfigurations = default;
Optional<IReadOnlyList<NetworkInterfaceTapConfiguration>> tapConfigurations = default;
Optional<NetworkInterfaceDnsSettings> dnsSettings = default;
Optional<string> macAddress = default;
Optional<bool> primary = default;
Optional<bool> enableAcceleratedNetworking = default;
Optional<bool> enableIPForwarding = default;
Optional<IList<string>> hostedWorkloads = default;
Optional<IReadOnlyList<string>> hostedWorkloads = default;
Optional<string> resourceGuid = default;
Optional<ProvisioningState> provisioningState = default;
foreach (var property in element.EnumerateObject())

Просмотреть файл

@ -41,7 +41,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="hostedWorkloads"> A list of references to linked BareMetal resources. </param>
/// <param name="resourceGuid"> The resource GUID property of the network interface resource. </param>
/// <param name="provisioningState"> The provisioning state of the network interface resource. </param>
internal NetworkInterface(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, SubResource virtualMachine, NetworkSecurityGroup networkSecurityGroup, PrivateEndpoint privateEndpoint, IList<NetworkInterfaceIPConfiguration> ipConfigurations, IList<NetworkInterfaceTapConfiguration> tapConfigurations, NetworkInterfaceDnsSettings dnsSettings, string macAddress, bool? primary, bool? enableAcceleratedNetworking, bool? enableIPForwarding, IList<string> hostedWorkloads, string resourceGuid, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
internal NetworkInterface(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, SubResource virtualMachine, NetworkSecurityGroup networkSecurityGroup, PrivateEndpoint privateEndpoint, IList<NetworkInterfaceIPConfiguration> ipConfigurations, IReadOnlyList<NetworkInterfaceTapConfiguration> tapConfigurations, NetworkInterfaceDnsSettings dnsSettings, string macAddress, bool? primary, bool? enableAcceleratedNetworking, bool? enableIPForwarding, IReadOnlyList<string> hostedWorkloads, string resourceGuid, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
{
Etag = etag;
VirtualMachine = virtualMachine;
@ -70,7 +70,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> A list of IPConfigurations of the network interface. </summary>
public IList<NetworkInterfaceIPConfiguration> IpConfigurations { get; }
/// <summary> A list of TapConfigurations of the network interface. </summary>
public IList<NetworkInterfaceTapConfiguration> TapConfigurations { get; }
public IReadOnlyList<NetworkInterfaceTapConfiguration> TapConfigurations { get; }
/// <summary> The DNS settings in network interface. </summary>
public NetworkInterfaceDnsSettings DnsSettings { get; set; }
/// <summary> The MAC address of the network interface. </summary>
@ -82,7 +82,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> Indicates whether IP forwarding is enabled on this network interface. </summary>
public bool? EnableIPForwarding { get; set; }
/// <summary> A list of references to linked BareMetal resources. </summary>
public IList<string> HostedWorkloads { get; }
public IReadOnlyList<string> HostedWorkloads { get; }
/// <summary> The resource GUID property of the network interface resource. </summary>
public string ResourceGuid { get; }
/// <summary> The provisioning state of the network interface resource. </summary>

Просмотреть файл

@ -37,7 +37,7 @@ namespace Azure.Network.Management.Interface.Models
internal static NetworkInterfaceDnsSettings DeserializeNetworkInterfaceDnsSettings(JsonElement element)
{
Optional<IList<string>> dnsServers = default;
Optional<IList<string>> appliedDnsServers = default;
Optional<IReadOnlyList<string>> appliedDnsServers = default;
Optional<string> internalDnsNameLabel = default;
Optional<string> internalFqdn = default;
Optional<string> internalDomainNameSuffix = default;

Просмотреть файл

@ -26,7 +26,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="internalDnsNameLabel"> Relative DNS name for this NIC used for internal communications between VMs in the same virtual network. </param>
/// <param name="internalFqdn"> Fully qualified DNS name supporting internal communications between VMs in the same virtual network. </param>
/// <param name="internalDomainNameSuffix"> Even if internalDnsNameLabel is not specified, a DNS entry is created for the primary NIC of the VM. This DNS name can be constructed by concatenating the VM name with the value of internalDomainNameSuffix. </param>
internal NetworkInterfaceDnsSettings(IList<string> dnsServers, IList<string> appliedDnsServers, string internalDnsNameLabel, string internalFqdn, string internalDomainNameSuffix)
internal NetworkInterfaceDnsSettings(IList<string> dnsServers, IReadOnlyList<string> appliedDnsServers, string internalDnsNameLabel, string internalFqdn, string internalDomainNameSuffix)
{
DnsServers = dnsServers;
AppliedDnsServers = appliedDnsServers;
@ -38,7 +38,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> List of DNS servers IP addresses. Use &apos;AzureProvidedDNS&apos; to switch to azure provided DNS resolution. &apos;AzureProvidedDNS&apos; value cannot be combined with other IPs, it must be the only value in dnsServers collection. </summary>
public IList<string> DnsServers { get; }
/// <summary> If the VM that uses this NIC is part of an Availability Set, then this list will have the union of all DNS servers from all NICs that are part of the Availability Set. This property is what is configured on each of those VMs. </summary>
public IList<string> AppliedDnsServers { get; }
public IReadOnlyList<string> AppliedDnsServers { get; }
/// <summary> Relative DNS name for this NIC used for internal communications between VMs in the same virtual network. </summary>
public string InternalDnsNameLabel { get; set; }
/// <summary> Fully qualified DNS name supporting internal communications between VMs in the same virtual network. </summary>

Просмотреть файл

@ -11,19 +11,13 @@ using Azure.Core;
namespace Azure.Network.Management.Interface.Models
{
public partial class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties : IUtf8JsonSerializable
public partial class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties DeserializeNetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(JsonElement element)
{
Optional<string> groupId = default;
Optional<string> requiredMemberName = default;
Optional<IList<string>> fqdns = default;
Optional<IReadOnlyList<string>> fqdns = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("groupId"))

Просмотреть файл

@ -14,7 +14,7 @@ namespace Azure.Network.Management.Interface.Models
public partial class NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties
{
/// <summary> Initializes a new instance of NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties. </summary>
public NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties()
internal NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties()
{
Fqdns = new ChangeTrackingList<string>();
}
@ -23,7 +23,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="groupId"> The group ID for current private link connection. </param>
/// <param name="requiredMemberName"> The required member name for current private link connection. </param>
/// <param name="fqdns"> List of FQDNs for current private link connection. </param>
internal NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(string groupId, string requiredMemberName, IList<string> fqdns)
internal NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties(string groupId, string requiredMemberName, IReadOnlyList<string> fqdns)
{
GroupId = groupId;
RequiredMemberName = requiredMemberName;
@ -35,6 +35,6 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> The required member name for current private link connection. </summary>
public string RequiredMemberName { get; }
/// <summary> List of FQDNs for current private link connection. </summary>
public IList<string> Fqdns { get; }
public IReadOnlyList<string> Fqdns { get; }
}
}

Просмотреть файл

@ -62,9 +62,9 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> location = default;
Optional<IDictionary<string, string>> tags = default;
Optional<IList<SecurityRule>> securityRules = default;
Optional<IList<SecurityRule>> defaultSecurityRules = default;
Optional<IList<NetworkInterface>> networkInterfaces = default;
Optional<IList<Subnet>> subnets = default;
Optional<IReadOnlyList<SecurityRule>> defaultSecurityRules = default;
Optional<IReadOnlyList<NetworkInterface>> networkInterfaces = default;
Optional<IReadOnlyList<Subnet>> subnets = default;
Optional<string> resourceGuid = default;
Optional<ProvisioningState> provisioningState = default;
foreach (var property in element.EnumerateObject())

Просмотреть файл

@ -35,7 +35,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="subnets"> A collection of references to subnets. </param>
/// <param name="resourceGuid"> The resource GUID property of the network security group resource. </param>
/// <param name="provisioningState"> The provisioning state of the network security group resource. </param>
internal NetworkSecurityGroup(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IList<SecurityRule> securityRules, IList<SecurityRule> defaultSecurityRules, IList<NetworkInterface> networkInterfaces, IList<Subnet> subnets, string resourceGuid, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
internal NetworkSecurityGroup(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IList<SecurityRule> securityRules, IReadOnlyList<SecurityRule> defaultSecurityRules, IReadOnlyList<NetworkInterface> networkInterfaces, IReadOnlyList<Subnet> subnets, string resourceGuid, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
{
Etag = etag;
SecurityRules = securityRules;
@ -51,11 +51,11 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> A collection of security rules of the network security group. </summary>
public IList<SecurityRule> SecurityRules { get; }
/// <summary> The default security rules of network security group. </summary>
public IList<SecurityRule> DefaultSecurityRules { get; }
public IReadOnlyList<SecurityRule> DefaultSecurityRules { get; }
/// <summary> A collection of references to network interfaces. </summary>
public IList<NetworkInterface> NetworkInterfaces { get; }
public IReadOnlyList<NetworkInterface> NetworkInterfaces { get; }
/// <summary> A collection of references to subnets. </summary>
public IList<Subnet> Subnets { get; }
public IReadOnlyList<Subnet> Subnets { get; }
/// <summary> The resource GUID property of the network security group resource. </summary>
public string ResourceGuid { get; }
/// <summary> The provisioning state of the network security group resource. </summary>

Просмотреть файл

@ -77,7 +77,7 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> location = default;
Optional<IDictionary<string, string>> tags = default;
Optional<Subnet> subnet = default;
Optional<IList<NetworkInterface>> networkInterfaces = default;
Optional<IReadOnlyList<NetworkInterface>> networkInterfaces = default;
Optional<ProvisioningState> provisioningState = default;
Optional<IList<PrivateLinkServiceConnection>> privateLinkServiceConnections = default;
Optional<IList<PrivateLinkServiceConnection>> manualPrivateLinkServiceConnections = default;

Просмотреть файл

@ -33,7 +33,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="provisioningState"> The provisioning state of the private endpoint resource. </param>
/// <param name="privateLinkServiceConnections"> A grouping of information about the connection to the remote resource. </param>
/// <param name="manualPrivateLinkServiceConnections"> A grouping of information about the connection to the remote resource. Used when the network admin does not have access to approve connections to the remote resource. </param>
internal PrivateEndpoint(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, Subnet subnet, IList<NetworkInterface> networkInterfaces, ProvisioningState? provisioningState, IList<PrivateLinkServiceConnection> privateLinkServiceConnections, IList<PrivateLinkServiceConnection> manualPrivateLinkServiceConnections) : base(id, name, type, location, tags)
internal PrivateEndpoint(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, Subnet subnet, IReadOnlyList<NetworkInterface> networkInterfaces, ProvisioningState? provisioningState, IList<PrivateLinkServiceConnection> privateLinkServiceConnections, IList<PrivateLinkServiceConnection> manualPrivateLinkServiceConnections) : base(id, name, type, location, tags)
{
Etag = etag;
Subnet = subnet;
@ -48,7 +48,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> The ID of the subnet from which the private IP will be allocated. </summary>
public Subnet Subnet { get; set; }
/// <summary> An array of references to the network interfaces created for this private endpoint. </summary>
public IList<NetworkInterface> NetworkInterfaces { get; }
public IReadOnlyList<NetworkInterface> NetworkInterfaces { get; }
/// <summary> The provisioning state of the private endpoint resource. </summary>
public ProvisioningState? ProvisioningState { get; }
/// <summary> A grouping of information about the connection to the remote resource. </summary>

Просмотреть файл

@ -63,7 +63,7 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> etag = default;
Optional<string> type = default;
Optional<string> id = default;
Optional<IList<SubResource>> loadBalancingRules = default;
Optional<IReadOnlyList<SubResource>> loadBalancingRules = default;
Optional<ProbeProtocol> protocol = default;
Optional<int> port = default;
Optional<int> intervalInSeconds = default;

Просмотреть файл

@ -31,7 +31,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="numberOfProbes"> The number of probes where if no response, will result in stopping further traffic from being delivered to the endpoint. This values allows endpoints to be taken out of rotation faster or slower than the typical times used in Azure. </param>
/// <param name="requestPath"> The URI used for requesting health status from the VM. Path is required if a protocol is set to http. Otherwise, it is not allowed. There is no default value. </param>
/// <param name="provisioningState"> The provisioning state of the probe resource. </param>
internal Probe(string id, string name, string etag, string type, IList<SubResource> loadBalancingRules, ProbeProtocol? protocol, int? port, int? intervalInSeconds, int? numberOfProbes, string requestPath, ProvisioningState? provisioningState) : base(id)
internal Probe(string id, string name, string etag, string type, IReadOnlyList<SubResource> loadBalancingRules, ProbeProtocol? protocol, int? port, int? intervalInSeconds, int? numberOfProbes, string requestPath, ProvisioningState? provisioningState) : base(id)
{
Name = name;
Etag = etag;
@ -52,7 +52,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> Type of the resource. </summary>
public string Type { get; }
/// <summary> The load balancer rules that use this probe. </summary>
public IList<SubResource> LoadBalancingRules { get; }
public IReadOnlyList<SubResource> LoadBalancingRules { get; }
/// <summary> The protocol of the end point. If &apos;Tcp&apos; is specified, a received ACK is required for the probe to be successful. If &apos;Http&apos; or &apos;Https&apos; is specified, a 200 OK response from the specifies URI is required for the probe to be successful. </summary>
public ProbeProtocol? Protocol { get; set; }
/// <summary> The port for communicating the probe. Possible values range from 1 to 65535, inclusive. </summary>

Просмотреть файл

@ -67,7 +67,7 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> location = default;
Optional<IDictionary<string, string>> tags = default;
Optional<IList<Route>> routes = default;
Optional<IList<Subnet>> subnets = default;
Optional<IReadOnlyList<Subnet>> subnets = default;
Optional<bool> disableBgpRoutePropagation = default;
Optional<ProvisioningState> provisioningState = default;
foreach (var property in element.EnumerateObject())

Просмотреть файл

@ -31,7 +31,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="subnets"> A collection of references to subnets. </param>
/// <param name="disableBgpRoutePropagation"> Whether to disable the routes learned by BGP on that route table. True means disable. </param>
/// <param name="provisioningState"> The provisioning state of the route table resource. </param>
internal RouteTable(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IList<Route> routes, IList<Subnet> subnets, bool? disableBgpRoutePropagation, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
internal RouteTable(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IList<Route> routes, IReadOnlyList<Subnet> subnets, bool? disableBgpRoutePropagation, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
{
Etag = etag;
Routes = routes;
@ -45,7 +45,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> Collection of routes contained within a route table. </summary>
public IList<Route> Routes { get; }
/// <summary> A collection of references to subnets. </summary>
public IList<Subnet> Subnets { get; }
public IReadOnlyList<Subnet> Subnets { get; }
/// <summary> Whether to disable the routes learned by BGP on that route table. True means disable. </summary>
public bool? DisableBgpRoutePropagation { get; set; }
/// <summary> The provisioning state of the route table resource. </summary>

Просмотреть файл

@ -62,7 +62,7 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> location = default;
Optional<IDictionary<string, string>> tags = default;
Optional<IList<ServiceEndpointPolicyDefinition>> serviceEndpointPolicyDefinitions = default;
Optional<IList<Subnet>> subnets = default;
Optional<IReadOnlyList<Subnet>> subnets = default;
Optional<string> resourceGuid = default;
Optional<ProvisioningState> provisioningState = default;
foreach (var property in element.EnumerateObject())

Просмотреть файл

@ -31,7 +31,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="subnets"> A collection of references to subnets. </param>
/// <param name="resourceGuid"> The resource GUID property of the service endpoint policy resource. </param>
/// <param name="provisioningState"> The provisioning state of the service endpoint policy resource. </param>
internal ServiceEndpointPolicy(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IList<ServiceEndpointPolicyDefinition> serviceEndpointPolicyDefinitions, IList<Subnet> subnets, string resourceGuid, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
internal ServiceEndpointPolicy(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IList<ServiceEndpointPolicyDefinition> serviceEndpointPolicyDefinitions, IReadOnlyList<Subnet> subnets, string resourceGuid, ProvisioningState? provisioningState) : base(id, name, type, location, tags)
{
Etag = etag;
ServiceEndpointPolicyDefinitions = serviceEndpointPolicyDefinitions;
@ -45,7 +45,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> A collection of service endpoint policy definitions of the service endpoint policy. </summary>
public IList<ServiceEndpointPolicyDefinition> ServiceEndpointPolicyDefinitions { get; }
/// <summary> A collection of references to subnets. </summary>
public IList<Subnet> Subnets { get; }
public IReadOnlyList<Subnet> Subnets { get; }
/// <summary> The resource GUID property of the service endpoint policy resource. </summary>
public string ResourceGuid { get; }
/// <summary> The provisioning state of the service endpoint policy resource. </summary>

Просмотреть файл

@ -114,11 +114,11 @@ namespace Azure.Network.Management.Interface.Models
Optional<SubResource> natGateway = default;
Optional<IList<ServiceEndpointPropertiesFormat>> serviceEndpoints = default;
Optional<IList<ServiceEndpointPolicy>> serviceEndpointPolicies = default;
Optional<IList<PrivateEndpoint>> privateEndpoints = default;
Optional<IList<IPConfiguration>> ipConfigurations = default;
Optional<IList<IPConfigurationProfile>> ipConfigurationProfiles = default;
Optional<IList<ResourceNavigationLink>> resourceNavigationLinks = default;
Optional<IList<ServiceAssociationLink>> serviceAssociationLinks = default;
Optional<IReadOnlyList<PrivateEndpoint>> privateEndpoints = default;
Optional<IReadOnlyList<IPConfiguration>> ipConfigurations = default;
Optional<IReadOnlyList<IPConfigurationProfile>> ipConfigurationProfiles = default;
Optional<IReadOnlyList<ResourceNavigationLink>> resourceNavigationLinks = default;
Optional<IReadOnlyList<ServiceAssociationLink>> serviceAssociationLinks = default;
Optional<IList<Delegation>> delegations = default;
Optional<string> purpose = default;
Optional<ProvisioningState> provisioningState = default;

Просмотреть файл

@ -48,7 +48,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="provisioningState"> The provisioning state of the subnet resource. </param>
/// <param name="privateEndpointNetworkPolicies"> Enable or Disable apply network policies on private end point in the subnet. </param>
/// <param name="privateLinkServiceNetworkPolicies"> Enable or Disable apply network policies on private link service in the subnet. </param>
internal Subnet(string id, string name, string etag, string addressPrefix, IList<string> addressPrefixes, NetworkSecurityGroup networkSecurityGroup, RouteTable routeTable, SubResource natGateway, IList<ServiceEndpointPropertiesFormat> serviceEndpoints, IList<ServiceEndpointPolicy> serviceEndpointPolicies, IList<PrivateEndpoint> privateEndpoints, IList<IPConfiguration> ipConfigurations, IList<IPConfigurationProfile> ipConfigurationProfiles, IList<ResourceNavigationLink> resourceNavigationLinks, IList<ServiceAssociationLink> serviceAssociationLinks, IList<Delegation> delegations, string purpose, ProvisioningState? provisioningState, string privateEndpointNetworkPolicies, string privateLinkServiceNetworkPolicies) : base(id)
internal Subnet(string id, string name, string etag, string addressPrefix, IList<string> addressPrefixes, NetworkSecurityGroup networkSecurityGroup, RouteTable routeTable, SubResource natGateway, IList<ServiceEndpointPropertiesFormat> serviceEndpoints, IList<ServiceEndpointPolicy> serviceEndpointPolicies, IReadOnlyList<PrivateEndpoint> privateEndpoints, IReadOnlyList<IPConfiguration> ipConfigurations, IReadOnlyList<IPConfigurationProfile> ipConfigurationProfiles, IReadOnlyList<ResourceNavigationLink> resourceNavigationLinks, IReadOnlyList<ServiceAssociationLink> serviceAssociationLinks, IList<Delegation> delegations, string purpose, ProvisioningState? provisioningState, string privateEndpointNetworkPolicies, string privateLinkServiceNetworkPolicies) : base(id)
{
Name = name;
Etag = etag;
@ -90,15 +90,15 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> An array of service endpoint policies. </summary>
public IList<ServiceEndpointPolicy> ServiceEndpointPolicies { get; }
/// <summary> An array of references to private endpoints. </summary>
public IList<PrivateEndpoint> PrivateEndpoints { get; }
public IReadOnlyList<PrivateEndpoint> PrivateEndpoints { get; }
/// <summary> An array of references to the network interface IP configurations using subnet. </summary>
public IList<IPConfiguration> IpConfigurations { get; }
public IReadOnlyList<IPConfiguration> IpConfigurations { get; }
/// <summary> Array of IP configuration profiles which reference this subnet. </summary>
public IList<IPConfigurationProfile> IpConfigurationProfiles { get; }
public IReadOnlyList<IPConfigurationProfile> IpConfigurationProfiles { get; }
/// <summary> An array of references to the external resources using subnet. </summary>
public IList<ResourceNavigationLink> ResourceNavigationLinks { get; }
public IReadOnlyList<ResourceNavigationLink> ResourceNavigationLinks { get; }
/// <summary> An array of references to services injecting into this subnet. </summary>
public IList<ServiceAssociationLink> ServiceAssociationLinks { get; }
public IReadOnlyList<ServiceAssociationLink> ServiceAssociationLinks { get; }
/// <summary> An array of references to the delegations on the subnet. </summary>
public IList<Delegation> Delegations { get; }
/// <summary> A read-only string identifying the intention of use for this subnet based on delegations and other user-defined properties. </summary>

Просмотреть файл

@ -66,7 +66,7 @@ namespace Azure.Network.Management.Interface.Models
Optional<string> type = default;
Optional<string> location = default;
Optional<IDictionary<string, string>> tags = default;
Optional<IList<NetworkInterfaceTapConfiguration>> networkInterfaceTapConfigurations = default;
Optional<IReadOnlyList<NetworkInterfaceTapConfiguration>> networkInterfaceTapConfigurations = default;
Optional<string> resourceGuid = default;
Optional<ProvisioningState> provisioningState = default;
Optional<NetworkInterfaceIPConfiguration> destinationNetworkInterfaceIPConfiguration = default;

Просмотреть файл

@ -32,7 +32,7 @@ namespace Azure.Network.Management.Interface.Models
/// <param name="destinationNetworkInterfaceIPConfiguration"> The reference to the private IP Address of the collector nic that will receive the tap. </param>
/// <param name="destinationLoadBalancerFrontEndIPConfiguration"> The reference to the private IP address on the internal Load Balancer that will receive the tap. </param>
/// <param name="destinationPort"> The VXLAN destination port that will receive the tapped traffic. </param>
internal VirtualNetworkTap(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IList<NetworkInterfaceTapConfiguration> networkInterfaceTapConfigurations, string resourceGuid, ProvisioningState? provisioningState, NetworkInterfaceIPConfiguration destinationNetworkInterfaceIPConfiguration, FrontendIPConfiguration destinationLoadBalancerFrontEndIPConfiguration, int? destinationPort) : base(id, name, type, location, tags)
internal VirtualNetworkTap(string id, string name, string type, string location, IDictionary<string, string> tags, string etag, IReadOnlyList<NetworkInterfaceTapConfiguration> networkInterfaceTapConfigurations, string resourceGuid, ProvisioningState? provisioningState, NetworkInterfaceIPConfiguration destinationNetworkInterfaceIPConfiguration, FrontendIPConfiguration destinationLoadBalancerFrontEndIPConfiguration, int? destinationPort) : base(id, name, type, location, tags)
{
Etag = etag;
NetworkInterfaceTapConfigurations = networkInterfaceTapConfigurations;
@ -46,7 +46,7 @@ namespace Azure.Network.Management.Interface.Models
/// <summary> A unique read-only string that changes whenever the resource is updated. </summary>
public string Etag { get; }
/// <summary> Specifies the list of resource IDs for the network interface IP configuration that needs to be tapped. </summary>
public IList<NetworkInterfaceTapConfiguration> NetworkInterfaceTapConfigurations { get; }
public IReadOnlyList<NetworkInterfaceTapConfiguration> NetworkInterfaceTapConfigurations { get; }
/// <summary> The resource GUID property of the virtual network tap resource. </summary>
public string ResourceGuid { get; }
/// <summary> The provisioning state of the virtual network tap resource. </summary>

Просмотреть файл

@ -109,13 +109,6 @@ namespace AutoRest.CSharp.V3.Input
Parents = new Relations();
Children = new Relations();
}
public bool IsInput => Usage.Contains(SchemaContext.Input);
public bool IsOutput => Usage.Contains(SchemaContext.Output);
public bool IsException => Usage.Contains(SchemaContext.Exception);
public bool IsInputOnly => IsInput && !IsOutput && !IsException;
public bool IsOutputOnly => IsOutput && !IsInput && !IsException;
public bool IsExceptionOnly => IsException && !IsInput && !IsOutput;
}
// redefined manually to inherit from ObjectSchema

Просмотреть файл

@ -0,0 +1,121 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
namespace AutoRest.CSharp.V3.Input
{
internal class SchemaUsageProvider
{
private readonly Dictionary<Schema, SchemaTypeUsage> _usages = new Dictionary<Schema, SchemaTypeUsage>();
public SchemaUsageProvider(CodeModel codeModel)
{
foreach (var operationGroup in codeModel.OperationGroups)
{
foreach (var operation in operationGroup.Operations)
{
foreach (var operationResponse in operation.Responses)
{
Apply(operationResponse.ResponseSchema, SchemaTypeUsage.Model | SchemaTypeUsage.Output);
}
foreach (var operationResponse in operation.Exceptions)
{
Apply(operationResponse.ResponseSchema, SchemaTypeUsage.Error | SchemaTypeUsage.Output);
}
foreach (var serviceRequest in operation.Requests)
{
foreach (var parameter in serviceRequest.Parameters)
{
if (parameter.Flattened == true)
{
Apply(parameter.Schema, SchemaTypeUsage.FattenedParameters | SchemaTypeUsage.Input, recurse: false);
}
else
{
Apply(parameter.Schema, SchemaTypeUsage.Model | SchemaTypeUsage.Input);
}
}
}
}
}
}
private void Apply(Schema? schema, SchemaTypeUsage usage, bool recurse = true)
{
if (schema == null)
{
return;
}
_usages.TryGetValue(schema, out var currentUsage);
var newUsage = currentUsage | usage;
if (newUsage == currentUsage)
{
return;
}
_usages[schema] = newUsage;
if (!recurse)
{
return;
}
if (schema is ObjectSchema objectSchema)
{
foreach (var parent in objectSchema.Parents!.All)
{
Apply(parent, usage);
}
foreach (var child in objectSchema.Children!.All)
{
Apply(child, usage);
}
foreach (var schemaProperty in objectSchema.Properties)
{
var propertyUsage = usage;
if (schemaProperty.IsReadOnly)
{
propertyUsage &= ~SchemaTypeUsage.Input;
}
Apply(schemaProperty.Schema, propertyUsage);
}
}
else if (schema is DictionarySchema dictionarySchema)
{
Apply(dictionarySchema.ElementType, usage);
}
else if (schema is ArraySchema arraySchema)
{
Apply(arraySchema.ElementType, usage);
}
}
public SchemaTypeUsage GetUsage(ObjectSchema schema)
{
_usages.TryGetValue(schema, out var usage);
return usage;
}
}
[Flags]
internal enum SchemaTypeUsage
{
None = 0,
Input = 1,
Output = Input << 1,
Model = Output << 1,
Error = Model << 1,
FattenedParameters = Error << 1,
}
}

Просмотреть файл

@ -16,11 +16,13 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
public BuildContext(CodeModel codeModel, Configuration configuration, SourceInputModel sourceInputModel)
{
CodeModel = codeModel;
SchemaUsageProvider = new SchemaUsageProvider(codeModel);
Configuration = configuration;
SourceInputModel = sourceInputModel;
}
public CodeModel CodeModel { get; }
public SchemaUsageProvider SchemaUsageProvider { get; }
public OutputLibrary Library => _library ??= new OutputLibrary(CodeModel, this);
public string DefaultNamespace => Configuration.Namespace;
public TypeFactory TypeFactory => _typeFactory ??= new TypeFactory(Library);

Просмотреть файл

@ -23,6 +23,7 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
private readonly ObjectSchema _objectSchema;
private readonly SerializationBuilder _serializationBuilder;
private readonly TypeFactory _typeFactory;
private readonly SchemaTypeUsage _usage;
private ObjectTypeProperty[]? _properties;
private ObjectTypeDiscriminator? _discriminator;
@ -40,8 +41,10 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
_objectSchema = objectSchema;
_typeFactory = context.TypeFactory;
_serializationBuilder = new SerializationBuilder();
_usage = context.SchemaUsageProvider.GetUsage(_objectSchema);
var hasUsage = _usage.HasFlag(SchemaTypeUsage.Model);
var hasUsage = objectSchema.Usage.Any() && !objectSchema.IsExceptionOnly;
DefaultAccessibility = objectSchema.Extensions?.Accessibility ?? (hasUsage ? "public" : "internal");
Description = BuilderHelpers.CreateDescription(objectSchema);
DefaultName = objectSchema.CSharpName();
@ -94,7 +97,7 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
{
yield return InitializationConstructor;
if (_objectSchema.IsInputOnly)
if (!IncludeDeserializer)
{
yield break;
}
@ -255,7 +258,7 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
Type.Name,
Type,
// inputs have public ctor by default
_objectSchema.IsInput ? "public" : "internal",
_usage.HasFlag(SchemaTypeUsage.Input) ? "public" : "internal",
null,
_typeFactory),
defaultCtorParameters.ToArray(),
@ -268,8 +271,8 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
public CSharpType? ImplementsDictionaryType => _implementsDictionaryType ??= CreateInheritedDictionaryType();
public bool IncludeSerializer => _objectSchema.IsInput;
public bool IncludeDeserializer => _objectSchema.IsOutput || _objectSchema.IsException;
public bool IncludeSerializer => _usage.HasFlag(SchemaTypeUsage.Input);
public bool IncludeDeserializer => _usage.HasFlag(SchemaTypeUsage.Output);
public ObjectTypeProperty GetPropertyForSchemaProperty(Property property, bool includeParents = false)
{
@ -440,7 +443,7 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
bool isCollection = TypeFactory.IsCollectionType(type);
bool isReadOnly = IsStruct ||
!objectSchema.IsInput ||
!_usage.HasFlag(SchemaTypeUsage.Input) ||
property.IsReadOnly;
if (isCollection)
@ -449,7 +452,10 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
}
else
{
isReadOnly |= property.IsRequired && objectSchema.IsInputOnly;
// In mixed models required properties are not readonly
isReadOnly |= property.IsRequired &&
_usage.HasFlag(SchemaTypeUsage.Input) &&
!_usage.HasFlag(SchemaTypeUsage.Output);
}
if (property.IsDiscriminator == true)
@ -478,7 +484,8 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
{
var valueType = _typeFactory.CreateType(property.Schema, property.IsNullable);
if (!_objectSchema.IsInput)
if (!_usage.HasFlag(SchemaTypeUsage.Input) ||
property.IsReadOnly)
{
valueType = TypeFactory.GetOutputType(valueType);
}
@ -543,7 +550,7 @@ namespace AutoRest.CSharp.V3.Output.Models.Types
if (complexSchema is DictionarySchema dictionarySchema)
{
return new CSharpType(
_objectSchema.IsInput ? typeof(IDictionary<,>) : typeof(IReadOnlyDictionary<,>),
_usage.HasFlag(SchemaTypeUsage.Input) ? typeof(IDictionary<,>) : typeof(IReadOnlyDictionary<,>),
typeof(string),
_typeFactory.CreateType(dictionarySchema.ElementType, false));
};

Просмотреть файл

@ -8,12 +8,19 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Azure.Core.Pipeline
{
internal static class TaskExtensions
{
public static WithCancellationTaskAwaitable<T> AwaitWithCancellation<T>(this Task<T> task, CancellationToken cancellationToken)
=> new WithCancellationTaskAwaitable<T>(task, cancellationToken);
public static WithCancellationValueTaskAwaitable<T> AwaitWithCancellation<T>(this ValueTask<T> task, CancellationToken cancellationToken)
=> new WithCancellationValueTaskAwaitable<T>(task, cancellationToken);
public static T EnsureCompleted<T>(this Task<T> task)
{
#if DEBUG
@ -133,5 +140,125 @@ namespace Azure.Core.Pipeline
public void Dispose() => _asyncEnumerator.DisposeAsync().EnsureCompleted();
#pragma warning restore AZC0107 // Do not call public asynchronous method in synchronous scope.
}
public readonly struct WithCancellationTaskAwaitable<T>
{
private readonly CancellationToken _cancellationToken;
private readonly ConfiguredTaskAwaitable<T> _awaitable;
public WithCancellationTaskAwaitable(Task<T> task, CancellationToken cancellationToken)
{
_awaitable = task.ConfigureAwait(false);
_cancellationToken = cancellationToken;
}
public WithCancellationTaskAwaiter<T> GetAwaiter() => new WithCancellationTaskAwaiter<T>(_awaitable.GetAwaiter(), _cancellationToken);
}
public readonly struct WithCancellationValueTaskAwaitable<T>
{
private readonly CancellationToken _cancellationToken;
private readonly ConfiguredValueTaskAwaitable<T> _awaitable;
public WithCancellationValueTaskAwaitable(ValueTask<T> task, CancellationToken cancellationToken)
{
_awaitable = task.ConfigureAwait(false);
_cancellationToken = cancellationToken;
}
public WithCancellationValueTaskAwaiter<T> GetAwaiter() => new WithCancellationValueTaskAwaiter<T>(_awaitable.GetAwaiter(), _cancellationToken);
}
public readonly struct WithCancellationTaskAwaiter<T> : ICriticalNotifyCompletion
{
private readonly CancellationToken _cancellationToken;
private readonly ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter _taskAwaiter;
public WithCancellationTaskAwaiter(ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter awaiter, CancellationToken cancellationToken)
{
_taskAwaiter = awaiter;
_cancellationToken = cancellationToken;
}
public bool IsCompleted => _taskAwaiter.IsCompleted || _cancellationToken.IsCancellationRequested;
public void OnCompleted(Action continuation) => _taskAwaiter.OnCompleted(WrapContinuation(continuation));
public void UnsafeOnCompleted(Action continuation) => _taskAwaiter.UnsafeOnCompleted(WrapContinuation(continuation));
public T GetResult()
{
Debug.Assert(IsCompleted);
if (!_taskAwaiter.IsCompleted)
{
_cancellationToken.ThrowIfCancellationRequested();
}
return _taskAwaiter.GetResult();
}
private Action WrapContinuation(in Action originalContinuation)
=> _cancellationToken.CanBeCanceled
? new WithCancellationContinuationWrapper(originalContinuation, _cancellationToken).Continuation
: originalContinuation;
}
public readonly struct WithCancellationValueTaskAwaiter<T> : ICriticalNotifyCompletion
{
private readonly CancellationToken _cancellationToken;
private readonly ConfiguredValueTaskAwaitable<T>.ConfiguredValueTaskAwaiter _taskAwaiter;
public WithCancellationValueTaskAwaiter(ConfiguredValueTaskAwaitable<T>.ConfiguredValueTaskAwaiter awaiter, CancellationToken cancellationToken)
{
_taskAwaiter = awaiter;
_cancellationToken = cancellationToken;
}
public bool IsCompleted => _taskAwaiter.IsCompleted || _cancellationToken.IsCancellationRequested;
public void OnCompleted(Action continuation) => _taskAwaiter.OnCompleted(WrapContinuation(continuation));
public void UnsafeOnCompleted(Action continuation) => _taskAwaiter.UnsafeOnCompleted(WrapContinuation(continuation));
public T GetResult()
{
Debug.Assert(IsCompleted);
if (!_taskAwaiter.IsCompleted)
{
_cancellationToken.ThrowIfCancellationRequested();
}
return _taskAwaiter.GetResult();
}
private Action WrapContinuation(in Action originalContinuation)
=> _cancellationToken.CanBeCanceled
? new WithCancellationContinuationWrapper(originalContinuation, _cancellationToken).Continuation
: originalContinuation;
}
private class WithCancellationContinuationWrapper
{
private Action _originalContinuation;
private readonly CancellationTokenRegistration _registration;
public WithCancellationContinuationWrapper(Action originalContinuation, CancellationToken cancellationToken)
{
Action continuation = ContinuationImplementation;
_originalContinuation = originalContinuation;
_registration = cancellationToken.Register(continuation);
Continuation = continuation;
}
public Action Continuation { get; }
private void ContinuationImplementation()
{
Action originalContinuation = Interlocked.Exchange(ref _originalContinuation, null);
if (originalContinuation != null)
{
_registration.Dispose();
originalContinuation();
}
}
}
}
}

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
@ -398,5 +399,39 @@ namespace AutoRest.TestServer.Tests
Assert.AreEqual(1, inputModel.RequiredIntList.Count);
}
[Test]
public void ErrorModelsAreInternalWithDeserializers()
{
Assert.False(typeof(ErrorModel).IsPublic);
Assert.NotNull(typeof(ErrorModel).GetMethod("DeserializeErrorModel", BindingFlags.Static | BindingFlags.NonPublic));
}
[Test]
public void ReadOnlyPropertyTypesOfMixedModelIsOutputOnly()
{
Assert.True(typeof(ReadonlyModel).IsPublic);
Assert.False(typeof(IUtf8JsonSerializable).IsAssignableFrom(typeof(ReadonlyModel)));
Assert.NotNull(typeof(ReadonlyModel).GetMethod("DeserializeReadonlyModel", BindingFlags.Static | BindingFlags.NonPublic));
}
[Test]
public void ReadOnlyPropertiesAreReadOnly()
{
var property = TypeAsserts.HasProperty(typeof(MixedModelWithReadonlyProperty), "ReadonlyProperty", BindingFlags.Public | BindingFlags.Instance);
var listProperty = TypeAsserts.HasProperty(typeof(MixedModelWithReadonlyProperty), "ReadonlyListProperty", BindingFlags.Public | BindingFlags.Instance);
Assert.Null(property.SetMethod);
Assert.Null(listProperty.SetMethod);
Assert.AreEqual(typeof(IReadOnlyList<ReadonlyModel>), listProperty.PropertyType);
}
[Test]
public void ModelsFlattenedIntoParametersAreInternal()
{
Assert.False(typeof(ParametersModel).IsPublic);
Assert.False(typeof(IUtf8JsonSerializable).IsAssignableFrom(typeof(ReadonlyModel)));
Assert.Null(typeof(ReadonlyModel).GetMethod("DeserializeParametersModel", BindingFlags.Static | BindingFlags.NonPublic));
}
}
}
}

175
test/TestProjects/Inheritance/CodeModel.yaml сгенерированный
Просмотреть файл

@ -4,6 +4,13 @@ info: !<!Info>
title: Schema mapping
schemas: !<!Schemas>
strings:
- !<!StringSchema> &ref_0
type: string
language: !<!Languages>
default:
name: String
description: simple string
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_16
type: string
apiVersions:
@ -74,13 +81,6 @@ schemas: !<!Schemas>
name: ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAPropertyBaseClassProperty
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_0
type: string
language: !<!Languages>
default:
name: String
description: simple string
protocol: !<!Protocols> {}
choices:
- !<!ChoiceSchema> &ref_25
choices:
@ -131,6 +131,17 @@ schemas: !<!Schemas>
name: BaseClassWithEnumDiscriminatorEnum
description: ''
protocol: !<!Protocols> {}
constants:
- !<!ConstantSchema> &ref_28
type: constant
value: !<!ConstantValue>
value: application/json
valueType: *ref_0
language: !<!Languages>
default:
name: ApplicationJson
description: Content Type 'application/json'
protocol: !<!Protocols> {}
objects:
- !<!ObjectSchema> &ref_2
type: object
@ -158,6 +169,11 @@ schemas: !<!Schemas>
- *ref_2
immediate:
- *ref_1
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromBaseClassWithDiscriminator
@ -192,6 +208,11 @@ schemas: !<!Schemas>
immediate:
- *ref_2
- *ref_3
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromBaseClassAndSomeProperties
@ -210,6 +231,11 @@ schemas: !<!Schemas>
immediate:
- *ref_2
- *ref_3
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride
@ -236,6 +262,11 @@ schemas: !<!Schemas>
- *ref_2
immediate:
- *ref_5
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty
@ -251,6 +282,11 @@ schemas: !<!Schemas>
immediate:
- *ref_3
- *ref_2
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromSomePropertiesAndBaseClass
@ -280,6 +316,11 @@ schemas: !<!Schemas>
name: someOtherProperty
description: ''
protocol: !<!Protocols> {}
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: SomeProperties
@ -290,6 +331,11 @@ schemas: !<!Schemas>
immediate:
- *ref_1
- *ref_3
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties
@ -324,6 +370,11 @@ schemas: !<!Schemas>
- *ref_2
properties:
- *ref_13
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: BaseClassWithDiscriminator
@ -342,6 +393,11 @@ schemas: !<!Schemas>
- *ref_2
immediate:
- *ref_2
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromBaseClass
@ -360,6 +416,11 @@ schemas: !<!Schemas>
- *ref_2
immediate:
- *ref_2
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ClassThatInheritsFromBaseClassAndRedefinesAProperty
@ -384,6 +445,11 @@ schemas: !<!Schemas>
name: baseClassProperty
description: ''
protocol: !<!Protocols> {}
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: BaseClass
@ -547,7 +613,100 @@ schemas: !<!Schemas>
protocol: !<!Protocols> {}
- *ref_23
- *ref_24
operationGroups: []
globalParameters:
- !<!Parameter> &ref_27
schema: *ref_0
clientDefaultValue: 'http://localhost:3000'
implementation: Client
origin: 'modelerfour:synthesized/host'
required: true
extensions:
x-ms-skip-url-encoding: true
language: !<!Languages>
default:
name: $host
description: server parameter
serializedName: $host
protocol: !<!Protocols>
http: !<!HttpParameter>
in: uri
operationGroups:
- !<!OperationGroup>
$key: ''
operations:
- !<!Operation>
apiVersions:
- !<!ApiVersion>
version: 1.0.0
parameters:
- *ref_27
requests:
- !<!Request>
parameters:
- !<!Parameter>
schema: *ref_28
implementation: Method
origin: 'modelerfour:synthesized/content-type'
required: true
language: !<!Languages>
default:
name: contentType
description: Body Parameter content-type
serializedName: Content-Type
protocol: !<!Protocols>
http: !<!HttpParameter>
in: header
- !<!Parameter> &ref_29
schema: *ref_2
implementation: Method
required: true
language: !<!Languages>
default:
name: value
description: ''
protocol: !<!Protocols>
http: !<!HttpParameter>
in: body
style: json
signatureParameters:
- *ref_29
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols>
http: !<!HttpWithBodyRequest>
path: /op
method: put
knownMediaType: json
mediaTypes:
- application/json
uri: '{$host}'
signatureParameters: []
responses:
- !<!SchemaResponse>
schema: *ref_2
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols>
http: !<!HttpResponse>
knownMediaType: json
mediaTypes:
- application/json
statusCodes:
- '200'
language: !<!Languages>
default:
name: Mixed
description: ''
protocol: !<!Protocols> {}
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols> {}
security: !<!Security>
authenticationRequired: false
language: !<!Languages>

Просмотреть файл

@ -15,12 +15,5 @@ namespace Inheritance.Models
{
DiscriminatorProperty = new BaseClassWithEntensibleEnumDiscriminatorEnum("random value");
}
/// <summary> Initializes a new instance of AnotherDerivedClassWithExtensibleEnumDiscriminator. </summary>
/// <param name="discriminatorProperty"> . </param>
internal AnotherDerivedClassWithExtensibleEnumDiscriminator(BaseClassWithEntensibleEnumDiscriminatorEnum discriminatorProperty) : base(discriminatorProperty)
{
DiscriminatorProperty = discriminatorProperty;
}
}
}

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class BaseClass : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
writer.WriteEndObject();
}
internal static BaseClass DeserializeBaseClass(JsonElement element)
{
Optional<string> baseClassProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
}
return new BaseClass(baseClassProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The BaseClass. </summary>
internal partial class BaseClass
public partial class BaseClass
{
/// <summary> Initializes a new instance of BaseClass. </summary>
internal BaseClass()
public BaseClass()
{
}
@ -22,6 +22,6 @@ namespace Inheritance.Models
BaseClassProperty = baseClassProperty;
}
public string BaseClassProperty { get; }
public string BaseClassProperty { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class BaseClassWithDiscriminator : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WritePropertyName("DiscriminatorProperty");
writer.WriteStringValue(DiscriminatorProperty);
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
writer.WriteEndObject();
}
internal static BaseClassWithDiscriminator DeserializeBaseClassWithDiscriminator(JsonElement element)
{
if (element.TryGetProperty("DiscriminatorProperty", out JsonElement discriminator))
{
switch (discriminator.GetString())
{
case "ClassThatInheritsFromBaseClassWithDiscriminator": return ClassThatInheritsFromBaseClassWithDiscriminator.DeserializeClassThatInheritsFromBaseClassWithDiscriminator(element);
case "ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties": return ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties.DeserializeClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties(element);
}
}
string discriminatorProperty = default;
Optional<string> baseClassProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("DiscriminatorProperty"))
{
discriminatorProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
}
return new BaseClassWithDiscriminator(baseClassProperty.Value, discriminatorProperty);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The BaseClassWithDiscriminator. </summary>
internal partial class BaseClassWithDiscriminator : BaseClass
public partial class BaseClassWithDiscriminator : BaseClass
{
/// <summary> Initializes a new instance of BaseClassWithDiscriminator. </summary>
internal BaseClassWithDiscriminator()
public BaseClassWithDiscriminator()
{
DiscriminatorProperty = "BaseClassWithDiscriminator";
}

Просмотреть файл

@ -15,13 +15,6 @@ namespace Inheritance.Models
{
}
/// <summary> Initializes a new instance of BaseClassWithEnumDiscriminator. </summary>
/// <param name="discriminatorProperty"> . </param>
internal BaseClassWithEnumDiscriminator(BaseClassWithEnumDiscriminatorEnum discriminatorProperty)
{
DiscriminatorProperty = discriminatorProperty;
}
internal BaseClassWithEnumDiscriminatorEnum DiscriminatorProperty { get; set; }
}
}

Просмотреть файл

@ -15,13 +15,6 @@ namespace Inheritance.Models
{
}
/// <summary> Initializes a new instance of BaseClassWithExtensibleEnumDiscriminator. </summary>
/// <param name="discriminatorProperty"> . </param>
internal BaseClassWithExtensibleEnumDiscriminator(BaseClassWithEntensibleEnumDiscriminatorEnum discriminatorProperty)
{
DiscriminatorProperty = discriminatorProperty;
}
internal BaseClassWithEntensibleEnumDiscriminatorEnum DiscriminatorProperty { get; set; }
}
}

Просмотреть файл

@ -15,13 +15,6 @@ namespace Inheritance.Models
{
}
/// <summary> Initializes a new instance of ClassThatAlsoDefinesBaseClassProperty. </summary>
/// <param name="baseClassProperty"> . </param>
internal ClassThatAlsoDefinesBaseClassProperty(string baseClassProperty)
{
BaseClassProperty = baseClassProperty;
}
public string BaseClassProperty { get; }
}
}

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class ClassThatInheritsFromBaseClass : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromBaseClass DeserializeClassThatInheritsFromBaseClass(JsonElement element)
{
Optional<string> baseClassProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromBaseClass(baseClassProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The ClassThatInheritsFromBaseClass. </summary>
internal partial class ClassThatInheritsFromBaseClass : BaseClass
public partial class ClassThatInheritsFromBaseClass : BaseClass
{
/// <summary> Initializes a new instance of ClassThatInheritsFromBaseClass. </summary>
internal ClassThatInheritsFromBaseClass()
public ClassThatInheritsFromBaseClass()
{
}

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class ClassThatInheritsFromBaseClassAndRedefinesAProperty : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromBaseClassAndRedefinesAProperty DeserializeClassThatInheritsFromBaseClassAndRedefinesAProperty(JsonElement element)
{
Optional<string> baseClassProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromBaseClassAndRedefinesAProperty(baseClassProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The ClassThatInheritsFromBaseClassAndRedefinesAProperty. </summary>
internal partial class ClassThatInheritsFromBaseClassAndRedefinesAProperty : BaseClass
public partial class ClassThatInheritsFromBaseClassAndRedefinesAProperty : BaseClass
{
/// <summary> Initializes a new instance of ClassThatInheritsFromBaseClassAndRedefinesAProperty. </summary>
internal ClassThatInheritsFromBaseClassAndRedefinesAProperty()
public ClassThatInheritsFromBaseClassAndRedefinesAProperty()
{
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class ClassThatInheritsFromBaseClassAndSomeProperties : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(SomeProperty))
{
writer.WritePropertyName("SomeProperty");
writer.WriteStringValue(SomeProperty);
}
if (Optional.IsDefined(SomeOtherProperty))
{
writer.WritePropertyName("SomeOtherProperty");
writer.WriteStringValue(SomeOtherProperty);
}
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromBaseClassAndSomeProperties DeserializeClassThatInheritsFromBaseClassAndSomeProperties(JsonElement element)
{
Optional<string> someProperty = default;
Optional<string> someOtherProperty = default;
Optional<string> baseClassProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("SomeProperty"))
{
someProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeOtherProperty"))
{
someOtherProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromBaseClassAndSomeProperties(baseClassProperty.Value, someProperty.Value, someOtherProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The ClassThatInheritsFromBaseClassAndSomeProperties. </summary>
internal partial class ClassThatInheritsFromBaseClassAndSomeProperties : BaseClass
public partial class ClassThatInheritsFromBaseClassAndSomeProperties : BaseClass
{
/// <summary> Initializes a new instance of ClassThatInheritsFromBaseClassAndSomeProperties. </summary>
internal ClassThatInheritsFromBaseClassAndSomeProperties()
public ClassThatInheritsFromBaseClassAndSomeProperties()
{
}
@ -25,7 +25,7 @@ namespace Inheritance.Models
SomeOtherProperty = someOtherProperty;
}
public string SomeProperty { get; }
public string SomeOtherProperty { get; }
public string SomeProperty { get; set; }
public string SomeOtherProperty { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
internal partial class ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
if (Optional.IsDefined(SomeProperty))
{
writer.WritePropertyName("SomeProperty");
writer.WriteStringValue(SomeProperty);
}
if (Optional.IsDefined(SomeOtherProperty))
{
writer.WritePropertyName("SomeOtherProperty");
writer.WriteStringValue(SomeOtherProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride DeserializeClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride(JsonElement element)
{
Optional<string> baseClassProperty = default;
Optional<string> someProperty = default;
Optional<string> someOtherProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeProperty"))
{
someProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeOtherProperty"))
{
someOtherProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride(someProperty.Value, someOtherProperty.Value, baseClassProperty.Value);
}
}
}

Просмотреть файл

@ -11,7 +11,7 @@ namespace Inheritance.Models
internal partial class ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride : SomeProperties
{
/// <summary> Initializes a new instance of ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride. </summary>
internal ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride()
public ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride()
{
}
@ -24,6 +24,6 @@ namespace Inheritance.Models
BaseClassProperty = baseClassProperty;
}
public string BaseClassProperty { get; }
public string BaseClassProperty { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,48 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class ClassThatInheritsFromBaseClassWithDiscriminator : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WritePropertyName("DiscriminatorProperty");
writer.WriteStringValue(DiscriminatorProperty);
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromBaseClassWithDiscriminator DeserializeClassThatInheritsFromBaseClassWithDiscriminator(JsonElement element)
{
string discriminatorProperty = default;
Optional<string> baseClassProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("DiscriminatorProperty"))
{
discriminatorProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromBaseClassWithDiscriminator(baseClassProperty.Value, discriminatorProperty);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The ClassThatInheritsFromBaseClassWithDiscriminator. </summary>
internal partial class ClassThatInheritsFromBaseClassWithDiscriminator : BaseClassWithDiscriminator
public partial class ClassThatInheritsFromBaseClassWithDiscriminator : BaseClassWithDiscriminator
{
/// <summary> Initializes a new instance of ClassThatInheritsFromBaseClassWithDiscriminator. </summary>
internal ClassThatInheritsFromBaseClassWithDiscriminator()
public ClassThatInheritsFromBaseClassWithDiscriminator()
{
DiscriminatorProperty = "ClassThatInheritsFromBaseClassWithDiscriminator";
}

Просмотреть файл

@ -0,0 +1,70 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(SomeProperty))
{
writer.WritePropertyName("SomeProperty");
writer.WriteStringValue(SomeProperty);
}
if (Optional.IsDefined(SomeOtherProperty))
{
writer.WritePropertyName("SomeOtherProperty");
writer.WriteStringValue(SomeOtherProperty);
}
writer.WritePropertyName("DiscriminatorProperty");
writer.WriteStringValue(DiscriminatorProperty);
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties DeserializeClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties(JsonElement element)
{
Optional<string> someProperty = default;
Optional<string> someOtherProperty = default;
string discriminatorProperty = default;
Optional<string> baseClassProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("SomeProperty"))
{
someProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeOtherProperty"))
{
someOtherProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("DiscriminatorProperty"))
{
discriminatorProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties(baseClassProperty.Value, discriminatorProperty, someProperty.Value, someOtherProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties. </summary>
internal partial class ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties : BaseClassWithDiscriminator
public partial class ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties : BaseClassWithDiscriminator
{
/// <summary> Initializes a new instance of ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties. </summary>
internal ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties()
public ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties()
{
DiscriminatorProperty = "ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties";
}
@ -28,7 +28,7 @@ namespace Inheritance.Models
DiscriminatorProperty = discriminatorProperty ?? "ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties";
}
public string SomeProperty { get; }
public string SomeOtherProperty { get; }
public string SomeProperty { get; set; }
public string SomeOtherProperty { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class ClassThatInheritsFromSomePropertiesAndBaseClass : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
if (Optional.IsDefined(SomeProperty))
{
writer.WritePropertyName("SomeProperty");
writer.WriteStringValue(SomeProperty);
}
if (Optional.IsDefined(SomeOtherProperty))
{
writer.WritePropertyName("SomeOtherProperty");
writer.WriteStringValue(SomeOtherProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromSomePropertiesAndBaseClass DeserializeClassThatInheritsFromSomePropertiesAndBaseClass(JsonElement element)
{
Optional<string> baseClassProperty = default;
Optional<string> someProperty = default;
Optional<string> someOtherProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeProperty"))
{
someProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeOtherProperty"))
{
someOtherProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromSomePropertiesAndBaseClass(someProperty.Value, someOtherProperty.Value, baseClassProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The ClassThatInheritsFromSomePropertiesAndBaseClass. </summary>
internal partial class ClassThatInheritsFromSomePropertiesAndBaseClass : SomeProperties
public partial class ClassThatInheritsFromSomePropertiesAndBaseClass : SomeProperties
{
/// <summary> Initializes a new instance of ClassThatInheritsFromSomePropertiesAndBaseClass. </summary>
internal ClassThatInheritsFromSomePropertiesAndBaseClass()
public ClassThatInheritsFromSomePropertiesAndBaseClass()
{
}
@ -24,6 +24,6 @@ namespace Inheritance.Models
BaseClassProperty = baseClassProperty;
}
public string BaseClassProperty { get; }
public string BaseClassProperty { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(BaseClassProperty))
{
writer.WritePropertyName("BaseClassProperty");
writer.WriteStringValue(BaseClassProperty);
}
if (Optional.IsDefined(SomeProperty))
{
writer.WritePropertyName("SomeProperty");
writer.WriteStringValue(SomeProperty);
}
if (Optional.IsDefined(SomeOtherProperty))
{
writer.WritePropertyName("SomeOtherProperty");
writer.WriteStringValue(SomeOtherProperty);
}
writer.WriteEndObject();
}
internal static ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty DeserializeClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty(JsonElement element)
{
Optional<string> baseClassProperty = default;
Optional<string> someProperty = default;
Optional<string> someOtherProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("BaseClassProperty"))
{
baseClassProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeProperty"))
{
someProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeOtherProperty"))
{
someOtherProperty = property.Value.GetString();
continue;
}
}
return new ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty(someProperty.Value, someOtherProperty.Value, baseClassProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty. </summary>
internal partial class ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty : ClassThatInheritsFromSomePropertiesAndBaseClass
public partial class ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty : ClassThatInheritsFromSomePropertiesAndBaseClass
{
/// <summary> Initializes a new instance of ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty. </summary>
internal ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty()
public ClassThatInheritsFromSomePropertiesAndBaseClassAndRedefinesAProperty()
{
}

Просмотреть файл

@ -15,12 +15,5 @@ namespace Inheritance.Models
{
DiscriminatorProperty = BaseClassWithEnumDiscriminatorEnum.Derived;
}
/// <summary> Initializes a new instance of DerivedClassWithEnumDiscriminator. </summary>
/// <param name="discriminatorProperty"> . </param>
internal DerivedClassWithEnumDiscriminator(BaseClassWithEnumDiscriminatorEnum discriminatorProperty) : base(discriminatorProperty)
{
DiscriminatorProperty = discriminatorProperty;
}
}
}

Просмотреть файл

@ -15,12 +15,5 @@ namespace Inheritance.Models
{
DiscriminatorProperty = BaseClassWithEntensibleEnumDiscriminatorEnum.Derived;
}
/// <summary> Initializes a new instance of DerivedClassWithExtensibleEnumDiscriminator. </summary>
/// <param name="discriminatorProperty"> . </param>
internal DerivedClassWithExtensibleEnumDiscriminator(BaseClassWithEntensibleEnumDiscriminatorEnum discriminatorProperty) : base(discriminatorProperty)
{
DiscriminatorProperty = discriminatorProperty;
}
}
}

Просмотреть файл

@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Inheritance.Models
{
public partial class SomeProperties : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(SomeProperty))
{
writer.WritePropertyName("SomeProperty");
writer.WriteStringValue(SomeProperty);
}
if (Optional.IsDefined(SomeOtherProperty))
{
writer.WritePropertyName("SomeOtherProperty");
writer.WriteStringValue(SomeOtherProperty);
}
writer.WriteEndObject();
}
internal static SomeProperties DeserializeSomeProperties(JsonElement element)
{
Optional<string> someProperty = default;
Optional<string> someOtherProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("SomeProperty"))
{
someProperty = property.Value.GetString();
continue;
}
if (property.NameEquals("SomeOtherProperty"))
{
someOtherProperty = property.Value.GetString();
continue;
}
}
return new SomeProperties(someProperty.Value, someOtherProperty.Value);
}
}
}

Просмотреть файл

@ -8,10 +8,10 @@
namespace Inheritance.Models
{
/// <summary> The SomeProperties. </summary>
internal partial class SomeProperties
public partial class SomeProperties
{
/// <summary> Initializes a new instance of SomeProperties. </summary>
internal SomeProperties()
public SomeProperties()
{
}
@ -24,7 +24,7 @@ namespace Inheritance.Models
SomeOtherProperty = someOtherProperty;
}
public string SomeProperty { get; }
public string SomeOtherProperty { get; }
public string SomeProperty { get; set; }
public string SomeOtherProperty { get; set; }
}
}

72
test/TestProjects/Inheritance/Generated/ServiceClient.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,72 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core.Pipeline;
using Inheritance.Models;
namespace Inheritance
{
/// <summary> The Service service client. </summary>
public partial class ServiceClient
{
private readonly ClientDiagnostics _clientDiagnostics;
private readonly HttpPipeline _pipeline;
internal ServiceRestClient RestClient { get; }
/// <summary> Initializes a new instance of ServiceClient for mocking. </summary>
protected ServiceClient()
{
}
/// <summary> Initializes a new instance of ServiceClient. </summary>
/// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
/// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
/// <param name="endpoint"> server parameter. </param>
internal ServiceClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null)
{
RestClient = new ServiceRestClient(clientDiagnostics, pipeline, endpoint);
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
}
/// <param name="value"> The BaseClass to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async Task<Response<BaseClass>> MixedAsync(BaseClass value, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.Mixed");
scope.Start();
try
{
return await RestClient.MixedAsync(value, cancellationToken).ConfigureAwait(false);
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
/// <param name="value"> The BaseClass to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Response<BaseClass> Mixed(BaseClass value, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ServiceClient.Mixed");
scope.Start();
try
{
return RestClient.Mixed(value, cancellationToken);
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
}
}

106
test/TestProjects/Inheritance/Generated/ServiceRestClient.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,106 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Inheritance.Models;
namespace Inheritance
{
internal partial class ServiceRestClient
{
private Uri endpoint;
private ClientDiagnostics _clientDiagnostics;
private HttpPipeline _pipeline;
/// <summary> Initializes a new instance of ServiceRestClient. </summary>
/// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
/// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
/// <param name="endpoint"> server parameter. </param>
public ServiceRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint = null)
{
endpoint ??= new Uri("http://localhost:3000");
this.endpoint = endpoint;
_clientDiagnostics = clientDiagnostics;
_pipeline = pipeline;
}
internal HttpMessage CreateMixedRequest(BaseClass value)
{
var message = _pipeline.CreateMessage();
var request = message.Request;
request.Method = RequestMethod.Put;
var uri = new RawRequestUriBuilder();
uri.Reset(endpoint);
uri.AppendPath("/op", false);
request.Uri = uri;
request.Headers.Add("Content-Type", "application/json");
var content = new Utf8JsonRequestContent();
content.JsonWriter.WriteObjectValue(value);
request.Content = content;
return message;
}
/// <param name="value"> The BaseClass to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception>
public async Task<Response<BaseClass>> MixedAsync(BaseClass value, CancellationToken cancellationToken = default)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
using var message = CreateMixedRequest(value);
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
switch (message.Response.Status)
{
case 200:
{
BaseClass value0 = default;
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
value0 = BaseClass.DeserializeBaseClass(document.RootElement);
return Response.FromValue(value0, message.Response);
}
default:
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
}
}
/// <param name="value"> The BaseClass to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception>
public Response<BaseClass> Mixed(BaseClass value, CancellationToken cancellationToken = default)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
using var message = CreateMixedRequest(value);
_pipeline.Send(message, cancellationToken);
switch (message.Response.Status)
{
case 200:
{
BaseClass value0 = default;
using var document = JsonDocument.Parse(message.Response.ContentStream);
value0 = BaseClass.DeserializeBaseClass(document.RootElement);
return Response.FromValue(value0, message.Response);
}
default:
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
}
}
}
}

Просмотреть файл

@ -15,7 +15,32 @@
"consumes": [
"application/json"
],
"paths": {},
"paths": {
"/op": {
"put": {
"operationId": "mixed",
"description": "",
"parameters": [
{
"name": "value",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/BaseClass"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/BaseClass"
}
}
}
}
}
},
"definitions": {
"BaseClass": {
"type": "object",

549
test/TestProjects/ModelShapes/CodeModel.yaml сгенерированный
Просмотреть файл

@ -115,7 +115,7 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelRequiredString
name: ErrorModelCode
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_12
@ -125,7 +125,17 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelRequiredStringListItem
name: ErrorModelStatus
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_13
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelRequiredString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_14
@ -135,17 +145,17 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelNonRequiredString
name: MixedModelRequiredStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_15
- !<!StringSchema> &ref_16
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelNonRequiredStringListItem
name: MixedModelNonRequiredString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_17
@ -155,17 +165,17 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelRequiredNullableString
name: MixedModelNonRequiredStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_18
- !<!StringSchema> &ref_19
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelRequiredNullableStringListItem
name: MixedModelRequiredNullableString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_20
@ -175,17 +185,17 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelNonRequiredNullableString
name: MixedModelRequiredNullableStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_21
- !<!StringSchema> &ref_22
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: MixedModelNonRequiredNullableStringListItem
name: MixedModelNonRequiredNullableString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_23
@ -195,17 +205,7 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelRequiredString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_24
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelRequiredStringListItem
name: MixedModelNonRequiredNullableStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_25
@ -215,7 +215,7 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelNonRequiredString
name: OutputModelRequiredString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_26
@ -225,7 +225,7 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelNonRequiredStringListItem
name: OutputModelRequiredStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_27
@ -235,7 +235,7 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelRequiredNullableString
name: OutputModelNonRequiredString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_28
@ -245,7 +245,7 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelRequiredNullableStringListItem
name: OutputModelNonRequiredStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_29
@ -255,7 +255,7 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelNonRequiredNullableString
name: OutputModelRequiredNullableString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_30
@ -265,10 +265,60 @@ schemas: !<!Schemas>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelNonRequiredNullableStringListItem
name: OutputModelRequiredNullableStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_31
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelNonRequiredNullableString
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_32
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: OutputModelNonRequiredNullableStringListItem
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_33
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: ReadonlyModelName
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_35
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: ParametersModelCode
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_36
type: string
apiVersions:
- !<!ApiVersion>
version: 1.0.0
language: !<!Languages>
default:
name: ParametersModelStatus
description: ''
protocol: !<!Protocols> {}
- !<!StringSchema> &ref_37
type: string
apiVersions:
- !<!ApiVersion>
@ -279,7 +329,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
constants:
- !<!ConstantSchema> &ref_45
- !<!ConstantSchema> &ref_52
type: constant
value: !<!ConstantValue>
value: application/json
@ -290,7 +340,7 @@ schemas: !<!Schemas>
description: Content Type 'application/json'
protocol: !<!Protocols> {}
objects:
- !<!ObjectSchema> &ref_46
- !<!ObjectSchema> &ref_53
type: object
apiVersions:
- !<!ApiVersion>
@ -315,7 +365,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_32
schema: !<!ArraySchema> &ref_38
type: array
apiVersions:
- !<!ApiVersion>
@ -334,7 +384,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_13
schema: !<!ArraySchema> &ref_15
type: array
elementType: *ref_4
language: !<!Languages>
@ -368,7 +418,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_33
schema: !<!ArraySchema> &ref_39
type: array
apiVersions:
- !<!ApiVersion>
@ -387,7 +437,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_16
schema: !<!ArraySchema> &ref_18
type: array
elementType: *ref_4
language: !<!Languages>
@ -423,7 +473,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_34
schema: !<!ArraySchema> &ref_40
type: array
apiVersions:
- !<!ApiVersion>
@ -443,7 +493,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_19
schema: !<!ArraySchema> &ref_21
type: array
elementType: *ref_4
language: !<!Languages>
@ -480,7 +530,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_35
schema: !<!ArraySchema> &ref_41
type: array
apiVersions:
- !<!ApiVersion>
@ -500,7 +550,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_22
schema: !<!ArraySchema> &ref_24
type: array
elementType: *ref_4
language: !<!Languages>
@ -526,7 +576,7 @@ schemas: !<!Schemas>
description: ''
namespace: ''
protocol: !<!Protocols> {}
- !<!ObjectSchema> &ref_48
- !<!ObjectSchema> &ref_55
type: object
apiVersions:
- !<!ApiVersion>
@ -534,6 +584,38 @@ schemas: !<!Schemas>
properties:
- !<!Property>
schema: *ref_11
serializedName: Code
language: !<!Languages>
default:
name: code
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_12
serializedName: Status
language: !<!Languages>
default:
name: status
description: ''
protocol: !<!Protocols> {}
serializationFormats:
- json
usage:
- exception
language: !<!Languages>
default:
name: ErrorModel
description: ''
namespace: ''
protocol: !<!Protocols> {}
- !<!ObjectSchema> &ref_56
type: object
apiVersions:
- !<!ApiVersion>
version: 1.0.0
properties:
- !<!Property>
schema: *ref_13
required: true
serializedName: RequiredString
language: !<!Languages>
@ -551,12 +633,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_36
schema: !<!ArraySchema> &ref_42
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_12
elementType: *ref_14
language: !<!Languages>
default:
name: MixedModelRequiredStringList
@ -570,7 +652,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_13
schema: *ref_15
required: true
serializedName: RequiredIntList
language: !<!Languages>
@ -579,7 +661,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_14
schema: *ref_16
required: false
serializedName: NonRequiredString
language: !<!Languages>
@ -597,12 +679,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_37
schema: !<!ArraySchema> &ref_43
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_15
elementType: *ref_17
language: !<!Languages>
default:
name: MixedModelNonRequiredStringList
@ -616,7 +698,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_16
schema: *ref_18
required: false
serializedName: NonRequiredIntList
language: !<!Languages>
@ -625,7 +707,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_17
schema: *ref_19
nullable: true
required: true
serializedName: RequiredNullableString
@ -645,12 +727,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_38
schema: !<!ArraySchema> &ref_44
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_18
elementType: *ref_20
language: !<!Languages>
default:
name: MixedModelRequiredNullableStringList
@ -665,7 +747,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_19
schema: *ref_21
nullable: true
required: true
serializedName: RequiredNullableIntList
@ -675,7 +757,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_20
schema: *ref_22
nullable: true
required: false
serializedName: NonRequiredNullableString
@ -695,12 +777,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_39
schema: !<!ArraySchema> &ref_45
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_21
elementType: *ref_23
language: !<!Languages>
default:
name: MixedModelNonRequiredNullableStringList
@ -715,7 +797,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_22
schema: *ref_24
nullable: true
required: false
serializedName: NonRequiredNullableIntList
@ -755,14 +837,14 @@ schemas: !<!Schemas>
description: ''
namespace: ''
protocol: !<!Protocols> {}
- !<!ObjectSchema> &ref_50
- !<!ObjectSchema> &ref_58
type: object
apiVersions:
- !<!ApiVersion>
version: 1.0.0
properties:
- !<!Property>
schema: *ref_23
schema: *ref_25
required: true
serializedName: RequiredString
language: !<!Languages>
@ -780,12 +862,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_40
schema: !<!ArraySchema> &ref_46
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_24
elementType: *ref_26
language: !<!Languages>
default:
name: OutputModelRequiredStringList
@ -799,7 +881,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_13
schema: *ref_15
required: true
serializedName: RequiredIntList
language: !<!Languages>
@ -808,7 +890,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_25
schema: *ref_27
required: false
serializedName: NonRequiredString
language: !<!Languages>
@ -826,12 +908,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_41
schema: !<!ArraySchema> &ref_47
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_26
elementType: *ref_28
language: !<!Languages>
default:
name: OutputModelNonRequiredStringList
@ -845,7 +927,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_16
schema: *ref_18
required: false
serializedName: NonRequiredIntList
language: !<!Languages>
@ -854,7 +936,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_27
schema: *ref_29
nullable: true
required: true
serializedName: RequiredNullableString
@ -874,12 +956,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_42
schema: !<!ArraySchema> &ref_48
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_28
elementType: *ref_30
language: !<!Languages>
default:
name: OutputModelRequiredNullableStringList
@ -894,7 +976,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_19
schema: *ref_21
nullable: true
required: true
serializedName: RequiredNullableIntList
@ -904,7 +986,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_29
schema: *ref_31
nullable: true
required: false
serializedName: NonRequiredNullableString
@ -924,12 +1006,12 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_43
schema: !<!ArraySchema> &ref_49
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_30
elementType: *ref_32
language: !<!Languages>
default:
name: OutputModelNonRequiredNullableStringList
@ -944,7 +1026,7 @@ schemas: !<!Schemas>
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: *ref_22
schema: *ref_24
nullable: true
required: false
serializedName: NonRequiredNullableIntList
@ -983,6 +1065,108 @@ schemas: !<!Schemas>
description: ''
namespace: ''
protocol: !<!Protocols> {}
- !<!ObjectSchema> &ref_59
type: object
apiVersions:
- !<!ApiVersion>
version: 1.0.0
properties:
- !<!Property>
schema: !<!ObjectSchema> &ref_34
type: object
apiVersions:
- !<!ApiVersion>
version: 1.0.0
properties:
- !<!Property>
schema: *ref_33
serializedName: Name
language: !<!Languages>
default:
name: name
description: ''
protocol: !<!Protocols> {}
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: ReadonlyModel
description: ''
namespace: ''
protocol: !<!Protocols> {}
readOnly: true
serializedName: ReadonlyProperty
language: !<!Languages>
default:
name: readonlyProperty
description: ''
protocol: !<!Protocols> {}
- !<!Property>
schema: !<!ArraySchema> &ref_50
type: array
apiVersions:
- !<!ApiVersion>
version: 1.0.0
elementType: *ref_34
language: !<!Languages>
default:
name: MixedModelWithReadonlyPropertyReadonlyListProperty
description: Array of ReadonlyModel
protocol: !<!Protocols> {}
readOnly: true
serializedName: ReadonlyListProperty
language: !<!Languages>
default:
name: readonlyListProperty
description: ''
protocol: !<!Protocols> {}
serializationFormats:
- json
usage:
- input
- output
language: !<!Languages>
default:
name: MixedModelWithReadonlyProperty
description: ''
namespace: ''
protocol: !<!Protocols> {}
- *ref_34
- !<!ObjectSchema> &ref_61
type: object
apiVersions:
- !<!ApiVersion>
version: 1.0.0
properties:
- !<!Property> &ref_63
schema: *ref_35
serializedName: Code
language: !<!Languages>
default:
name: code
description: ''
protocol: !<!Protocols> {}
- !<!Property> &ref_64
schema: *ref_36
serializedName: Status
language: !<!Languages>
default:
name: status
description: ''
protocol: !<!Protocols> {}
serializationFormats:
- json
usage:
- input
language: !<!Languages>
default:
name: ParametersModel
description: ''
namespace: ''
protocol: !<!Protocols> {}
- !<!ObjectSchema>
type: object
apiVersions:
@ -990,7 +1174,7 @@ schemas: !<!Schemas>
version: 1.0.0
properties:
- !<!Property>
schema: *ref_31
schema: *ref_37
serializedName: UnusedString
language: !<!Languages>
default:
@ -1004,24 +1188,25 @@ schemas: !<!Schemas>
namespace: ''
protocol: !<!Protocols> {}
arrays:
- *ref_32
- *ref_13
- *ref_33
- *ref_16
- *ref_34
- *ref_19
- *ref_35
- *ref_22
- *ref_36
- *ref_37
- *ref_38
- *ref_15
- *ref_39
- *ref_18
- *ref_40
- *ref_21
- *ref_41
- *ref_24
- *ref_42
- *ref_43
- *ref_44
- *ref_45
- *ref_46
- *ref_47
- *ref_48
- *ref_49
- *ref_50
globalParameters:
- !<!Parameter> &ref_44
- !<!Parameter> &ref_51
schema: *ref_0
clientDefaultValue: 'http://localhost:3000'
implementation: Client
@ -1046,12 +1231,12 @@ operationGroups:
- !<!ApiVersion>
version: 1.0.0
parameters:
- *ref_44
- *ref_51
requests:
- !<!Request>
parameters:
- !<!Parameter>
schema: *ref_45
schema: *ref_52
implementation: Method
origin: 'modelerfour:synthesized/content-type'
required: true
@ -1063,8 +1248,8 @@ operationGroups:
protocol: !<!Protocols>
http: !<!HttpParameter>
in: header
- !<!Parameter> &ref_47
schema: *ref_46
- !<!Parameter> &ref_54
schema: *ref_53
implementation: Method
required: true
language: !<!Languages>
@ -1076,7 +1261,7 @@ operationGroups:
in: body
style: json
signatureParameters:
- *ref_47
- *ref_54
language: !<!Languages>
default:
name: ''
@ -1100,6 +1285,20 @@ operationGroups:
http: !<!HttpResponse>
statusCodes:
- '200'
exceptions:
- !<!SchemaResponse>
schema: *ref_55
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols>
http: !<!HttpResponse>
knownMediaType: json
mediaTypes:
- application/json
statusCodes:
- default
language: !<!Languages>
default:
name: Input
@ -1110,12 +1309,12 @@ operationGroups:
- !<!ApiVersion>
version: 1.0.0
parameters:
- *ref_44
- *ref_51
requests:
- !<!Request>
parameters:
- !<!Parameter>
schema: *ref_45
schema: *ref_52
implementation: Method
origin: 'modelerfour:synthesized/content-type'
required: true
@ -1127,8 +1326,8 @@ operationGroups:
protocol: !<!Protocols>
http: !<!HttpParameter>
in: header
- !<!Parameter> &ref_49
schema: *ref_48
- !<!Parameter> &ref_57
schema: *ref_56
implementation: Method
required: true
language: !<!Languages>
@ -1140,7 +1339,7 @@ operationGroups:
in: body
style: json
signatureParameters:
- *ref_49
- *ref_57
language: !<!Languages>
default:
name: ''
@ -1156,7 +1355,7 @@ operationGroups:
signatureParameters: []
responses:
- !<!SchemaResponse>
schema: *ref_48
schema: *ref_56
language: !<!Languages>
default:
name: ''
@ -1178,7 +1377,7 @@ operationGroups:
- !<!ApiVersion>
version: 1.0.0
parameters:
- *ref_44
- *ref_51
requests:
- !<!Request>
language: !<!Languages>
@ -1193,7 +1392,7 @@ operationGroups:
signatureParameters: []
responses:
- !<!SchemaResponse>
schema: *ref_50
schema: *ref_58
language: !<!Languages>
default:
name: ''
@ -1210,6 +1409,164 @@ operationGroups:
name: Output
description: ''
protocol: !<!Protocols> {}
- !<!Operation>
apiVersions:
- !<!ApiVersion>
version: 1.0.0
parameters:
- *ref_51
requests:
- !<!Request>
parameters:
- !<!Parameter>
schema: *ref_52
implementation: Method
origin: 'modelerfour:synthesized/content-type'
required: true
language: !<!Languages>
default:
name: contentType
description: Body Parameter content-type
serializedName: Content-Type
protocol: !<!Protocols>
http: !<!HttpParameter>
in: header
- !<!Parameter> &ref_60
schema: *ref_59
implementation: Method
required: true
language: !<!Languages>
default:
name: value
description: ''
protocol: !<!Protocols>
http: !<!HttpParameter>
in: body
style: json
signatureParameters:
- *ref_60
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols>
http: !<!HttpWithBodyRequest>
path: /op2
method: put
knownMediaType: json
mediaTypes:
- application/json
uri: '{$host}'
signatureParameters: []
responses:
- !<!SchemaResponse>
schema: *ref_59
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols>
http: !<!HttpResponse>
knownMediaType: json
mediaTypes:
- application/json
statusCodes:
- '200'
language: !<!Languages>
default:
name: Mixedreadonly
description: ''
protocol: !<!Protocols> {}
- !<!Operation>
apiVersions:
- !<!ApiVersion>
version: 1.0.0
parameters:
- *ref_51
requests:
- !<!Request>
parameters:
- !<!Parameter>
schema: *ref_52
implementation: Method
origin: 'modelerfour:synthesized/content-type'
required: true
language: !<!Languages>
default:
name: contentType
description: Body Parameter content-type
serializedName: Content-Type
protocol: !<!Protocols>
http: !<!HttpParameter>
in: header
- !<!Parameter> &ref_62
schema: *ref_61
flattened: true
implementation: Method
required: true
extensions:
x-ms-client-flatten: true
language: !<!Languages>
default:
name: value
description: ''
protocol: !<!Protocols>
http: !<!HttpParameter>
in: body
style: json
- !<!VirtualParameter> &ref_65
schema: *ref_35
implementation: Method
originalParameter: *ref_62
pathToProperty: []
targetProperty: *ref_63
language: !<!Languages>
default:
name: code
description: ''
protocol: !<!Protocols> {}
- !<!VirtualParameter> &ref_66
schema: *ref_36
implementation: Method
originalParameter: *ref_62
pathToProperty: []
targetProperty: *ref_64
language: !<!Languages>
default:
name: status
description: ''
protocol: !<!Protocols> {}
signatureParameters:
- *ref_65
- *ref_66
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols>
http: !<!HttpWithBodyRequest>
path: /op3
method: put
knownMediaType: json
mediaTypes:
- application/json
uri: '{$host}'
signatureParameters: []
responses:
- !<!Response>
language: !<!Languages>
default:
name: ''
description: ''
protocol: !<!Protocols>
http: !<!HttpResponse>
statusCodes:
- '200'
language: !<!Languages>
default:
name: FlattenedParameterOperation
description: ''
protocol: !<!Protocols> {}
language: !<!Languages>
default:
name: ''

Просмотреть файл

@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace ModelShapes.Models
{
internal partial class ErrorModel
{
internal static ErrorModel DeserializeErrorModel(JsonElement element)
{
Optional<string> code = default;
Optional<string> status = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("Code"))
{
code = property.Value.GetString();
continue;
}
if (property.NameEquals("Status"))
{
status = property.Value.GetString();
continue;
}
}
return new ErrorModel(code.Value, status.Value);
}
}
}

30
test/TestProjects/ModelShapes/Generated/Models/ErrorModel.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
namespace ModelShapes.Models
{
/// <summary> The ErrorModel. </summary>
internal partial class ErrorModel
{
/// <summary> Initializes a new instance of ErrorModel. </summary>
internal ErrorModel()
{
}
/// <summary> Initializes a new instance of ErrorModel. </summary>
/// <param name="code"> . </param>
/// <param name="status"> . </param>
internal ErrorModel(string code, string status)
{
Code = code;
Status = status;
}
public string Code { get; }
public string Status { get; }
}
}

Просмотреть файл

@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Collections.Generic;
using System.Text.Json;
using Azure.Core;
namespace ModelShapes.Models
{
public partial class MixedModelWithReadonlyProperty : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
internal static MixedModelWithReadonlyProperty DeserializeMixedModelWithReadonlyProperty(JsonElement element)
{
Optional<ReadonlyModel> readonlyProperty = default;
Optional<IReadOnlyList<ReadonlyModel>> readonlyListProperty = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("ReadonlyProperty"))
{
readonlyProperty = ReadonlyModel.DeserializeReadonlyModel(property.Value);
continue;
}
if (property.NameEquals("ReadonlyListProperty"))
{
List<ReadonlyModel> array = new List<ReadonlyModel>();
foreach (var item in property.Value.EnumerateArray())
{
array.Add(ReadonlyModel.DeserializeReadonlyModel(item));
}
readonlyListProperty = array;
continue;
}
}
return new MixedModelWithReadonlyProperty(readonlyProperty.Value, Optional.ToList(readonlyListProperty));
}
}
}

Просмотреть файл

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Collections.Generic;
using Azure.Core;
namespace ModelShapes.Models
{
/// <summary> The MixedModelWithReadonlyProperty. </summary>
public partial class MixedModelWithReadonlyProperty
{
/// <summary> Initializes a new instance of MixedModelWithReadonlyProperty. </summary>
public MixedModelWithReadonlyProperty()
{
ReadonlyListProperty = new ChangeTrackingList<ReadonlyModel>();
}
/// <summary> Initializes a new instance of MixedModelWithReadonlyProperty. </summary>
/// <param name="readonlyProperty"> . </param>
/// <param name="readonlyListProperty"> . </param>
internal MixedModelWithReadonlyProperty(ReadonlyModel readonlyProperty, IReadOnlyList<ReadonlyModel> readonlyListProperty)
{
ReadonlyProperty = readonlyProperty;
ReadonlyListProperty = readonlyListProperty;
}
public ReadonlyModel ReadonlyProperty { get; }
public IReadOnlyList<ReadonlyModel> ReadonlyListProperty { get; }
}
}

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace ModelShapes.Models
{
internal partial class ParametersModel : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(Code))
{
writer.WritePropertyName("Code");
writer.WriteStringValue(Code);
}
if (Optional.IsDefined(Status))
{
writer.WritePropertyName("Status");
writer.WriteStringValue(Status);
}
writer.WriteEndObject();
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше