Closed sayedihashimi closed 8 years ago
With regards to T4, here is a brief(!) summary of my (often stated) thoughts on this:
In T4, we have a tool that is already cross platform, i.e it has been available for over 5 years on Mono, including integration with Mono Develop, Sharp Develop etc, it can be run (through non-Microsoft efforts) on OSX, Linux, Windows. We have a large number of community projects and frameworks in circulation that use T4. As far as I am aware, the Entity Framework team continue to use T4.
Current strengths of T4:
Current weaknesses of T4
Possible Approaches
Scrap T4 and come up with another technology
Enhance T4
As I say, just my initial personal thoughts.
In another thread, it was asked if there were other projects to make T4 cross platform; the good news is yes.
There is a project here by a member of the Entity Framework team and updated to RC1 here byTibor @totht91)
That would indicate it would be possible to incorporate T4 into an Asp.Net 5 pipeline via Gulp, and a command, working cross platform in VS Code, or indeed anything compatible with the dnx.
It also supports Razor syntax
Another obvious example: https://github.com/mono/monodevelop/tree/master/main/src/addins/TextTemplating
Which is published as a NuGet, Copyright 2009-2011 Novell, Inc. 2011-2014 Xamarin Inc. https://www.nuget.org/packages/Mono.TextTemplating/
https://github.com/giacomelli/MonoDevelop.ThoseMissingFeatures
Some more on template runtime errors here: T4MVC/T4MVC#68.
We are using a custom tool to create XXX.Designer.cs from XXX.resx files. For resources whose comments contain an appropriate parameter list, the tool creates type-safe methods instead of properties. In order not to have to revert to old behavior, we would need one of the following:
We will have better support for this in the future. Closing this for now.
@sayedihashimi Are any details about forthcoming single file generator support available? Primarily I'd like to know if the general concept of single file generators will end up being supported or will the support focus exclusively on enabling the common generation scenarios like T4. I'd note that there are some (though admittedly not many) libraries in the community that use the single file generator plumbing to do stuff other than T4/resources (I.e., Scripty).
We're also using a SingleFileGenerator custom tool to generate source code on each save of the file. Is there any workaround to run custom tools on a per-file basis for now? If no, we have to step back to the old project format which is a real downer.
@sayedihashimi : Please, some workaround advice :-) And even better: a roadmap on when we can expect our SFG to work again.
@drauch @all I actually found out that it already works as expected for .NET Core projects. You just have to add another CodeGeneratorRegistration for the new project type (new guid). For the old projects you can use the constant from VSLangProj80.vsContextGuids.vsContextGuidVCSProject ("{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}") For the new projects you need to use the constant "{9A19103F-16F7-4668-BE54-9A1E7A4F7556}" (this is the guid for the new project type, which you can see in the .sln files - you need to add the {} as well!)
You can either enter the code generator in the compile item: <Generator>CustomToolName</Generator>
or you can use the properties dialog (not page) from Visual Studio - however this is for some reason glitched:
a.) in the properties page the CustomTool setting is not avialable anymore
b.) in the properties dialog of the file you can find the CustomTool in Advanced - however you need to add a namespace before adding the custom tool and remove it afterwards again (as you get an exception else and the setting is not stored)
@sayedihashimi / dotnet / aspnet team: Why is the CustomTool settting not displayed in Visual Studio 2017 for the new project format? (Only in the properties dialog)
@Inspyro Thanks for the tip.
Adding a GeneratorRegistration using the new project type constant "{9A19103F-16F7-4668-BE54-9A1E7A4F7556}" worked for me. I can now use single file generators in .NET Core projects in Visual Studio 2017.
@danielcrabtree Exactly where and how did you add this GUID?
I figured it out. I added the GUID to my generator
[ComVisible(true)]
[Guid(GuidList.GuidI18NReactivetring)]
[ProvideObject(typeof(I18NReactive))]
[CodeGeneratorRegistration(typeof(I18NReactive), "I18N.Reactive", vsContextGuids.vsContextGuidVCSProject, GeneratesDesignTimeSource = true)]
[CodeGeneratorRegistration(typeof(I18NReactive), "I18N.Reactive", "{9A19103F-16F7-4668-BE54-9A1E7A4F7556}", GeneratesDesignTimeSource = true)]
public class I18NReactive : IVsSingleFileGenerator, IObjectWithSite
{
While custom tools can be started in VS 2017 15.8.1 on .NET Core 2.1 projects without adding the second registration for us, we are still having issues to use our custom tool. Our custom tool is used for localization and takes a simple text file and converts it to a C# class and two resource files with English and German string resources.
To generate the code and manage the files in the solution our custom tool implements the IObjectWithSite interface. Unfortunately the SetSite method of that interface is never called if the custom tool is started from a .NET Core project and we are not able to access neither the CodeDomGenerator nor the project's items. Adding the GUID to the registration does not help.
Is there a replacement for IObjectWithSite that works with .NET core projects?
We have the same issue as @KZumbusch Even with the latest VS 2017 15.8.3, the custom tool is instantiated, but neither SetSite
nor Generate
is called for multi target project using the new csproj format (class library, <TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
). The custom tool works in old style full framework projects inside the same solution. What should we do?
Any movement on this, @sayedihashimi ? I think three years counts for "later." ;)
We have implemented basic support for
.t4
and.resx
but the implementation is limited and not meeting all the needs. We need to come with a better story there.Open items
internal
versuspublic
I've heard some rumors that we may get support for
.resx
files from the runtime. If that happens we should design it such that we can leverage the same support for other generators.Right now we are busy converting dnx to dotnet so we are not really implementing many features like this. I'd like to see if there is going to be a better story from the runtime before we implement something specific in tooling.
Related issues