Many surround with templates unavailable

I just upgraded to 4.5.1225 from 4.1.933, this is the first thing I tried after loading my solution.

Select some code and press Ctrl+Alt+J for surround with templates

Dialog pops-up offering
#region  5
#if...#endif   6
{}    7
More...

My 4.1 install was configured to offer several more surround with options, so a small issue is the options changed during upgrade.  There is a bigger issue keep reading.

I'm looking for try...finally so I select More

Choose Template dialog pops-up

I expand Predefined Templates node

Under c# the only available templates are
#if...#endif
#region
{}

Problem:  Where are the rest of the templates???

Continuing to investigate...

Close Choose Template dialog and
Click Reshaper > Live Templates menu item
Templates Explorer dialog appears
Select the Surround Templates tab
On right side of dialog under C# files shortcuts for many surround templates are listed
1 if
2 while
3 for
4 do...while
5 #region
6 #if...#endif
7 {}
8 try...catch
9 try...finally
0 cast
A tag
B lock
C String.Format
Expand Predefind Templates and C# nodes to see all the pre-defined templates still exist

It's not clear why the surround templates are not availabe when pressing Ctrl+Alt+J or using the manu Resharper>Code>Surround With

Finally,

After looking around for a while I returned to the Templates explorer, and drag and dropped try...finally from postion 9 to position 8, after doing this all the options are available again when pressing Ctrl+Alt+J.

3 comments

My last statement about dragging and dropping the try...finally is not correct.  I've looked into this more and can see the problem more clearly.

The 3 options that are avaiable to me when I press Ctrl+Alt+J are all marked Availalbe in C# 2.0+ files, while the missing options are marked Available in C#2.0+ files where statement is allowed.

Here is the code I selected when attemptin to use the surround template

        //if key already exists
        if(_keys.Count > insertAt && _keys[insertAt].Key.Equals(key))
        {
          _keys[insertAt] = new KeyValuePair<TKey, TValue>(key, value);
          Updated();
        }
        else
        {
          _keys.Insert(insertAt, new KeyValuePair<TKey, TValue>(key, value));
          Updated();
        }

I don't know if this worked in 4.1 or not, but it seems like it shold work.  I have no problem manually writing in the try/finally and compiling the code, here is the complete method with the try/finally typed in, this compiles successfullly.

    public void Put(TKey key, TValue value)
    {
      int insertAt = GetInserIndex(key);

      _lock.EnterWriteLock();

      try
      {
        //if key already exists
        if(_keys.Count > insertAt && _keys[insertAt].Key.Equals(key))
        {
          _keys[insertAt] = new KeyValuePair<TKey, TValue>(key, value);
          Updated();
        }
        else
        {
          _keys.Insert(insertAt, new KeyValuePair<TKey, TValue>(key, value));
          Updated();
        }
      }
      finally
      {
        _lock.ExitWriteLock();
      }

      CheckForInvalidChildren();
    }

0

Hello,

We appreciate your feedback. The corresponding JIRA request has been created,
and you are welcome to monitor its status at http://www.jetbrains.net/jira/browse/RSRP-102166.

You may want to check our request tracking policy here: http://www.jetbrains.net/confluence/display/ReSharper/ReSharperIssueTracker

Best regards,
- Development Team.


0

FYI, although marked as fixed for 1227, I just tried it using 1227 and the issue still exists.  I also commented on the jira issue.

0

Please sign in to leave a comment.