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

T4 is failed to run with Unity. #44

Open
shtse8 opened this issue Mar 23, 2021 · 3 comments
Open

T4 is failed to run with Unity. #44

shtse8 opened this issue Mar 23, 2021 · 3 comments

Comments

@shtse8
Copy link

shtse8 commented Mar 23, 2021

I have an issue with Rider T4 and Unity

The issued was first reported in Jetbrains in 2019. but the issue is still here in 2021.

https://youtrack.jetbrains.com/issue/RIDER-37159

Repo Steps:

Make a new Unity Project, open project, update rider in package manager to latest one(just incase older versions cause issues, which was 3.0.5 currently).
Make a random C# script in the Unity Editor and then double click to open with Rider.
Once riders finishes loading add a T4 file via the Rider UI.

Now at this point, I cannot run the file for some reason, the green run button in the left top doesn't seem to work after creating the T4 template.

However after re-starting rider, the run button works. So then I click the preprocess template option.
Boom the new file is now generated into the Unity project root folder, instead of where the T4 file is located.

image

java.lang.NullPointerException: T4 does not operate without Project and/or VirtualFile
	at com.jetbrains.fortea.language.T4FileType$1.getEditorHighlighter(T4FileType.kt:14)
	at com.intellij.openapi.editor.highlighter.EditorHighlighterFactoryImpl.createEditorHighlighter(EditorHighlighterFactoryImpl.java:37)
	at com.intellij.openapi.editor.highlighter.EditorHighlighterFactoryImpl.createEditorHighlighter(EditorHighlighterFactoryImpl.java:47)
	at com.intellij.diff.util.DiffUtil.createEditorHighlighter(DiffUtil.java:183)
	at com.intellij.diff.util.DiffUtil.setEditorHighlighter(DiffUtil.java:194)
	at com.intellij.diff.util.DiffUtil.configureEditor(DiffUtil.java:262)
	at com.intellij.diff.tools.holders.TextEditorHolder.create(TextEditorHolder.java:97)
	at com.intellij.diff.tools.holders.TextEditorHolder$TextEditorHolderFactory.create(TextEditorHolder.java:107)
	at com.intellij.diff.tools.holders.TextEditorHolder$TextEditorHolderFactory.create(TextEditorHolder.java:101)
	at com.intellij.diff.tools.util.side.OnesideDiffViewer.createEditorHolder(OnesideDiffViewer.java:79)
	at com.intellij.diff.tools.util.side.OnesideTextDiffViewer.createEditorHolder(OnesideTextDiffViewer.java:73)
	at com.intellij.diff.tools.util.side.OnesideTextDiffViewer.createEditorHolder(OnesideTextDiffViewer.java:34)
	at com.intellij.diff.tools.util.side.OnesideDiffViewer.<init>(OnesideDiffViewer.java:51)
	at com.intellij.diff.tools.util.side.OnesideTextDiffViewer.<init>(OnesideTextDiffViewer.java:40)
	at com.intellij.diff.tools.simple.SimpleOnesideDiffViewer.<init>(SimpleOnesideDiffViewer.java:57)
	at com.intellij.diff.tools.simple.SimpleDiffTool.createComponent(SimpleDiffTool.java:30)
	at com.intellij.diff.impl.DiffRequestProcessor.createState(DiffRequestProcessor.java:273)
	at com.intellij.diff.impl.DiffRequestProcessor.lambda$doApplyRequest$4(DiffRequestProcessor.java:348)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:218)
	at com.intellij.diff.impl.DiffRequestProcessor.lambda$doApplyRequest$5(DiffRequestProcessor.java:342)
	at com.intellij.diff.util.DiffUtil.runPreservingFocus(DiffUtil.java:760)
	at com.intellij.diff.impl.DiffRequestProcessor.doApplyRequest(DiffRequestProcessor.java:332)
	at com.intellij.diff.impl.DiffRequestProcessor.lambda$applyRequest$3(DiffRequestProcessor.java:314)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.lambda$doWhenFocusSettlesDown$3(FocusManagerImpl.java:182)
	at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:101)
	at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.java:188)
	at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.java:140)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:173)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:179)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.doWhenFocusSettlesDown(IdeFocusManagerImpl.java:41)
	at com.intellij.diff.impl.DiffRequestProcessor.applyRequest(DiffRequestProcessor.java:322)
	at com.intellij.diff.impl.DiffRequestProcessor.applyRequest(DiffRequestProcessor.java:301)
	at com.intellij.diff.impl.CacheDiffRequestProcessor.lambda$updateRequest$0(CacheDiffRequestProcessor.java:117)
	at com.intellij.openapi.progress.util.BackgroundTaskUtil.finish(BackgroundTaskUtil.java:111)
	at com.intellij.openapi.progress.util.BackgroundTaskUtil.executeAndTryWait(BackgroundTaskUtil.java:99)
	at com.intellij.diff.util.DiffTaskQueue.executeAndTryWait(DiffTaskQueue.java:47)
	at com.intellij.diff.util.DiffTaskQueue.executeAndTryWait(DiffTaskQueue.java:38)
	at com.intellij.diff.impl.CacheDiffRequestProcessor.updateRequest(CacheDiffRequestProcessor.java:112)
	at com.intellij.diff.impl.CacheDiffRequestProcessor.updateRequest(CacheDiffRequestProcessor.java:91)
	at com.intellij.diff.impl.DiffRequestProcessor.updateRequest(DiffRequestProcessor.java:184)
	at com.intellij.diff.impl.DiffRequestProcessor.updateRequest(DiffRequestProcessor.java:179)
	at com.intellij.openapi.vcs.changes.ChangeViewDiffRequestProcessor.setCurrentChange(ChangeViewDiffRequestProcessor.java:178)
	at com.intellij.openapi.vcs.changes.ChangeViewDiffRequestProcessor.refresh(ChangeViewDiffRequestProcessor.java:159)
	at com.intellij.openapi.vcs.changes.EditorTabPreview.openPreview(EditorTabPreview.kt:134)
	at com.intellij.openapi.vcs.changes.EditorTabPreview$openWithSingleClick$1$1.invoke(EditorTabPreview.kt:59)
	at com.intellij.openapi.vcs.changes.EditorTabPreview$openWithSingleClick$1$1.invoke(EditorTabPreview.kt:36)
	at com.intellij.openapi.vcs.changes.EditorTabPreview$installSelectionChangedHandler$1$1.run(EditorTabPreview.kt:100)
	at com.intellij.util.ui.update.DisposableUpdate$1.doRun(DisposableUpdate.java:31)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
	at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:254)
	at com.intellij.util.ui.update.DisposableUpdate.run(DisposableUpdate.java:19)
	at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:333)
	at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:323)
	at com.intellij.util.ui.update.MergingUpdateQueue.lambda$flush$1(MergingUpdateQueue.java:273)
	at com.intellij.util.ui.EdtInvocationManager.invokeAndWaitIfNeeded(EdtInvocationManager.java:148)
	at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2115)
	at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:284)
	at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:242)
	at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
	at com.intellij.util.Alarm$Request.runSafely(Alarm.java:369)
	at com.intellij.util.Alarm$Request.run(Alarm.java:355)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:220)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:218)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:200)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:781)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:319)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:969)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:839)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:449)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:808)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:781)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:496)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
@pixelpax
Copy link

pixelpax commented Aug 20, 2021

I have a similar issue! Bump!

I made a jetbrains bug report here but I suspect the issue is actually within this repo!

@pixelpax
Copy link

@kirillgla this strikes me as P0, since it prevents any execution and fails to communicate problem details to user.

I would be willing to help with this because I really want to use this tool, but I would need guidance since I'm very out of my depth here.

@pixelpax
Copy link

Ok-- @kirillgla I found the workaround you posted. I think this resolves the worst of the problem:

you need to open Edit > Project Settings > Editor > C# Project Generation, edit Additional extensions to include and add the following extensions to it: tt;t4;ttinclude. Then you need to re-generate project files (which can be done using Edit > Preferences > External Tools > Regenerate project files).

Thank you! And thank you for all the hard work you did to make this excellent extension! It would be nice to have this added to the jetbrains unity package, since this was difficult to track down.

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