Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autorest-generated model factories #21301

Merged
merged 11 commits into from
May 27, 2021

Conversation

AlexanderSher
Copy link
Contributor

@AlexanderSher AlexanderSher commented May 24, 2021

Fixes #21144

@ghost ghost added Event Grid IoT KeyVault Search Storage Storage Service (Queues, Blobs, Files) Tables labels May 24, 2021
Copy link
Member

@JoshLove-msft JoshLove-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event Grid updates look good.

@@ -337,7 +337,9 @@ public static partial class FormRecognizerModelFactory
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.AI.FormRecognizer.Training.CustomFormModel CustomFormModel(string modelId, Azure.AI.FormRecognizer.Training.CustomFormModelStatus status, System.DateTimeOffset trainingStartedOn, System.DateTimeOffset trainingCompletedOn, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Training.CustomFormSubmodel> submodels, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Training.TrainingDocumentInfo> trainingDocuments, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormRecognizerError> errors) { throw null; }
public static Azure.AI.FormRecognizer.Training.CustomFormModel CustomFormModel(string modelId, Azure.AI.FormRecognizer.Training.CustomFormModelStatus status, System.DateTimeOffset trainingStartedOn, System.DateTimeOffset trainingCompletedOn, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Training.CustomFormSubmodel> submodels, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Training.TrainingDocumentInfo> trainingDocuments, System.Collections.Generic.IReadOnlyList<Azure.AI.FormRecognizer.Models.FormRecognizerError> errors, string modelName, Azure.AI.FormRecognizer.Training.CustomFormModelProperties properties) { throw null; }
public static Azure.AI.FormRecognizer.Training.CustomFormModelField CustomFormModelField(string name = null, float? accuracy = default(float?)) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FR is in code freeze until we release GA (hopefully this week). Is there a way to disable the changes here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add an internal type that will make codegen MF internal. We will delete it after GA.

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class names need to be changed to match pattern, and the sample factory isn't necessary because it's a sample. These classes just complicate it unnecessarily. Can we just turn off factory generation?

using Azure.Security.KeyVault.Administration.Models;

namespace Azure.Security.KeyVault.Administration
{
/// <summary>
/// A factory class which constructs model classes for mocking purposes.
/// </summary>
public static class KeyVaultAdministrationModelFactory
[CodeGenType("AzureSecurityKeyVaultAdministrationModelFactory")]
public static partial class KeyVaultAdministrationModelFactory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just AdministrationModelFactory, which matches our other factory classes we already GA'd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type was there already. Do you want me to rename it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow, you're right. I didn't realize that (or just flat-out forgot). @christothes it seems to me that we should leave this name as-is since "AdministrationModelFactory" is rather vague, even if it fits the existing pattern. Agreed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving timing, we'll leave it as-is for now. If there's concern, we still have a little time to change it.

@AlexanderSher
Copy link
Contributor Author

Is there anybody else who needs public API changes to be reverted in this PR?

public static partial class ContainerRegistryModelFactory
{
public static Azure.Containers.ContainerRegistry.ArtifactManifestProperties ArtifactManifestProperties(string registryLoginServer = null, string repositoryName = null, string digest = null, long? size = default(long?), System.DateTimeOffset createdOn = default(System.DateTimeOffset), System.DateTimeOffset lastUpdatedOn = default(System.DateTimeOffset), Azure.Containers.ContainerRegistry.ArtifactArchitecture? architecture = default(Azure.Containers.ContainerRegistry.ArtifactArchitecture?), Azure.Containers.ContainerRegistry.ArtifactOperatingSystem? operatingSystem = default(Azure.Containers.ContainerRegistry.ArtifactOperatingSystem?), System.Collections.Generic.IReadOnlyList<Azure.Containers.ContainerRegistry.ArtifactManifestReference> manifestReferences = null, System.Collections.Generic.IReadOnlyList<string> tags = null, bool? canDelete = default(bool?), bool? canWrite = default(bool?), bool? canList = default(bool?), bool? canRead = default(bool?), string quarantineState = null, string quarantineDetails = null) { throw null; }
public static Azure.Containers.ContainerRegistry.ArtifactManifestReference ArtifactManifestReference(string digest = null, Azure.Containers.ContainerRegistry.ArtifactArchitecture architecture = default(Azure.Containers.ContainerRegistry.ArtifactArchitecture), Azure.Containers.ContainerRegistry.ArtifactOperatingSystem operatingSystem = default(Azure.Containers.ContainerRegistry.ArtifactOperatingSystem)) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ever wanted to use EditorBrowsable Never here, would that get picked up on the creation methods automatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you apply [EditorBrowsable(EditorBrowsableState.Never)] and [Browsable(false)] to the hand-written partial part of the factory, it should affect all the methods in it.

Copy link
Member

@annelo-msft annelo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACR looks good - thanks!

@heaths
Copy link
Member

heaths commented May 25, 2021

@AlexanderSher

Is there anybody else who needs public API changes to be reverted in this PR?

Actually, KV is about to GA in a couple weeks, so if that's an option, yes, I'd rather not take these changes. That also gives us time to work out the issues. I still think dropping the redundant class name from the class summary should go in before this one (or soon after, though). It's currently out of sync with the class name, and really is redundant since it's literally in the class summary.

- Remove unwanted model factories
@AlexanderSher
Copy link
Contributor Author

We have added assembly-level attribute CodeGenSuppressTypeAttribute that allows you to suppress generation of any type (not just model factory).
@maririos , you'll need to remove this usage after GA:
https://github.com/Azure/azure-sdk-for-net/pull/21301/files#diff-e7e5f4324b0c386a49f3bcbc03c54b0159cca15ad2918c24521b3eeb12f77b2bR13

@heaths, codegen'ed model factories are removed.

using Azure.Security.KeyVault.Administration.Models;

namespace Azure.Security.KeyVault.Administration
{
/// <summary>
/// A factory class which constructs model classes for mocking purposes.
/// </summary>
public static class KeyVaultAdministrationModelFactory
[CodeGenType("AzureSecurityKeyVaultAdministrationModelFactory")]
public static partial class KeyVaultAdministrationModelFactory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow, you're right. I didn't realize that (or just flat-out forgot). @christothes it seems to me that we should leave this name as-is since "AdministrationModelFactory" is rather vague, even if it fits the existing pattern. Agreed?

using Azure.Security.KeyVault.Administration.Models;

namespace Azure.Security.KeyVault.Administration
{
/// <summary>
/// A factory class which constructs model classes for mocking purposes.
/// </summary>
public static class KeyVaultAdministrationModelFactory
[CodeGenType("AzureSecurityKeyVaultAdministrationModelFactory")]
public static partial class KeyVaultAdministrationModelFactory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving timing, we'll leave it as-is for now. If there's concern, we still have a little time to change it.

@AlexanderSher AlexanderSher merged commit 9195ffe into Azure:master May 27, 2021
@AlexanderSher AlexanderSher deleted the AddModelFactory branch May 27, 2021 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ACR] Add ContainerRegistryModelFactory for Mocking
6 participants