1

Closed

generator declaration line not on first line

description

The "generator declaration line" needs to be on the very first line of the file.

Problem is that we--and I assume many other folks--have a standard licence header at the top of all our files, and it is generated dynamically, so we cannot change it.

Is it possible for this addin to search for the "generator declaration line" instead of assume it is on line 1? I assume it should be easy enough to find it as it is well defined, one only needs to search for "@* Generator:" and then "**@". Otherwise a fantastic tool!
Closed Apr 20, 2012 at 9:34 PM by davidebbo
Closing as this issue has not come up since

comments

davidebbo wrote Jul 22, 2011 at 5:05 PM

It's conceivable, but couple questions for you first:
  1. Are you aware that in many scenarios, you can omit this line and we will choose the right generator based on the project type and file location? What generator are you using specifically?
  2. Can you explain how your license header is generated dynamically? Do you mean it's generated at runtime? But if that were the case it wouldn't affect the generator. Can you clarify?

bugmenot2 wrote Jul 22, 2011 at 5:21 PM

  1. Yes you can omit it. But with a non-standard solution structure it doesn't always work as expected and results in a file which complains about choosing the correct generator :) I tried the "MvcHelper" and "WebPagesHelper".
  2. No not at runtime. Well we have a tool which saves the license header to the very top of the file, every time the file is saved in VS. It is very similar to this tool out of interest: http://licensemanager.codeplex.com/. We also have an automated version of the tool which does this during MSBUILD runs, but in either case it will not affect the generator. Perhaps I added too much complexity to the question - the gist of it is whether it is possible to make the declaration not on line 1? By your reply I assume this is not the case right now.
I should point out however, that there seem to be more and more projects which somehow manipulate code files, and they all want THEIR config stuff to be the first line in the file. This is because it is the easiest approach - I know because I am guilty of doing the same thing in all of our projects!! :-)

pranavkm wrote Jul 22, 2011 at 6:14 PM

We do have a partial workaround in that you could specify a generator for the entire project by dropping a file named "razorgenerator.directives" in the project root and putting your directives in there sans the comment block (@* and **@). Certainly doesn't help when you want to mix and match files and it would hijack the heuristic-based determination of the generator.

bugmenot2 wrote Jul 22, 2011 at 7:20 PM

Just so I understand, it would use the same generator for all files? I guess it may be sufficient in some cases, but inflexible in others.

Scanning for the directive is probably the cleanest option, but on second thought, it may not be that straighforward to accomplish which is why we always stick our config stuff on line 1 instead of wrestle with parsing using VS EnvDTE (which I suspect is what this tool uses).

davidebbo wrote Jul 22, 2011 at 9:31 PM

We could try to support that .directives file at each folder level, so it's not necessarily for the entire app.

Could you give more details on your non-standard solution structure where the heuristic doesn't work? It may be possible to make it smarter to cover more scenarios.

Of course, doing the directive scan is possible, but ideally we'd like to avoid it :)