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

AnnotatedCodeGeneratorFactory writes namespace and using statements in wrong order #9

Closed
davidwincent opened this issue Sep 30, 2014 · 9 comments

Comments

@davidwincent
Copy link

Expected behaviour to put using statements first in generated class file

@davidwincent
Copy link
Author

Created public gist: https://gist.github.com/davidwincent/69a8d8de2416ba674b44
Default.cs is the generated class file.

@davidwincent
Copy link
Author

Turns out that it works as long as you don't use the word Umbraco in namespace. Perhaps solution suggested in #6 solves the same problem?

@lars-erik
Copy link
Owner

I don't agree that it's wrong, but I can agree it's a matter of taste. :)
However, I don't see that the way generated files order it's using statements have any impact on the quality of the code. You're free to put them elsewhere in the partials.
For the record, I usually have them first myself, but since it clashes with the Umbraco part, I've put them inside for now. Don't think I want to change namespace now.

@davidwincent
Copy link
Author

Ah, OK! I agree.

What would I need to do to change the formatting?
Write a custom CodeGenerator?

@lars-erik
Copy link
Owner

Sorry, I've been confusing things here.
I never hit this problem since my projects always have namespace CustomerName.Web.
Is there really a good reason to include Umbraco in your namespace?
You can also configure codegen to use another namespace for the generated classes, then you're home free.

@davidwincent
Copy link
Author

No specific reason to include Umbraco in the namespace. I found the problem by accident when I was testing in that namespace.
Having said that it still looks odd to me having the using statements wrapped inside the namespace declaration. I usually put them in the beginning of the file. 🙏

@lars-erik
Copy link
Owner

I had to put them inside due to some other namespace conflicts. :D

@davidwincent
Copy link
Author

No problem. Then I know there is a reason. I think this project could be the missing link in my past U7 projects. Nicely done!

@lars-erik
Copy link
Owner

:)

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

2 participants