Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ namespace AzureSample.ResourceManager.Sample
/// Context class which will be filled in by the System.ClientModel.SourceGeneration.
/// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md'
/// </summary>
[ModelReaderWriterBuildable(typeof(AdditionalCapabilities))]
[ModelReaderWriterBuildable(typeof(AdditionalUnattendContent))]
[ModelReaderWriterBuildable(typeof(ApiError))]
[ModelReaderWriterBuildable(typeof(ApiErrorBase))]
[ModelReaderWriterBuildable(typeof(AutomaticOSUpgradePolicy))]
[ModelReaderWriterBuildable(typeof(AutomaticOSUpgradeProperties))]
[ModelReaderWriterBuildable(typeof(AutomaticRepairsPolicy))]
[ModelReaderWriterBuildable(typeof(AvailabilitySetData))]
[ModelReaderWriterBuildable(typeof(AvailabilitySetListResult))]
Expand All @@ -30,13 +32,16 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(AzureSampleResourceManagerSampleSku))]
[ModelReaderWriterBuildable(typeof(AzureSampleResourceManagerSampleUsage))]
[ModelReaderWriterBuildable(typeof(AzureSampleResourceManagerSampleUsageName))]
[ModelReaderWriterBuildable(typeof(BillingProfile))]
[ModelReaderWriterBuildable(typeof(BootDiagnostics))]
[ModelReaderWriterBuildable(typeof(BootDiagnosticsInstanceView))]
[ModelReaderWriterBuildable(typeof(DataDisk))]
[ModelReaderWriterBuildable(typeof(DataDiskImage))]
[ModelReaderWriterBuildable(typeof(DedicatedHostAllocatableVm))]
[ModelReaderWriterBuildable(typeof(DedicatedHostAvailableCapacity))]
[ModelReaderWriterBuildable(typeof(DedicatedHostData))]
[ModelReaderWriterBuildable(typeof(DedicatedHostGroupData))]
[ModelReaderWriterBuildable(typeof(DedicatedHostGroupInstanceView))]
[ModelReaderWriterBuildable(typeof(DedicatedHostGroupListResult))]
[ModelReaderWriterBuildable(typeof(DedicatedHostGroupPatch))]
[ModelReaderWriterBuildable(typeof(DedicatedHostGroupResource))]
Expand All @@ -45,10 +50,13 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(DedicatedHostListResult))]
[ModelReaderWriterBuildable(typeof(DedicatedHostPatch))]
[ModelReaderWriterBuildable(typeof(DedicatedHostResource))]
[ModelReaderWriterBuildable(typeof(DiagnosticsProfile))]
[ModelReaderWriterBuildable(typeof(DiffDiskSettings))]
[ModelReaderWriterBuildable(typeof(DisallowedConfiguration))]
[ModelReaderWriterBuildable(typeof(DiskEncryptionSettings))]
[ModelReaderWriterBuildable(typeof(DiskInstanceView))]
[ModelReaderWriterBuildable(typeof(ExtendedLocation))]
[ModelReaderWriterBuildable(typeof(HardwareProfile))]
[ModelReaderWriterBuildable(typeof(ImageData))]
[ModelReaderWriterBuildable(typeof(ImageDataDisk))]
[ModelReaderWriterBuildable(typeof(ImageDisk))]
Expand All @@ -67,14 +75,18 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(ListUsagesResult))]
[ModelReaderWriterBuildable(typeof(LogAnalytics))]
[ModelReaderWriterBuildable(typeof(LogAnalyticsInputBase))]
[ModelReaderWriterBuildable(typeof(LogAnalyticsOutput))]
[ModelReaderWriterBuildable(typeof(MaintenanceRedeployStatus))]
[ModelReaderWriterBuildable(typeof(ManagedDiskParameters))]
[ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))]
[ModelReaderWriterBuildable(typeof(NetworkInterfaceReference))]
[ModelReaderWriterBuildable(typeof(NetworkProfile))]
[ModelReaderWriterBuildable(typeof(OrchestrationServiceStateContent))]
[ModelReaderWriterBuildable(typeof(OrchestrationServiceSummary))]
[ModelReaderWriterBuildable(typeof(OSDisk))]
[ModelReaderWriterBuildable(typeof(OSDiskImage))]
[ModelReaderWriterBuildable(typeof(OSProfile))]
[ModelReaderWriterBuildable(typeof(PatchSettings))]
[ModelReaderWriterBuildable(typeof(ProximityPlacementGroupData))]
[ModelReaderWriterBuildable(typeof(ProximityPlacementGroupListResult))]
[ModelReaderWriterBuildable(typeof(ProximityPlacementGroupPatch))]
Expand All @@ -87,6 +99,10 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(RollingUpgradePolicy))]
[ModelReaderWriterBuildable(typeof(RollingUpgradeProgressInfo))]
[ModelReaderWriterBuildable(typeof(RollingUpgradeRunningStatus))]
[ModelReaderWriterBuildable(typeof(ScaleInPolicy))]
[ModelReaderWriterBuildable(typeof(ScheduledEventsProfile))]
[ModelReaderWriterBuildable(typeof(SecurityProfile))]
[ModelReaderWriterBuildable(typeof(SshConfiguration))]
[ModelReaderWriterBuildable(typeof(SshPublicKeyData))]
[ModelReaderWriterBuildable(typeof(SshPublicKeyGenerateKeyPairResult))]
[ModelReaderWriterBuildable(typeof(SshPublicKeyInfo))]
Expand All @@ -110,6 +126,7 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(UserAssignedIdentity))]
[ModelReaderWriterBuildable(typeof(VaultCertificate))]
[ModelReaderWriterBuildable(typeof(VaultSecretGroup))]
[ModelReaderWriterBuildable(typeof(VirtualHardDisk))]
[ModelReaderWriterBuildable(typeof(VirtualMachineAgentInstanceView))]
[ModelReaderWriterBuildable(typeof(VirtualMachineAssessPatchesResult))]
[ModelReaderWriterBuildable(typeof(VirtualMachineCaptureContent))]
Expand All @@ -121,7 +138,9 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(VirtualMachineExtensionImageResource))]
[ModelReaderWriterBuildable(typeof(VirtualMachineExtensionInstanceView))]
[ModelReaderWriterBuildable(typeof(VirtualMachineExtensionResource))]
[ModelReaderWriterBuildable(typeof(VirtualMachineExtensionsListResult))]
[ModelReaderWriterBuildable(typeof(VirtualMachineExtensionUpdate))]
[ModelReaderWriterBuildable(typeof(VirtualMachineHealthStatus))]
[ModelReaderWriterBuildable(typeof(VirtualMachineImage))]
[ModelReaderWriterBuildable(typeof(VirtualMachineImageResource))]
[ModelReaderWriterBuildable(typeof(VirtualMachineInstanceView))]
Expand All @@ -138,6 +157,7 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetExtensionProfile))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetExtensionResource))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetInstanceView))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetInstanceViewStatusesSummary))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetIPConfiguration))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetIPTag))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetListOSUpgradeHistory))]
Expand All @@ -146,11 +166,13 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetListWithLinkResult))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetManagedDiskParameters))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetNetworkConfiguration))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetNetworkConfigurationDnsSettings))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetNetworkProfile))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetOSDisk))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetOSProfile))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetPatch))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetPublicIPAddressConfiguration))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetReimageContent))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetResource))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetRollingUpgradeData))]
Expand All @@ -173,6 +195,7 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetVmInstanceRequiredIds))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetVmInstanceView))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetVmListResult))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetVmNetworkProfileConfiguration))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetVmProfile))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetVmProtectionPolicy))]
[ModelReaderWriterBuildable(typeof(VirtualMachineScaleSetVmReimageContent))]
Expand All @@ -183,6 +206,7 @@ namespace AzureSample.ResourceManager.Sample
[ModelReaderWriterBuildable(typeof(VirtualMachineStatusCodeCount))]
[ModelReaderWriterBuildable(typeof(VmScaleSetConvertToSinglePlacementGroupContent))]
[ModelReaderWriterBuildable(typeof(WindowsConfiguration))]
[ModelReaderWriterBuildable(typeof(WinRMConfiguration))]
[ModelReaderWriterBuildable(typeof(WinRMListener))]
[ModelReaderWriterBuildable(typeof(WritableSubResource))]
public partial class AzureSampleResourceManagerSampleContext : ModelReaderWriterContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public async Task<Project> InternalizeAsync(Project project)
var modelNamesToRemove = nodesToInternalize.Keys.Select(item => item.Identifier.Text).Concat(suppressedTypeNames);
var modelFullNamesToRemove = nodesToInternalize.Keys.Select(item => GetFullName(item)).ToHashSet();
project = await RemoveMethodsFromModelFactoryAsync(project, definitions, modelNamesToRemove.ToHashSet());
project = await RemoveAttributesFromModelRreaderWriterContext(project, modelFullNamesToRemove);

return project;

Expand All @@ -159,68 +158,6 @@ string GetFullName(BaseTypeDeclarationSyntax item)
}
}

private async Task<Project> RemoveAttributesFromModelRreaderWriterContext(Project project, HashSet<string> namesToRemove)
{
if (_mrwContextTypeSymbol is null)
{
return project;
}

var updatedAttributeLists = new List<AttributeListSyntax>();
var mrwContextClassNode = _mrwContextTypeSymbol.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() as ClassDeclarationSyntax;
if (mrwContextClassNode is null)
{
return project;
}

var root = await mrwContextClassNode.SyntaxTree.GetRootAsync();
var updated = false;
foreach (var attributeList in mrwContextClassNode!.AttributeLists)
{
var updatedAttributes = new List<AttributeSyntax>();
foreach (var attribute in attributeList.Attributes)
{
if (!ShouldRemoveAttribute(attribute))
{
updatedAttributes.Add(attribute);
}
}

if (updatedAttributes.Count != attributeList.Attributes.Count)
{
updated = true;
if (updatedAttributes.Count == 0)
{
continue; // skip empty attribute lists
}
updatedAttributeLists.Add(SyntaxFactory.AttributeList(SyntaxFactory.SeparatedList(updatedAttributes)));
}
else
{
updatedAttributeLists.Add(attributeList);
}
}

if (updated)
{
var leadingTrivia = mrwContextClassNode.GetLeadingTrivia();
var newClassNode = mrwContextClassNode.WithAttributeLists(SyntaxFactory.List(updatedAttributeLists)).WithLeadingTrivia(leadingTrivia);
var newRoot = root.ReplaceNode(mrwContextClassNode, newClassNode);

var mrwContextDocument = project.GetDocument(mrwContextClassNode.SyntaxTree)!;
mrwContextDocument = mrwContextDocument.WithSyntaxRoot(newRoot);
return mrwContextDocument.Project;
}

return project;

bool ShouldRemoveAttribute(AttributeSyntax attr)
{
var attributeArgumentNames = attr.ArgumentList?.Arguments.Select(x => ((x.Expression as TypeOfExpressionSyntax)?.Type as QualifiedNameSyntax)?.ToString());
return attributeArgumentNames != null && attributeArgumentNames.Any(name => name is not null && namesToRemove.Contains(name));
}
}

private async Task<Project> RemoveMethodsFromModelFactoryAsync(Project project, TypeSymbols definitions, HashSet<string> namesToRemove)
{
var modelFactorySymbol = definitions.ModelFactorySymbol;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ namespace _Specs_.Azure.ClientGenerator.Core.Access
/// Context class which will be filled in by the System.ClientModel.SourceGeneration.
/// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md'
/// </summary>
[ModelReaderWriterBuildable(typeof(AbstractModel))]
[ModelReaderWriterBuildable(typeof(BaseModel))]
[ModelReaderWriterBuildable(typeof(InnerModel))]
[ModelReaderWriterBuildable(typeof(InternalDecoratorModelInInternal))]
[ModelReaderWriterBuildable(typeof(NoDecoratorModelInInternal))]
[ModelReaderWriterBuildable(typeof(NoDecoratorModelInPublic))]
[ModelReaderWriterBuildable(typeof(OuterModel))]
[ModelReaderWriterBuildable(typeof(PublicDecoratorModelInInternal))]
[ModelReaderWriterBuildable(typeof(PublicDecoratorModelInPublic))]
[ModelReaderWriterBuildable(typeof(RealModel))]
[ModelReaderWriterBuildable(typeof(SharedModel))]
[ModelReaderWriterBuildable(typeof(UnknownAbstractModel))]
public partial class _Specs_AzureClientGeneratorCoreAccessContext : ModelReaderWriterContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace _Azure.ResourceManager.CommonProperties
[ModelReaderWriterBuildable(typeof(ConfidentialResourceProperties))]
[ModelReaderWriterBuildable(typeof(ManagedIdentityTrackedResource))]
[ModelReaderWriterBuildable(typeof(ManagedIdentityTrackedResourceData))]
[ModelReaderWriterBuildable(typeof(ManagedIdentityTrackedResourceProperties))]
[ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))]
[ModelReaderWriterBuildable(typeof(ResponseError))]
[ModelReaderWriterBuildable(typeof(SystemData))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,26 @@ namespace _Azure.ResourceManager.Resources
/// </summary>
[ModelReaderWriterBuildable(typeof(ExtensionsResource))]
[ModelReaderWriterBuildable(typeof(ExtensionsResourceData))]
[ModelReaderWriterBuildable(typeof(ExtensionsResourceListResult))]
[ModelReaderWriterBuildable(typeof(ExtensionsResourceProperties))]
[ModelReaderWriterBuildable(typeof(LocationResource))]
[ModelReaderWriterBuildable(typeof(LocationResourceData))]
[ModelReaderWriterBuildable(typeof(LocationResourceListResult))]
[ModelReaderWriterBuildable(typeof(LocationResourceProperties))]
[ModelReaderWriterBuildable(typeof(NestedProxyResource))]
[ModelReaderWriterBuildable(typeof(NestedProxyResourceData))]
[ModelReaderWriterBuildable(typeof(NestedProxyResourceListResult))]
[ModelReaderWriterBuildable(typeof(NestedProxyResourceProperties))]
[ModelReaderWriterBuildable(typeof(NotificationDetails))]
[ModelReaderWriterBuildable(typeof(ResponseError))]
[ModelReaderWriterBuildable(typeof(SingletonTrackedResource))]
[ModelReaderWriterBuildable(typeof(SingletonTrackedResourceData))]
[ModelReaderWriterBuildable(typeof(SingletonTrackedResourceListResult))]
[ModelReaderWriterBuildable(typeof(SingletonTrackedResourceProperties))]
[ModelReaderWriterBuildable(typeof(SystemData))]
[ModelReaderWriterBuildable(typeof(TopLevelTrackedResource))]
[ModelReaderWriterBuildable(typeof(TopLevelTrackedResourceData))]
[ModelReaderWriterBuildable(typeof(TopLevelTrackedResourceListResult))]
[ModelReaderWriterBuildable(typeof(TopLevelTrackedResourceProperties))]
public partial class _AzureResourceManagerResourcesContext : ModelReaderWriterContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Parameters.Basic
/// Context class which will be filled in by the System.ClientModel.SourceGeneration.
/// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md'
/// </summary>
[ModelReaderWriterBuildable(typeof(SimpleRequest))]
[ModelReaderWriterBuildable(typeof(User))]
public partial class ParametersBasicContext : ModelReaderWriterContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ namespace Parameters.Spread
/// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md'
/// </summary>
[ModelReaderWriterBuildable(typeof(BodyParameter))]
[ModelReaderWriterBuildable(typeof(SpreadAsRequestBodyRequest))]
[ModelReaderWriterBuildable(typeof(SpreadAsRequestParameterRequest))]
[ModelReaderWriterBuildable(typeof(SpreadCompositeRequestMixRequest))]
[ModelReaderWriterBuildable(typeof(SpreadParameterWithInnerAliasRequest))]
[ModelReaderWriterBuildable(typeof(SpreadParameterWithInnerModelRequest))]
[ModelReaderWriterBuildable(typeof(SpreadWithMultipleParametersRequest))]
public partial class ParametersSpreadContext : ModelReaderWriterContext
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ namespace _Type.Union
[ModelReaderWriterBuildable(typeof(GetResponse9))]
[ModelReaderWriterBuildable(typeof(MixedLiteralsCases))]
[ModelReaderWriterBuildable(typeof(MixedTypesCases))]
[ModelReaderWriterBuildable(typeof(SendRequest))]
[ModelReaderWriterBuildable(typeof(SendRequest1))]
[ModelReaderWriterBuildable(typeof(SendRequest2))]
[ModelReaderWriterBuildable(typeof(SendRequest3))]
[ModelReaderWriterBuildable(typeof(SendRequest4))]
[ModelReaderWriterBuildable(typeof(SendRequest5))]
[ModelReaderWriterBuildable(typeof(SendRequest6))]
[ModelReaderWriterBuildable(typeof(SendRequest7))]
[ModelReaderWriterBuildable(typeof(SendRequest8))]
[ModelReaderWriterBuildable(typeof(SendRequest9))]
[ModelReaderWriterBuildable(typeof(StringAndArrayCases))]
public partial class _TypeUnionContext : ModelReaderWriterContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ namespace Scm.Parameters.Spread
/// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md'
/// </summary>
[ModelReaderWriterBuildable(typeof(BodyParameter))]
[ModelReaderWriterBuildable(typeof(SpreadAsRequestBodyRequest))]
[ModelReaderWriterBuildable(typeof(SpreadAsRequestParameterRequest))]
[ModelReaderWriterBuildable(typeof(SpreadCompositeRequestMixRequest))]
[ModelReaderWriterBuildable(typeof(SpreadParameterWithInnerAliasRequest))]
[ModelReaderWriterBuildable(typeof(SpreadParameterWithInnerModelRequest))]
[ModelReaderWriterBuildable(typeof(SpreadWithMultipleParametersRequest))]
public partial class ScmParametersSpreadContext : ModelReaderWriterContext
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ namespace Scm._Type.Union
[ModelReaderWriterBuildable(typeof(GetResponse9))]
[ModelReaderWriterBuildable(typeof(MixedLiteralsCases))]
[ModelReaderWriterBuildable(typeof(MixedTypesCases))]
[ModelReaderWriterBuildable(typeof(SendRequest))]
[ModelReaderWriterBuildable(typeof(SendRequest1))]
[ModelReaderWriterBuildable(typeof(SendRequest2))]
[ModelReaderWriterBuildable(typeof(SendRequest3))]
[ModelReaderWriterBuildable(typeof(SendRequest4))]
[ModelReaderWriterBuildable(typeof(SendRequest5))]
[ModelReaderWriterBuildable(typeof(SendRequest6))]
[ModelReaderWriterBuildable(typeof(SendRequest7))]
[ModelReaderWriterBuildable(typeof(SendRequest8))]
[ModelReaderWriterBuildable(typeof(SendRequest9))]
[ModelReaderWriterBuildable(typeof(StringAndArrayCases))]
public partial class Scm_TypeUnionContext : ModelReaderWriterContext
{
Expand Down
Loading