Bug 61174 - iOS Designer regenerates inherited outlets
Summary: iOS Designer regenerates inherited outlets
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS Designer ()
Version: 4.8.0 (15.5)
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Alexander Sorokin
URL:
Depends on:
Blocks:
 
Reported: 2018-01-24 09:02 UTC by Leon
Modified: 2018-04-12 14:18 UTC (History)
8 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 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 Leon 2018-01-24 09:02:19 UTC
The iOS designer in Visual Studio regenerates the outlet properties in the designer files, even if they are already present due to class inheritance. This happens with both storyboards and xib files.

Take for example the following UITableViewCell base class:

    public abstract partial class BaseTableViewCell : UITableViewCell
    {
       //..Other methods

       public void DoSomething()
       {
          cancelButton.TintColor = UIColor.Blue;
       }
    }

And in the designer file:

    [Register ("BaseTableViewCell")]
    partial class BaseTableViewCell 
    {
        [Outlet]
        UIKit.UIButton cancelButton { get; set; }

        void ReleaseDesignerOutlets ()
        {
            if (cancelButton != null) {
                cancelButton.Dispose ();
                cancelButton = null;
            }
        }
    }

In the Visual Studio For Mac + XCode Interface Designer flow, classes derived from BaseTableViewCell can access the cancelButton outlet and assign XIB/Storyboard objects to it.
A setup like this works fine in Objective-C based projects in XCode and the XCode Interface Builder flow in Visual Studio for Mac. 

The iOS Designer in Visual Studio 2017 on Windows doesn't seem to handle this properly though. When trying to assign the properties in a XIB/Storyboard file (by entering the property name in the name field of the object) the designer always regenerates the property in the derived class, even when the property is already present in the base class, thereby redefining said property. 
This causes several parts of the code in the base class to fail (since the base class property remains unassigned at runtime).

A temporary workaround is to manually remove the generated properties in the derived class's designer file, but considering these are regenerated every time a small change is made to the XIB/Storyboard file (or sometimes even when the file is opened) this gets a bit tedious.
Comment 1 John Miller [MSFT] 2018-01-30 16:02:50 UTC
I am able to confirm the same issue in VSMac 7.5 (build 250)

## Steps To Reproduce

1. Create a single view iOS app project
2. Open the storyboard in the designer
3. Select the default controller in the scene
4. Change it's Class property to CustomClass and press Enter/Return. 
5. Change the Class property to CustomClass2 and press Enter/Return.
6. Drag a button onto the controller and change it's Name property to TestButton
7. Select the controller again and change it's Class property back to CustomClass
8. Edit the CustomClass.cs file and inherit from CustomClass2
9. Go back in the designer and select the button. Delete the Name property and then re-add the name TestButton. 

## Actual Results

A TestButton outlet is generated in CustomClass

## Expected Results

A TestButton outlet should not be generated in CustomClass because it already has an inherited property for TestButton in the base class, CustomClass2. 

## Version Info

=== Visual Studio Enterprise 2017 for Mac (Preview) ===

Version 7.5 Preview (7.5 build 250)
Installation UUID: b968d862-551c-4a33-ab4e-9666400e357c
Runtime:
	Mono 5.8.0.108 (2017-10/9aa78573ee2) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 508000108

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.0.0-preview2-25407-01
SDK: /usr/local/share/dotnet/sdk/2.0.0-preview2-006497/Sdks
SDK Version: 2.0.0-preview2-006497
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.8.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.2.0.6 (Visual Studio Enterprise)
Android SDK: /Users/johnmiller/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		7.0 (API level 24)
		7.1 (API level 25)
		8.0 (API level 26)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 26.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 9.2 (13772)
Build 9C40b

=== Xamarin.Mac ===

Version: 4.2.0.8 (Visual Studio Enterprise)

=== Xamarin.iOS ===

Version: 11.8.0.8 (Visual Studio Enterprise)
Hash: eaff169d
Branch: d15-6
Build date: 2018-01-09 18:39:05-0500

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 705000250
Git revision: 500eed91298a4dc298f244b6eb2078c67fc8f14e
Build date: 2018-01-26 06:12:03-05
Xamarin addins: 128cde428c7ad21426ac44d9685718a645937936
Build lane: monodevelop-lion-master

=== Operating System ===

Mac OS X 10.13.2
Darwin 17.3.0 Darwin Kernel Version 17.3.0
    Thu Nov  9 18:09:22 PST 2017
    root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

AddinMaker 1.4.1
MicroFramework 1.0.2
Prism Template Pack 1.6.1
Internet of Things (IoT) development (Preview) 7.1
Comment 2 Sergei 2018-02-28 12:56:33 UTC
It's very annoying issue. What is fixing progress?
Comment 3 Alexander Sorokin 2018-03-13 10:50:53 UTC
=== Visual Studio Community 2017 for Mac (Preview) ===

Version 7.5 Preview (7.5 build 108)
Installation UUID: 13146915-8506-40ac-89f8-0dcdaf7dcbd5
Runtime:
	Mono 5.10.0.88 (2017-12/71fdb336b82 Mon Feb  5 16:53:42 EST 2018) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 510000088

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.0.0
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Version: 2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.10.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.6
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 9.2 (13772)
Build 9C40b

=== Xamarin.Mac ===

Version: 4.5.0.1 (Visual Studio Community)

=== Xamarin.iOS ===

Version: 11.11.0.1 (Visual Studio Community)
Hash: 6d88e01b
Branch: master
Build date: 2018-02-19 06:37:43-0500

=== Xamarin.Android ===

Version: 8.2.99.14 (Visual Studio Community)
Android SDK: /Users/user/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)
		7.1    (API level 25)
		8.0    (API level 26)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 27.0.0

Java SDK: /usr
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.4.0-beta1+69
Hash: 4012b4e
Branch: master
Build date: Thu, 07 Dec 2017 16:20:26 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 705000108
Git revision: f0198d46b8703f23c002f1f0f2fc0f936bf1f3af
Build date: 2018-01-10 09:32:11-05
Xamarin addins: b07a46355f97207a2c5721b6a5b70798d140c2e4
Build lane: monodevelop-lion-master

=== Operating System ===

Mac OS X 10.13.3
Darwin 17.4.0 Darwin Kernel Version 17.4.0
    Sun Dec 17 09:19:54 PST 2017
    root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
Comment 4 Alexander Sorokin 2018-03-13 10:52:24 UTC
Oops, didn't mean to send it :)
Comment 5 xamarin-release-manager 2018-04-05 22:36:18 UTC
Fixed in version 4.13.0.270 (master)

Author: Alexander Sorokin
Commit: 83f4f40b3bba6049c4aca6a60f21b763613eb486 (xamarin/designer)
Comment 6 xamarin-release-manager 2018-04-05 22:37:19 UTC
Fixed in version 4.13.0.270 (master)

Author: Alexander Sorokin
Commit: 83f4f40b3bba6049c4aca6a60f21b763613eb486 (xamarin/designer)
Comment 7 xamarin-release-manager 2018-04-10 10:16:34 UTC
Fixed in version 4.12.0.251 (d15-7)

Author: Alexander Sorokin
Commit: ee8593b392b36bb08cd4aa974dd66fa805f082a4 (xamarin/designer)
Comment 8 xamarin-release-manager 2018-04-10 10:16:58 UTC
Fixed in version 4.12.0.251 (d15-7)

Author: Alexander Sorokin
Commit: ee8593b392b36bb08cd4aa974dd66fa805f082a4 (xamarin/designer)