R# 6: Live Templates broken

I have a live template for registering an attached property. When I insert it, R# 6 replaces all template parameters with the literal "a", and doesn't allow me to edit them. The active code window also stops accepting the return and tab keys until I hit escape, or close it and re-open it.

If I change the template to remove the XML comments from either the Get or Set method, the template starts working again.

R# 5 was able to use this template without any problems.

Clearing the caches makes no difference. Restarting Visual Studio makes no difference.

For once, I can reproduce this bug in any solution.


The template:

/// <summary>
/// Identifies the $NAME$ attached property. This field is read-only.
/// </summary>
/// <value>
/// The identifier for the $NAME$ attached property.
/// </value>
public static readonly System.Windows.DependencyProperty $NAME$Property = System.Windows.DependencyProperty.RegisterAttached(
     "$NAME$", typeof($TYPE$), typeof($CLASS$),
     new System.Windows.PropertyMetadata($DEFAULT$));

/// <summary>
/// Gets the value of the $NAME$ attached property for a specified element.
/// </summary>
/// <param name="element">
/// The element from which the property value is read.
/// </param>
/// <returns>
/// The $NAME$ property value for the specified element.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="element"/> is <see langword="null"/>.
/// </exception>
public static $TYPE$ Get$NAME$(System.Windows.DependencyObject element)
{
     if (null == element) throw new ArgumentNullException("element");
     return ($TYPE$)element.GetValue($NAME$Property);
}

/// <summary>
/// Sets the value of the $NAME$ attached property for a specified element.
/// </summary>
/// <param name="element">
/// The element to which the property value is written.
/// </param>
/// <param name="value">
/// The new value of the $NAME$ property for the specified element.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="element"/> is <see langword="null"/>.
/// </exception>
public static void Set$NAME$(System.Windows.DependencyObject element, $TYPE$ value)
{
     if (null == element) throw new ArgumentNullException("element");
     element.SetValue($NAME$Property, value);
}


What R#6 inserts:

/// <summary>
/// Identifies the a attached property. This field is read-only.
/// </summary>
/// <value>
/// The identifier for the a attached property.
/// </value>
public static readonly DependencyProperty aProperty = DependencyProperty.RegisterAttached(
     "a", typeof(a), typeof(a),
     new PropertyMetadata(a));

/// <summary>
/// Gets the value of the a attached property for a specified element.
/// </summary>
/// <param name="element">
/// The element from which the property value is read.
/// </param>
/// <returns>
/// The a property value for the specified element.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="element"/> is <see langword="null"/>.
/// </exception>
public static a Geta(DependencyObject element)
{
     if (null == element) throw new ArgumentNullException("element");
     return (a)element.GetValue(aProperty);
}

/// <summary>
/// Sets the value of the a attached property for a specified element.
/// </summary>
/// <param name="element">
/// The element to which the property value is written.
/// </param>
/// <param name="value">
/// The new value of the a property for the specified element.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="element"/> is <see langword="null"/>.
/// </exception>
public static void Seta(DependencyObject element, a value)
{
     if (null == element) throw new ArgumentNullException("element");
     element.SetValue(aProperty, value);
}


The exported template is attached.



Attachment(s):
registerpropattach.xml
5 comments

I've just reproduced this on another PC, with no other add-ins or extensions installed, and no other templates.

0

Hello Richard,

I confirm that this is a bug and you're welcome to monitor it status at http://youtrack.jetbrains.net/issue/RSRP-274529.
Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

http://devnet.jetbrains.net/message/5312733#5312733



0

I have reproduced this problem, including that the code window won't accept <Enter> or <Tab> until you hit <ESC> and the 'a' text replacements **WITHOUT** XML comments, so I think that might be a red herring (not related).

See the bug that I logged in August.  I spent quite some time narrowing it down to a simple reproducable case - to the point where I was able to get it to work properly or break with the deletion of a line or two.  Unfortunately, it wasn't anything obvious like XML comments - I was even able to break it by deleting a couple BLANK lines!  See http://youtrack.jetbrains.net/issue/RSRP-275177

This also looks like the same issue as RSRP-274356 Some Live Templates no longer work after upgrade to R# 6

Also, JetBrains - perhaps this bug does not affect all users for whatever reason, but this is a showstopper bug of a major feature that should be fixed without waiting for the next version release!  I found three separate reported bugs of this issue going back to the beginning of July - with each report providing a test file for their reproducible case.  My bug does not appear to have been reviewed yet even though it was reported in August.

I saw the comment on this link that "We implemented new LiveTemplate and Settings engine in upcoming R# 6.1 bug fix update".  While the new engine may very well be fantastic, I'm worried that if there are new bugs introduced with the new engine, then it will be 6.2 or even 7.0 before they get fixed and it is usable - please tell me I'm wrong!

0

Hello Scott,

Most of the bugs you've mentioned are marked as 'Critical' and 'Show-stopper'
for ReSharper 6.1, so it is very likely that they will get fixed. Also, I've
asked the developer to review these bugs and make sure that they will get
addressed. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

http://devnet.jetbrains.net/message/5390587#5390587



0

Thanks

It would be nice if you could provide some sort of guidance like 'don't create templates with comments/make sure there are an even number of lines/etc. if you guys discover what triggers it.  About 50% of my templates are triggering this bug, thus the entire feature is fairly unusable for me at this point.

Here is relevant info from the log (devenv /ReSharper.LogFile C:\resharper_log.txt /ReSharper.LogLevel Verbose):

2:49:58 PM.796: Thread:1: Adding file [MyFilePath]\Class1.cs

2:49:58 PM.796: Thread:1: Project item [MyFilePath]\Class1.cs has already been created

2:49:58 PM.796: Thread:1: Saving unopened document for the file <Unit Tests>\<[MyProjectName].Facade.Tests>\Class1.cs

2:49:58 PM.796: Thread:1: +SaveDocumentAfterModiciation

2:49:58 PM.796: Thread:1: -SaveDocumentAfterModiciation

    2:49:58 PM.828: Thread:1: OnRegisterTextBuffer:adding mapping, doc info:, projectFile:<Unit Tests>\<[MyProjectName].Facade.Tests>\Class1.cs

    2:49:58 PM.828: Thread:1: VSDocumentOperationsHandler::ConnectToStream, id 8787797 text stream:11981316

2:49:58 PM.843: Thread:1: VSDocumentOperationsHandler::OnLoadCompleted, id 8787797

2:49:58 PM.890: Thread:1: RECENT FILE TRACKER. Adding file location: project file - Class1.cs, caret offset - 0. Time: 11/9/2011 2:49:58 PM

2:49:59 PM.203: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.562: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.578: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.578: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.593: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.609: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.609: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.609: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.609: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.609: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.625: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.640: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.640: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.640: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.640: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.640: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.640: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:49:59 PM.890: Thread:1: VSFormatSettingsSynchronizer:DisableVSAutoFormatting

2:49:59 PM.906: Thread:1: VSFormatSettingsSynchronizer:RestoreVSAutoFormatting:System.Collections.Stack

2:50:00 PM.406: Thread:1: EXCEPTION: An exception has occurred during action 'Template8' execution. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

An exception has occurred during action 'Template8' execution. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index


--- EXCEPTION #1/2 [ArgumentOutOfRangeException]


Message = “Index was out of range. Must be non-negative and less than the size of the collection.”
ExceptionPath = Root.InnerException
ClassName = System.ArgumentOutOfRangeException
HResult = COR_E_ARGUMENTOUTOFRANGE=80131502
Source = mscorlib
ParamName = index
StackTraceString = “
  at System.ThrowHelper.ThrowArgumentOutOfRangeException()
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots.Hotspot.CreateExpressionContext()
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots.Hotspot.GetLookupItems()
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots.Hotspot.Evaluate()
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots.HotspotSessionBase.EvaluateHotspot(Hotspot hotspot)
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots.HotspotSession.GoToNextHotspot()
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots.HotspotSession.StartSession()
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots.HotspotSessionExecutor.ExecuteSession(HotspotSession hotspotSession, IDisposable tryFinallyCookie)
     at JetBrains.ReSharper.LiveTemplates.FileTemplates.FileTemplatesManagerImpl.CreateFileFromTemplate(String fileNameNoExtension, IProjectFolder targetFolder, Template template, Action`1 init)
     at JetBrains.ReSharper.Feature.Services.LiveTemplates.FileTemplates.FileFromTemplateActionHandler.Execute(IDataContext context, DelegateExecute nextExecute)
     at JetBrains.ActionManagement.ExecutableAction.Execute(IDataContext context)

--- Outer ---

--- EXCEPTION #2/2 [LoggerException]
Message = “
  An exception has occurred during action 'Template8' execution. Index was out of range. Must be non-negative and less than the size of the collection.
  Parameter name: index

ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
  at JetBrains.ActionManagement.ExecutableAction.Execute(IDataContext context)
     at JetBrains.ActionManagement.ActionManager.CoreExecuteAction(IExecutableAction action, IDataContext context)
     at JetBrains.VsIntegration.ActionManagement.VsActionManager.CoreExecuteAction(IExecutableAction action, IDataContext context)
     at JetBrains.ActionManagement.ActionManager.<>c__DisplayClass6.<ExecuteActionIfAvailable>b__5(Lifetime lifetime)
     at JetBrains.DataFlow.Lifetimes.Using[TRetVal](Func`2 F)
     at JetBrains.ActionManagement.ActionManager.ExecuteActionIfAvailable(IExecutableAction action, IDataContext dataContext)
     at JetBrains.VsIntegration.ActionManagement.VsActionManager.OleCommandTargetExec_Product(String actionid, Boolean isAuxiliaryCommand, IntPtr vIn, IntPtr vOut)
     at JetBrains.VsIntegration.ActionManagement.VsActionManager.<>c__DisplayClass20.<OleCommandTargetExec>b__1d()
     at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action)
     at JetBrains.Threading.ReentrancyGuard.TryExecute(String name, Action action)
     at JetBrains.VsIntegration.ActionManagement.VsActionManager.OleCommandTargetExec(CommandID commandid, OLECMDEXECOPT nCmdExecOpt, IntPtr vIn, IntPtr vOut, VsCommandHandlerStage stage)
     at JetBrains.VsIntegration.ActionManagement.VsActionManager.<Init>b__54(CommandID commandid, OLECMDEXECOPT opt, IntPtr in, IntPtr out)
     at JetBrains.VsIntegration.Package.VsPackageSdkStub.Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget.Exec(Guid& guidGroup, UInt32 nCmdId, UInt32 nCmdExcept, IntPtr vIn, IntPtr vOut)
     at Microsoft.VisualStudio.Shell.Interop.IVsUIDataSource.Invoke(String verb, Object pvaIn, Object& pvaOut)
     at Microsoft.Internal.VisualStudio.PlatformUI.DataSource.Invoke(String verb, Object pvaIn, Object& pvaOut)
     at Microsoft.VisualStudio.PlatformUI.VsCommand.Execute(Object parameter)
     at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
     at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
     at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
     at System.Windows.Threading.DispatcherOperation.InvokeImpl()
     at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
     at System.Threading.ExecutionContext.runTryCode(Object userData)
     at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Windows.Threading.DispatcherOperation.Invoke()
     at System.Windows.Threading.Dispatcher.ProcessQueue()
     at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
     at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
     at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
     at Microsoft.VisualStudio.PlatformUI.NativeMethods.DispatchMessage(MSG& lpmsg)
     at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.<PushMessageLoopOnContextMenuTrackingComponent>b__72(Object sender, PreTranslateMessageEventArgs args)
     at Microsoft.VisualStudio.PlatformUI.OleComponentSupport.OleComponent.FPreTranslateMessageCore(MSG[] pMsg)
     at Microsoft.VisualStudio.PlatformUI.OleComponentSupport.OleComponent.Microsoft.VisualStudio.OLE.Interop.IOleComponent.FPreTranslateMessage(MSG[] pMsg)
     at Microsoft.VisualStudio.OLE.Interop.IOleComponentManager.FPushMessageLoop(UInt32 dwComponentID, UInt32 uReason, IntPtr pvLoopData)
     at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.PushMessageLoopOnContextMenuTrackingComponent()
0

Please sign in to leave a comment.