Open cataggar opened 1 year ago
I'm not sure what is causing this change. The line MgmtContext.Context.DefaultNamespace.Split('.').Last()
looks like it should result in Avs
as the prefix.
This broke when we upgraded from 3.0.0-beta.20230531.2
to 3.0.0-beta.20230804.1
. It looks like it was caused by
cc @ArcturusZhang @m-nash
How do I get the prefix to be just Avs
like before?
The use case is that we generating test clients for different API versions. They are in different C# projects and different C# namespaces.
Before Avs
was the prefix. With the #3470 change, V20230901Avs
is the prefix, which is not what I want.
This is by design, we made this change because we need to ensure as much as possible that types in different namespaces to have different names.
There are two RPs Azure.ResourceManager.PostgreSql.FlexibleServers
and Azure.ResourceManager.MySql.FlexibleServers
which contains very similar models therefore we have to change the logic to take everything after Azure.ResourceManager to make sure there model factory could have a different name.
I understand, but that breaks our use case. A safer alternative would have been a way to configure the name and then configure the name for those RPs. Now, adding a way to configure it would also be a solution to unbreak my use case. Can you point me to the code for this logic? Is it different just for Azure.ResourceManager
?
I understand, but that breaks our use case. A safer alternative would have been a way to configure the name and then configure the name for those RPs. Now, adding a way to configure it would also be a solution to unbreak my use case. Can you point me to the code for this logic? Is it different just for
Azure.ResourceManager
?
Sorry I forgot to include the solution on my previous comment. You could use the rename-mapping
functionality to rename a thing to whatever you want. You could find some document around this here: https://github.com/Azure/autorest.csharp/blob/73514b6dde9b060462c2b82c82ba8bbf2d5d1a70/docs/mgmt/polishing.md#rename-a-type
@ArcturusZhang, that workaround only appears to work for models. There are several other files impacted including the model factory and these:
@ArcturusZhang, that workaround only appears to work for models. There are several other files impacted including the model factory and these:
Oh - for these, you could use customization code to add something like:
[CodeGenType("ThePreviousGeneratedName")] // for instance you could `v2023_03_01AvsExtensions` here
public partial class YourNewName
{} // it does not need to contain anything inside this partial class
In the meantime, I believe it should be somewhere that we could assign the "rp name". I will have an investigation to see where we could put it
The bahavior of
prepend-rp-prefix
has changed. It no longer takes the last word after the last dot for the RP Name. For<RootNamespace>Azure.ResourceManager.Aaa.Bbb.Avs</RootNamespace>
it used to calculateAvs
as the RP prefix. Now it calculatesAaaBbbAvs
as the RP prefix.Is there a way for me to get back the previous behavior? Or is there a way for me to explicitly set the RP prefix as
Avs
in the csproj or autorest.md`?