Skip to content

DynamicTextTransformation fails since GenerationEnvironment property is now public #9

Description

@gitfool

FWIW, I just tried using this tool with Visual Studio 2022 (17.9.0 Preview 5.0) and it failed with the following error:

Error		Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TextTemplating375A1FF1DB56D345CF6C793FF482ACD833FB60B96D9461371457541944B520BF4D9710C7CED185C0A8F727B5DB680AD493A29F76721197FB9A90D2CF2F62367B.GeneratedTextTransformation.DynamicTextTransformation.get_GenerationEnvironment()
   at Microsoft.VisualStudio.TextTemplating375A1FF1DB56D345CF6C793FF482ACD833FB60B96D9461371457541944B520BF4D9710C7CED185C0A8F727B5DB680AD493A29F76721197FB9A90D2CF2F62367B.GeneratedTextTransformation.EntityFrameworkTemplateFileManager..ctor(Object textTransformation)
   at Microsoft.VisualStudio.TextTemplating375A1FF1DB56D345CF6C793FF482ACD833FB60B96D9461371457541944B520BF4D9710C7CED185C0A8F727B5DB680AD493A29F76721197FB9A90D2CF2F62367B.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.VsEntityFrameworkTemplateFileManager..ctor(Object textTemplating)
   at Microsoft.VisualStudio.TextTemplating375A1FF1DB56D345CF6C793FF482ACD833FB60B96D9461371457541944B520BF4D9710C7CED185C0A8F727B5DB680AD493A29F76721197FB9A90D2CF2F62367B.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.Create(Object textTransformation)
   at Microsoft.VisualStudio.TextTemplating375A1FF1DB56D345CF6C793FF482ACD833FB60B96D9461371457541944B520BF4D9710C7CED185C0A8F727B5DB680AD493A29F76721197FB9A90D2CF2F62367B.GeneratedTextTransformation.TransformText()	Test	D:\Devel\gitfool\Test\Scripts\TypeLite.tt	1	

But I then managed to get it to work by changing TypeLitePlus.T4/Scripts/Manager.ttinclude#L464 from:

_generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic);

to:

_generationEnvironment = type.GetProperty("GenerationEnvironment");

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions