Skip to content

VS2022 & VS2019 support#65

Open
hippasus wants to merge 19 commits into
olegsych:masterfrom
hippasus:vs2022
Open

VS2022 & VS2019 support#65
hippasus wants to merge 19 commits into
olegsych:masterfrom
hippasus:vs2022

Conversation

@hippasus

Copy link
Copy Markdown

Hi Oleg,

I've managed to make this excellent tool targeting to both Visaul Studio 2019 and Visual Studio 2022.

It is still using deprecated APIs, however, it works.

Hippasus.

@hippasus hippasus changed the title VS2020 & VS2019 support VS2022 & VS2019 support Nov 14, 2021
@hippasus

Copy link
Copy Markdown
Author

For anyone who want to use this tool, I'm uploading the built VSIX file here.
For Visual Studio 2019: T4Toolbox.16.0.0.0.vsix.zip
For Visual Studio 2022: T4Toolbox.17.0.0.0.vsix.zip

@islaytitans

Copy link
Copy Markdown

This works a treat, thanks @hippasus

@bn-obelu

bn-obelu commented Aug 4, 2022

Copy link
Copy Markdown

Thank you for great work!

It stopped working since VS 17.2.4 update.

Severity	Code	Description	Project	File	Line	Suppression State
Error		Running transformation: System.Runtime.Serialization.SerializationException: Type 'Microsoft.VisualStudio.CommonIDE.Solutions.Dte.DteProjects' in Assembly 'Microsoft.VisualStudio.CommonIDE, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.

Server stack trace: 
   at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize)
   at System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage..ctor(IMethodReturnMessage mrm)
   at System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.SmuggleIfPossible(IMessage msg)
   at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm)
   at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at EnvDTE._Solution.get_Projects()
   at Microsoft.VisualStudio.TextTemplatingB5EC13400F541F31CD2FF70C4DE270BF66420DA4352A9431CD2EB6412E99ACEBEDB91B4DA7F9C256938CE1D4BEBE32F59E9FD89030A3D4D1ED0703898B13BE6D.GeneratedTextTransformation.IdeUtils.FindProject(DTE dte, String name) in C:\introniseng\qa\Automation.CodeGeneration\T4\IdeUtils.tt:line 16
   at Microsoft.VisualStudio.TextTemplatingB5EC13400F541F31CD2FF70C4DE270BF66420DA4352A9431CD2EB6412E99ACEBEDB91B4DA7F9C256938CE1D4BEBE32F59E9FD89030A3D4D1ED0703898B13BE6D.GeneratedTextTransformation.TransformText() in C:\introniseng\qa\Automation.Maestro\MaestroClassGenerator.tt:line 9	Miscellaneous Files	C:\introniseng\qa\Automation.CodeGeneration\T4\IdeUtils.tt	16	

@hippasus

hippasus commented Aug 5, 2022

Copy link
Copy Markdown
Author

it works on my computer, I'm using VS 17.2.5.

could you please show me your .tt file, are you using something like IServiceProvider.GetService ?

@bn-obelu

bn-obelu commented Aug 8, 2022

Copy link
Copy Markdown

Yes, I was using GetService, now it works with GetCOMService. One thing that I think is not working, if I update a template, the generator dosen't update the file with the changes, any ideea why?

@qideqian

Copy link
Copy Markdown

@hippasus it possible to install in vs2022, but it still cannot be used, presumably because the plug-in implementation is based on.netframwork, and the project I refer to is based on .net8 class library, I wonder if it can be solved?
var types = typeof(BaseEntity).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseEntity)));
The BaseEntity is a base class in the.NET 8 class library.

@hippasus

Copy link
Copy Markdown
Author

@hippasus it possible to install in vs2022, but it still cannot be used, presumably because the plug-in implementation is based on.netframwork, and the project I refer to is based on .net8 class library, I wonder if it can be solved? var types = typeof(BaseEntity).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseEntity))); The BaseEntity is a base class in the.NET 8 class library.

It can be installed in vs2022 and it just works. I never tried it on net8.0, was using it with .netstandard2.0.

@qideqian

Copy link
Copy Markdown

@hippasus it possible to install in vs2022, but it still cannot be used, presumably because the plug-in implementation is based on.netframwork, and the project I refer to is based on .net8 class library, I wonder if it can be solved? var types = typeof(BaseEntity).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseEntity))); The BaseEntity is a base class in the.NET 8 class library.可以在 VS2022 中安装,但还是不能使用,大概是因为插件实现是基于 .netframwork,而我提到的项目是基于 .net8 类库的,不知道能不能解决? var types = typeof(BaseEntity).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseEntity))); BaseEntity 是 the.NET 8 类库中的基类。

It can be installed in vs2022 and it just works. I never tried it on net8.0, was using it with .netstandard2.0.它可以安装在 vs2022 中,并且它就可以正常工作。我从未在 net8.0 上尝试过它,而是将其与 .netstandard2.0 一起使用。

Will.net8 be supported later? After all, the version gap between the merged .NET and .netfromwork is relatively large, and some basic class libraries may not be available in plug-ins written with .netfromwork, such as System.Runtime.

@hippasus

Copy link
Copy Markdown
Author

@hippasus it possible to install in vs2022, but it still cannot be used, presumably because the plug-in implementation is based on.netframwork, and the project I refer to is based on .net8 class library, I wonder if it can be solved? var types = typeof(BaseEntity).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseEntity))); The BaseEntity is a base class in the.NET 8 class library.可以在 VS2022 中安装,但还是不能使用,大概是因为插件实现是基于 .netframwork,而我提到的项目是基于 .net8 类库的,不知道能不能解决? var types = typeof(BaseEntity).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseEntity))); BaseEntity 是 the.NET 8 类库中的基类。

It can be installed in vs2022 and it just works. I never tried it on net8.0, was using it with .netstandard2.0.它可以安装在 vs2022 中,并且它就可以正常工作。我从未在 net8.0 上尝试过它,而是将其与 .netstandard2.0 一起使用。

Will.net8 be supported later? After all, the version gap between the merged .NET and .netfromwork is relatively large, and some basic class libraries may not be available in plug-ins written with .netfromwork, such as System.Runtime.

just tried with .net8, it works just fine. could you share more information about your tt file?

@qideqian

Copy link
Copy Markdown

@hippasus

Copy link
Copy Markdown
Author

@hippasus TestT4Toolbox.zip image

I saw what you were doing... interesting... you were referencing a .net8.0 dll in your text template file. Maybe you can find a modern way to generate code Introducing C# Source Generators

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

Successfully merging this pull request may close these issues.

4 participants