1

I am attempting to search for

using (var context = new $DataContext$())

where DataContext is any class that extends System.Data.Linq.DataContext using Resharpers 'Search with Pattern'.

The pattern I'm using is:

using($type$ $var$ = new $type$($args$))
{
  $stmt$
}

enter image description here

This appears to return all using statements, eg using StreamWriter, using FileStream, things that clearly do not derive from System.Data.Linq.DataContext

How can you return only the types indicated?

I am using VS 2010 SP1 Beta and ReSharper 5.1 C# Edition build 5.1.1727.12

Bas Leijdekkers
  • 23,709
  • 4
  • 70
  • 68
wal
  • 17,409
  • 8
  • 74
  • 109

1 Answers1

2

I suggest you file it as a bug, because the following returns the expected results:

$type$ $var$ = new $type$($args$);

(Settings like you showed them).
It returns only this line:

var context2 = new DataContext("");

But not this:

var stream2 = new FileStream("", FileMode.CreateNew);
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
  • what R# and VS are using? please include version numbers and/or service packs – wal Feb 24 '11 at 12:45
  • I am currently using VS 2010 without SP and R# Build 5.1.1753.4 – Daniel Hilgarth Feb 24 '11 at 12:47
  • I have posted to r# discussion forum. http://devnet.jetbrains.net/message/5290066#5290066 – wal Feb 24 '11 at 13:03
  • Did you try the statement using 'using' and have it return unexpected results like it did for me? – wal Feb 24 '11 at 13:06
  • Yes. And it behaves as you described. That's why I tried it without the `using`. That's why I suggested it is a bug: In some circumstances it works, in others, it doesn't. – Daniel Hilgarth Feb 24 '11 at 13:08
  • 1
    This is a bug as confirmed by Jetbrains. See http://devnet.jetbrains.net/message/5290193#5290193 – wal Feb 25 '11 at 08:56