-
Notifications
You must be signed in to change notification settings - Fork 210
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
Full namespace Issue #4796
Comments
Thanks for raising this @deinok Any chance you'd be willing to submit a PR for this? (cc @peterwurzinger) I believe you'd simply need to
|
Ah sorry, I missed to prepend that in the initial PR - my bad. Just one thing to note regarding implementing the fix: Imo it should be inserted here:
with fullNameBuilder.Insert(0, $"global::{codeNamespace.Name}."); |
How about the other obvious issue that's visible in that picture? The code is completely unreadable, which was caused by recent Kiota changes, adding more prefixes will certainly not help that. |
Before we make any further change, I'd like the input of @maisarissi and @sebastienlevert |
hey @baywet . Per what I could understand there is no other way we can identify whether the namespace will conflict with a type. Is that correct? Because they initial error was all about that scenario. |
I think there are a couple of avenues we can take here:
The challenge with option 2 is that the symbols resolution in CSharp is not clear (and changed slightly when we moved to roselyn as far as I can tell). The rules of thumb of when a symbol might conflict are roughly "whenever is present as a segment of a namespace, as a symbol directly under a imported namespace, as a member name for the current type" and there are probably missing rules here which is why we've had to review the implementation multiple times already. |
Thats another issue, but if it is going in the verbose direction, we need it fully functional and correct. And the only correct way is using the global directive. |
regarding the option 1, I would ask the roslyn team on how to better respresent that and how they do it internally. They probably have much more experience in this kind of issues and can provide insights Regarding on what to choose, yes, option 1 is pretty ugly, as same as ugly as looking at MSIL code. It's generated code and should not be touched by hand, so I really dont care about verbosity, but probably option 1 will give you more flexibility in the future, and you can always try to move to path 2 in the future But im going to say it, if kiota could have a SourceGenerator, i could fix most of the issues about Verbosity as user will not see it in the git, exactly as MSIL is not "shown" in git |
Thanks for the additional context. For everybody's information, we've explored source generators in the past. But the netstandard2.0 limitation had serious performance impacts. Plus our own experience building some of them (updating versions automatically and default settings) has been far from great at this point (debugging and whatnot). I guess the ask for @maisarissi and the community here is roughly: "do we care about generated code readability?" Since our recommendation is that it shouldn't be edited anyway, I lean on "no". I do understand that in some debug scenarios, having access to code that's easier to read makes for a better debugging experience. At that point however, how much could we rely on linting tools and quick formatting to make the experience better? (i.e. is it a documentation issue? are we missing a section "if you want to debug through the code, run this first"? ) |
@baywet Should we fix this issue by prepending the global namespace? While there still might be an ongoing discussion regarding the potential need for a more sophisticated namespace collision detection, it wouldn't really matter if there was a |
Alright, I'd have appreciated for @maisarissi to make a decision on this so we don't do work we'd have to potentially undo later on. |
Yeah I agree, it should have been included in the initial PR right away, I'll create a separate one to fix this issue. |
Regarding the topic of readability. While we will always try to make it as readable as possible, there will always be cases where machine-generated code will need to take a path that impacts the readability of the code in favor of better generation. There are areas where the code is pretty much very readable, where it's a bit less because of the constraints. I don't think we should be peeking into the generated code and we should leave it as is. I see this code to be as opaque as can be while offering really easy debugging and learning experience. So my stance: We should not tax any of our development efforts to make the code "more readable" at the expense of complex solutions. |
I'm in the same page as Sebastien. Even tough it would be awesome to always have as much readable code as possible, having the best generation possible should be our goal. Readability is a plus whenever possible and when it don't come with perf or generation costs. |
I think prefixing with |
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Nuget tool
Client library/SDK language
Csharp
Describe the bug
Moving from v1.14 to v1.15.
I have a a csproj with two Clients.
I have noticed that when I regenerate the client, it adds the full namespace. But it does it without adding the global::
Expected behavior
It adds the global:: insted of not doing it.
I have added it manualy so you can see that it fixes the bug
How to reproduce
Make them clash by namespace.
Just add the global:: when you write the full namespace, you are already doing it be clear about the namespace so it doesn't clash
Open API description file
No response
Kiota Version
1.15.0+b535a94064cd8c14a022aaba42964467d5db525a
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
No response
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: