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

Storage: Add internal constructors for output only model types #7738

Closed
tg-msft opened this issue Sep 24, 2019 · 1 comment
Closed

Storage: Add internal constructors for output only model types #7738

tg-msft opened this issue Sep 24, 2019 · 1 comment
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Milestone

Comments

@tg-msft
Copy link
Member

tg-msft commented Sep 24, 2019

@KrzysztofCwalina pointed out in the ongoing API review that model types only ever returned shouldn't have public constructors. We're not generating those constructors, but C# will add a default public constructor if we don't have any. Here's an example comment.

We need to add an internal constructor that looks something like:

    /// <summary>
    /// Prevent direct instantiation of ${naming.type(type.name)} instances.
    /// You can use ${factoryName}.${naming.type(type.name)} instead.
    /// </summary>
    internal ${naming.type(type.name)}() { }

This is a little more involved. You can see where we generate constructors at generator.ts line 872. We want to add an else that generates the above code. You can get the factory name for the helpful comment via same code as line 943. Adding a local variable for naming.type(type.name) probably wouldn't hurt either.

When you regenerate, you should see private constructors appear for all the model types without other constructors and a Azure.Storage.sln should rebuild cleanly.

@tg-msft tg-msft added Storage Storage Service (Queues, Blobs, Files) Client This issue points to a problem in the data-plane of the library. labels Sep 24, 2019
@tg-msft tg-msft added this to the Backlog milestone Sep 24, 2019
@ShivangiReja
Copy link
Member

Closed with #7744

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

2 participants