Bug 551688

Summary: Add a shortcut to switch between AS?X and code behind
Product: [Mono] MonoDevelop Reporter: Curtis Wensley <curtis.wensley>
Component: ASP.NetAssignee: Michael Hutchinson <mhutchinson>
Status: RESOLVED FIXED QA Contact: MD Bugs <monodevelop-bugs>
Severity: Enhancement    
Priority: P5 - None    
Version: SVN   
Target Milestone: 2.4   
Hardware: All   
OS: All   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: patch to add a shortcut that switches between *.as?x and code behind
New patch implemented in DesignerSupport module

Description Curtis Wensley 2009-11-01 00:34:01 UTC
Created attachment 325003 [details]
patch to add a shortcut that switches between *.as?x and code behind

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9

It is very difficult to switch between the *.as?x and code behind files with the mouse only, since you have to expand the as?x file and then double click on the code-behind file.  It would be nice to have a shortcut (similar to the one for C++ projects) that switches between the two.

I have created a patch that implements this feature.  Only thing I would do in addition (but don't know how) is to make it when you press the shortcut with the file highlighted in the solution explorer, it would show the code behind as well (like visual studio).

Reproducible: Always
Comment 1 Michael Hutchinson 2009-11-03 22:43:41 UTC
I like the idea behind this but perhaps it makes more sense to implement it at the IDE level and switch between files in any grouped set? That way there can be a common command and keybinding for ASP.NET, Silverlight, C/C++ etc.

This could be done very easily using the DependsOn and DependentOn properties of the ProjectFile.
Comment 2 Curtis Wensley 2009-11-04 02:45:36 UTC
Is there some identifier that would be able to tell between a designer-generated dependency a code-behind file (e.g. MyForm.aspx.designer.cs vs.  MyForm.aspx.cs)?  If not it might still have to be project-type specific or have a property/method of the project type to tell the generic code what to do..

Also, I've looked at the C/C++ projects and it doesn't look like it uses dependencies between the header and .cpp...  unless I'm mistaken?
Comment 3 Michael Hutchinson 2009-11-05 20:43:43 UTC
You could probably take a reliable guess using something like:

var s = name.Split('.');
bool isDesigner = s.Length < 2 && (s [s.Length - 2] == "designer" || s [s.Length - 2] == "generated");

Checking for the Generator MSBuild element should work in some cases too, but MD doesn't use this right now, so it would only work for projects from VS.

Regarding C/C++, I don't think it does have deps like that, not, but it would make sense to add them. I'll file an enhancement - it's near-trivial to add.

There's already some logic for handling designer files in MonoDevelop.DesignerSupport.CodeBehind, so maybe it would make sense to have the IsDesignerFile logic in there too, and have the switching command in that addin.
Comment 4 Curtis Wensley 2009-11-24 03:08:26 UTC
Created attachment 329104 [details]
New patch implemented in DesignerSupport module
Comment 5 Curtis Wensley 2009-11-24 03:13:55 UTC
Ok, took a bit to get md compiling again after issues with Mono.Cairo.. 

Moved the command over to MonoDevelop.DesignerSupport, and use the DependsOn and DependdentOn properties instead of going by filename...

This should work for all types of projects that have designer files, though I only tested with asp.net project as I couldn't figure out how to get IPhone module in there.. (;

Hopefully this gets in for MD 2.2!
Comment 6 Michael Hutchinson 2009-11-26 00:45:17 UTC
Looks pretty good. I'll do a full review and commit next week.
Comment 7 Michael Hutchinson 2010-05-12 03:24:49 UTC
Cleaned up and committed. Sorry for the delay!