Extract interface problem

I'd like to create an interface from an existing class. I put the cursor under the class name, right-click, choose Refactor / Extract interface, click on 'all public', then Next. Reshaper works for a while (the status bar states 'moving members', 'updating references', etc.), closes the 'Extract interface' dialog.
My problem is that nothing got created, no new file (if I ask the new interface to be in a new file), no new interface... I searched using R# itself, VS and outside VS in the file system.

I am using R# 5.1.2 (i.e. 5.1.1766.4), on VS 2010 SP1, in a Silverlight 4 project. The class that I am working on is the Context created by RIA Services.

Am I missing something ?

Regards,
Jean-Marie

3 comments

Hello Jean-Marie,

Could you please attach a small sample solution that would demonstrate this
behavior? Thank you!

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

I'd like to create an interface from an existing class. I put the
cursor under the class name, right-click, choose Refactor / Extract
interface, click on 'all public', then Next. Reshaper works for a
while (the status bar states 'moving members', 'updating references',
etc.), closes the 'Extract interface' dialog. My problem is that
nothing got created, no new file (if I ask the new interface to be in
a new file), no new interface... I searched using R# itself, VS and
outside VS in the file system.

I am using R# 5.1.2 (i.e. 5.1.1766.4), on VS 2010 SP1, in a
Silverlight 4 project. The class that I am working on is the Context
created by RIA Services.

Am I missing something ?

Regards,
Jean-Marie
---
Original message URL:
http://devnet.jetbrains.net/message/5299746#5299746



0

Hello Andrey,

I was afraid you'd ask this ;)

I extracted the SL project of the solution into its own solution, removed the RIA Services link and could compile and reproduce the issue.

I may have found some clues about the problem.

If you open the project, you'll find the 'RoomContext' class, defined in 2 files. One of them, RoomManagement.Web.g.cs is generated by RIA Services (in the complete solution, not in the zip file). I had not realized it before, but RIA Services sets the file to Read-Only.

I had selected the class in the other file (Models\Extensions.cs) when I tried to extract the interface (the command is actually unavailable from the RIA Services file). What happens is that R# extracts the interface and tries to insert the generated declaration in the read-only file, which fails.

What confused me is that there is no error or warning message (this could be an improvement in a future version).

I simply removed the read-only bit from RoomManagement.Web.g.cs and could successfully extract the interface.

I actually made some more tests while writing this post and I no longer understand what's going on because I can suddenly extract the interface even after setting back the read-only attribute. I deleted the solution and unzipped the attached file to try again. Again, it worked.

So I am not sure that you'll be able to reproduce the issue.

If it helps, here the Resharper "about" text:

JetBrains ReSharper 5.1 Full Edition
Build 5.1.1766.4 on 2011-01-12T16:31:10
Plugins: none.
Visual Studio 10.0.40219.1.


Regards,
Jean-Marie

Attachment(s):
RoomManagement.zip
0

Hello Jean-Marie,

Thank you for the sample! I've tried to reproduce this behavior and I get
an 'Edit Read-only file' message from Visual Studio (which allows to make
the file writeable) during Extract Interface refactoring, which, I suspect,
is the correct behavior in this case. Let me know if you'll encounter this
problem in the future.

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

Hello Andrey,

I was afraid you'd ask this

I extracted the SL project of the solution into its own solution,
removed the RIA Services link and could compile and reproduce the
issue.

I may have found some clues about the problem.

If you open the project, you'll find the 'RoomContext' class, defined
in 2 files. One of them, RoomManagement.Web.g.cs is generated by RIA
Services (in the complete solution, not in the zip file). I had not
realized it before, but RIA Services sets the file to Read-Only.

I had selected the class in the other file (Models\Extensions.cs) when
I tried to extract the interface (the command is actually unavailable
from the RIA Services file). What happens is that R# extracts the
interface and tries to insert the generated declaration in the
read-only file, which fails.

What confused me is that there is no error or warning message (this
could be an improvement in a future version).

I simply removed the read-only bit from RoomManagement.Web.g.cs and
could successfully extract the interface.

I actually made some more tests while writing this post and I no
longer understand what's going on because I can suddenly extract the
interface even after setting back the read-only attribute. I deleted
the solution and unzipped the attached file to try again. Again, it
worked.

So I am not sure that you'll be able to reproduce the issue.

If it helps, here the Resharper "about" text:

JetBrains ReSharper 5.1 Full Edition
Build 5.1.1766.4 on 2011-01-12T16:31:10
Plugins: none.
Visual Studio 10.0.40219.1.
Regards,
Jean-Marie
---
Original message URL:
http://devnet.jetbrains.net/message/5299811#5299811



0

Please sign in to leave a comment.