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

Autocompletion issues with preprocessed templates #28

Open
ltrzesniewski opened this issue Apr 17, 2020 · 10 comments
Open

Autocompletion issues with preprocessed templates #28

ltrzesniewski opened this issue Apr 17, 2020 · 10 comments

Comments

@ltrzesniewski
Copy link

Here's something I noticed:

  • Create any T4 preprocessed template, for instance:
<#@ template language="C#" #>
Hello!
  • Run the "Preprocess Template" action

image

  • Try to use it from C#:
var test = new Test();
test.TransformText();
  • The IDE does not suggest Test in the autocompletion popup, but does suggest TestBase:

image

  • The TransformText method is not present in the suggestions either:

image

  • Go to definition does not work on the type or the method.

Tested with Rider 2020.1, with the bundled 2020.1.157 version of the plugin.

@kirillgla
Copy link
Contributor

Thank you for reporting that! Is that specific to preprocessed templates, or do you expect to see those symbols in completion in executable templates, too?

@ltrzesniewski
Copy link
Author

I'm not sure I understand your question, as preprocessed templates are executable templates in my understanding. I'm basically talking about the TextTemplatingFilePreprocessor generator, which always generates a class with a TransformText method.

@kirillgla
Copy link
Contributor

kirillgla commented Apr 18, 2020

Yes, I totally agree that those symbols should be visible in preprocessed files, because that's what you'd get if you edited the C# file directly. By 'executable' I mean templates with TextTemplatingFileGenerator generator. That generator also generates a class and the TransformText method behind the scenes, but should they be visible in completion? I mean, in templates with TextTemplatingFileGenerator those symbols just look like implementation details that are not intended to be accessed from C# code in T4 file, aren't they?

@ltrzesniewski
Copy link
Author

ltrzesniewski commented Apr 18, 2020

I don't expect to see the template class generated by TextTemplatingFileGenerator in the completion. This is an implementation detail as you say, and not part of the project. Only the result of template execution should be visible in the project.

Actually, the way I see it is pretty simple: executing a TextTemplatingFileGenerator or a TextTemplatingFilePreprocessor generator will produce an output file next to the .tt file. TextTemplatingFilePreprocessor always produces a .cs file, and TextTemplatingFileGenerator can produce any file type. I do not expect Rider to treat this file in any particular way. Just let the IDE handle it like any other file in the project. The template output file should not be of any concern to ForTea.

Currently, there is definitely some special treatment attached to the output of a T4 template. This issue along with the fixed #20 and #15 demonstrate that. If the output file was handled like any other file, none of these three issues would have occurred.

@kirillgla
Copy link
Contributor

I agree. I'll fix that once I can; it shouldn't be difficult

@kirillgla
Copy link
Contributor

Done. The fix should be publicly available in 2020.2 EAP 1

@ltrzesniewski
Copy link
Author

Thanks! 👍

@ltrzesniewski
Copy link
Author

Hi again @kirillgla, I noticed an issue in 2020.2 EAP 2 and I suppose it's related to this.

A call to TransformText yields an "ambiguous invocation" error:

image

image

image

@ltrzesniewski
Copy link
Author

I'm unable to reproduce this issue in a new solution, but here's some stuff I noticed:

  • The template code was generated by the VS T4 generator
  • When I regenerated it with the ForTea generator, the error disappeared
  • That "Create the template output" documentation summary is generated in the template code by the T4 generator (both the VS and the ForTea one).
  • Rider doesn't display the "Create the template output" summary in the TransformText call tooltip when the error does not appear.
  • A custom base class was used by the template (I don't know if that's important)

I hope that helps.

@kirillgla
Copy link
Contributor

Thank you for the report! I'll investigate that

@kirillgla kirillgla reopened this Jul 17, 2020
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