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

Ambiguous reference for entities on namespace System #94

Closed
brenovieira opened this issue Jun 3, 2015 · 5 comments
Closed

Ambiguous reference for entities on namespace System #94

brenovieira opened this issue Jun 3, 2015 · 5 comments
Assignees

Comments

@brenovieira
Copy link

I have a class Action.

AutoRest generates a class Action on namespace MyNamespace.Models and
ActionOperations, ActionOperationsExtensions and IActionOperations on namespace MyNamespace.

Methods on both ActionOperations, ActionOperationsExtensions and IActionOperations reference Action and have "using System" which causes an ambigous reference between 'System.Action' and 'MyNamespace.Models.Action'.

I see four solutions:

  • Detect conflit and rename the entity as it already does for ActionOperations.

warning: Client operation with name 'Action' was renamed to 'ActionOperations' because it conflicts with following entities: Action (already used in schema definition)
Please consider changing your swagger specification to avoid naming conflicts.

  • Put all classes and interfaces related to the entity on the same namespace.

For example, put both Action, ActionOperations, ActionOperationsExtensions and IActionOperations on MyNamespace.

  • Add using statement Entity = MyNamespace.Models.Entity on each class and interface generated.

For example, adding "using Action = MyNamespace.Models.Action".

  • Use the entity's full description (MyNamespace.Models.Entity) every time.

Microsoft.Rest.HttpOperationResponse<System.Collections.Generic.IList<MyNamespace.Models.Action>> result = await operations.GetWithOperationResponseAsync(authorization, cancellationToken).ConfigureAwait(false);

@matt-gibbs
Copy link
Contributor

Thanks @brenovieira
I am wary of renaming. I think it will lead to confusion, especially when it comes to the Models.
The full namespace would work but gets a bit ugly to look at. We'll get something worked out. Expect a new release in a few weeks along with the sources to get populated into the repo too. Leaving this open 'til we get the fix in place.

@stankovski
Copy link
Member

This scenario should work as of 0.11.0 since now we are generating usings inside the namespace

@brenovieira
Copy link
Author

@stankovski , 👍

I believe that is right !

@brenovieira
Copy link
Author

@stankovski , please reopen this issue.

I updated to 0.12.0 and it generated the same problem, even with usings inside the namespace.

Please, see what it generated (part of) in this gist.

The lines - 59, 135, 142 - don't compile since it has Action, which is defined in namespace Models and System.

On line 7 you add using System and
on line 20, you add my namespace using Models.

So you define both and it has an ambigous reference.

note:
I have the same issue with a class called Group. Error:
'Group' is an ambigous reference between 'API.Cliente.Models.Group' and 'System.Text.RegularExpressions.Group'.

note2:
I'm not sure I had this issue with 0.11.0 as well or not.

@stankovski stankovski reopened this Oct 30, 2015
@stankovski
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants