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

Remove static cache #47859

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Remove static cache #47859

wants to merge 6 commits into from

Conversation

live1206
Copy link
Member

@live1206 live1206 commented Jan 16, 2025

Remove static cache, it is causing unexpected cache state shared between isolated tests.

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. CodeGen Issues that relate to code generation labels Jan 16, 2025
var restClientNamesToExclude = new HashSet<string>();
foreach(var provider in baseProviders)
{
// skip clients without methods
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we only do this for ARM libraries?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should override CreateClientCore in the AzureTypeFactory, and just return null for the case we care about. I'm adding support for returning null in microsoft/typespec#5638

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't we only do this for ARM libraries?

As in this PR description, I am not sure if we should diverge this for MPG and DPG. Is there a good reason why this is only for MPG?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should override CreateClientCore in the AzureTypeFactory, and just return null for the case we care about. I'm adding support for returning null in microsoft/typespec#5638

OK, that's one way to deal with it, I will update the implementation.

Copy link
Member Author

@live1206 live1206 Jan 17, 2025

Choose a reason for hiding this comment

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

@JoshLove-msft Actually, it would be hard to check if the client is empty in CreateClientCore with only InputClient.
Because we also need to deal with sub-clients which is populated within clientProvider, if the client contains empty sub-clients, we should skip them. But if the sub-clients contains methods, we should not skip the root client.
https://github.com/Azure/azure-sdk-for-net/pull/47859/files#diff-64b049a6da4931ec4ae5b7a5d3fc110140166f14857b9e612167d4450c04a5e8R52-R79 is the corresponding test.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, in that case can we use a visitor to handle this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, in that case can we use a visitor to handle this?

hmm, not easy to achieve this with visitor, either. How can we omit a provider using visitor?

Copy link
Member Author

Choose a reason for hiding this comment

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

As offline discussed, will handle this in MGC as general behavior.
Follow-up work is in microsoft/typespec#5652

@live1206 live1206 changed the title Skip empty clients for Azure Remove static cache Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. CodeGen Issues that relate to code generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants