Bug 480 - Need to support renaming/removing/deleting Outlets and ACtions
Summary: Need to support renaming/removing/deleting Outlets and ACtions
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS add-in ()
Version: 2.8 Alpha 2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2011-08-26 15:40 UTC by Jonathan Pryor
Modified: 2014-02-10 15:03 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jonathan Pryor 2011-08-26 15:40:45 UTC
Following: http://docs.xamarin.com/ios/getting_started/Hello_iPhone

In the "Creating the Interface" section, I created a btnClickMe Outlet. Then I looked at it and said "ClickMe would be a better FxDG name!", and tried to find a way to rename it.

How should I be renaming it? How should I be deleting it?

It seems that renaming the property within the HelloWorld_iPhoneViewController.designer.cs file actually works, but this isn't obvious (or is it?).

I also tried deleting the added declarations from HelloWorld_iPHoneViewController.h within Xcode, but after saving the Xcode project MonoDevelop didn't appear to re-read the file, so this appeared to have no effect.

Similarly, within Xcode if I go to the Connections Inspector and remove the outlet from the 'Referencing Outlets' section, nothing seems to happen within MonoDevelop.

If after creating a connection within Xcode and I do see an outlet within Connections Inspector > Referencing Outlets, and I then close the Xcode project and reopen from MonoDevelop, the Connections Inspector > Referencing Outlets section for e.g. the Click Me button shows no outlets.
Comment 1 Mikayla Hutchinson [MSFT] 2011-08-26 21:32:00 UTC
1) Manually renaming the outlet in the designer file works but won't update any references to it in xibs. This is expected. However, it would be nice if using the rename refactoring command on an outlet property or a type in MD affected the xibs.

2) That's a bug, MD is supposed to be picking up additions and removals from the Xcode headers. Ideally we would also have some fuzzy logic to detect renames then offer to update all references in MD, like a rename refactoring does.

3) Removing a connection doesn't affect the outlet/action. Other things might be connected to it, or you might want to make another connection to it.

4) Sounds like the bug from #2 again.
Comment 2 Miguel de Icaza [MSFT] 2011-08-29 16:34:19 UTC
Should the refactoring take place in XCode4 or should it take place in MonoDevelop?

For #1 do you suggest that the XCode4 importer should probably check for differences in names as recorded in the .h file vs the outlet as declared on the XIB file and warn the user on import?
Comment 3 Mikayla Hutchinson [MSFT] 2011-08-29 19:37:33 UTC
I don't understand what you mean. Users can perform class or property or method rename refactorings on either side, and we have to cope with them. And xibs don't define outlets or classes, they simply refer to them.

I would hope that if the if the user performs rename refactorings in Xcode, it would fully update all the xib files as well as the code files, but I haven't verified this.

Unfortunately, there are many possibilities for renaming things and we don't handle many of them well. Here's a few:

a) class rename refactoring in Xcode, h filename updated to match class
In Xcode: all source files and xib files are updated. h file is renamed.
Sync back: MD gets the updated xib files, but ignores the "new" h file, and keeps the old C# class. Outlets in other classes' designer files that refer to the type fail to resolve. Sync fails.

b) class rename refactoring in Xcode, h filename not updated to match class
In Xcode: all source files and xib files are updated. h file is not renamed.
Sync back: MD detects class name doesn't match h filename, errors out. Sync fails.

c) outlet/action rename refactoring in Xcode:
In Xcode: all source files and xibs files updated:
Sync back: all changed outlets/actions are synced back to designer class parts. Xib files synced back.

d) Class rename refactoring in MD
All references in MD updated. Doesn't affect xcode because all that matters to Xcode is the name in the Register attribute.

e) Property/method rename refactoring in MD (explicit name)
All references in MD updated. Doesn't affect Xcode because all that matters to Xcode is the name in the Outlet/Action attribute.

f) Property/method rename refactoring in MD (implicit name)
All references in MD updated, and  outlet/action name sync to xcode. Xibs' references to the outlets/actions are not updated, user must fix them manually.

g) User manually changes Register name
User renames class by changing value in Register attribute. The new class name syncs to Xcode but xibs' references to the type are not updated, user must fix them manually.

h) User manually changes Outlet/Action name
User renames outlet/action by changing value in Outlet/Action attribute in C#. The new class name syncs to Xcode but xibs' references to the outlet/action are not updated, user must fix them manually.

IMO the most robust solution is to hook into rename refactorings in MD so that we can update the explicit Register/Action/Outlet names when the managed class is renamed, and apply the rename to all references in the xibs.
Comment 4 Jeffrey Stedfast 2014-02-10 15:03:53 UTC
Fixed by the iOS Designer