Bug 40855 - Subclassing UITextField crashes Property navigator
Summary: Subclassing UITextField crashes Property navigator
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS Designer ()
Version: 4.1.0 (C7)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 42662 ()
Depends on:
Blocks:
 
Reported: 2016-05-04 12:09 UTC by Kenneth
Modified: 2016-09-02 16:40 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 NOT_REPRODUCIBLE

Description Kenneth 2016-05-04 12:09:00 UTC
When subclassing UITextField for use in the iOS designer in Visual Studio, the "Widget" part of the Properties window crashes (seize to show class specific properties).

Example class:

    [Register("CustomTextField"), DesignTimeVisible(true)]
    public class CustomTextField : UITextField
    {
        public CustomTextField(IntPtr handle) : base(handle)
        {
        }
    }

Log error:

Xamarin.VisualStudio.UnhandledExceptionsManager Error: 0 : [2016-05-04 13:18:02.5360] Unhandled exception.
System.Exception: Did not know how to select the correct default value '2' for property 'textInputTraits.autocapitalizationType'
   at MonoTouch.Design.Client.Windows.ComboEnumPropertyEntry..ctor(PropertyEditorContext ctx, PropertyEditorBase editor, DesignerPropertyDescriptor attr)
   at MonoTouch.Design.Client.Windows.IPhoneDesignerServiceWindows.CreateNativePropertyEntry(PropertyEditorContext ctx, PropertyEditorBase editor, String name)
   at Xamarin.Designer.PropertyEditing.PropertyEditor.CreateNativePropertyEntry(PropertyEditorContext ctx, String name)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.CreateEditor(PropertyTableRow row, PropertyEditor editor)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.AddRow(PropertyEditorBase pe, PropertyTableGroup grp, Int32 groupID, PropertyTableRow parent)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.AddPanel(PropertyPanel p)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.Fill(PropertyEditorContext context, IEnumerable`1 panels)
   at Xamarin.Designer.DesignerPropertyPanel.SwitchToSection(PropertySection section, Boolean animated)
   at Xamarin.Designer.DesignerPropertyPanel.LoadItem(DesignerItem item, Boolean animated)
   at Xamarin.Designer.DesignerPropertyPanel.LoadItem(DesignerItem item)
   at Xamarin.Designer.PropertyEditing.IPhoneDesignerPropertyPanel.HandleDesignerSelectionChanged(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Xamarin.Designer.DesignerSurface.set_MouseDown(Boolean value)
   at Xamarin.Designer.DesignerSurface.OnButtonReleased(ButtonEventArgs args)
   at MonoTouch.Design.Client.IPhoneDesignerSurface.OnButtonReleased(ButtonEventArgs args)
   at Xamarin.Designer.DesignerSurface.ButtonReleased(ButtonEventArgs args)
   at Xamarin.Designer.Windows.EventUtils.ForwardButtonEvent(Action`1 action, Object sender, MouseButtonEventArgs e)
   at Xamarin.Designer.Windows.WpfSurfaceRenderer.<>c__DisplayClass64_0.<WireNativeEvents>b__4(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

A quickfix is to override the Autocapitaliztion type, like this:

    public override UITextAutocapitalizationType AutocapitalizationType { get; set; }

By overriding the property, the subclass works as intended and all properties are shown in the "Widget" tab.
Comment 1 Kenneth 2016-05-04 12:17:18 UTC
All properies are shown, but the default value for AutocapitalizationType is not set. (none vs Sentences)
Comment 2 Ben Beckley 2016-05-04 18:29:40 UTC
Hello Kenneth,

I have tried to reproduce this error by overriding UITextField as you described, and altering some of the widget properties. Unfortunately, I have not been able to trigger the crash. Could you please provide us with a little more information?

1) I see you marked this as C7, but what specific version of XVS are you using when you encounter this crash? Also, what version did you first see the failure occur? You can find this in "Help > About Microsoft Visual Studio".

2) If at all possible, please attach a small project which reproduces the error you are describing.

3) Additionally, if you could provide specific steps on how to reproduce, it would help immensely.


Thank you!
Comment 3 Alan McGovern 2016-05-25 13:18:51 UTC
We can't reproduce this problem and no further information has been provided. It does look like an issue we've fixed in the past. If the issue can be reproduced using the latest build in the Beta channel then please reopen the bug and we'll investigate some more!

Thanks!
Comment 4 Will 2016-06-02 10:14:28 UTC
I have updated to the latest beta to fix another issue and I have encountered the same issue with one of my sub classed UITextBoxes in the storyboard.

The designer doesn't seem to want to update the "Widget" tab on the properties window when I click on the textbox, it keeps the properties visible of the last object selected. It works on my subclassed UIButtons. It crashed when I attempted to update layout constraints using the "update frames" button.

I have not attempted to reproduce the problem in a new project, I'm not sure if this is because the project was built with the stable release and upgraded to the beta or not. 

The error is the same as above: 

System.Exception: Did not know how to select value '2' for property 'textInputTraits.autocapitalizationType'
   at MonoTouch.Design.Client.Windows.ComboEnumPropertyEntry.SelectValue(String value)
   at MonoTouch.Design.Client.Windows.ComboEnumPropertyEntry..ctor(PropertyEditorContext ctx, PropertyEditorBase editor, DesignerPropertyDescriptor attr)
   at MonoTouch.Design.Client.Windows.IPhoneDesignerServiceWindows.CreateNativePropertyEntry(PropertyEditorContext ctx, PropertyEditorBase editor, String name)
   at Xamarin.Designer.PropertyEditing.PropertyEditor.CreateNativePropertyEntry(PropertyEditorContext ctx, String name)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.CreateEditor(PropertyTableRow row, PropertyEditor editor)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.AddRow(PropertyEditorBase pe, PropertyTableGroup grp, Int32 groupID, PropertyTableRow parent)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.AddPanel(PropertyPanel p)
   at MonoTouch.Design.Client.Windows.NativePropertyTable.Fill(PropertyEditorContext context, IEnumerable`1 panels)
   at Xamarin.Designer.DesignerPropertyPanel.SwitchToSection(PropertySection section, Boolean animated)
   at Xamarin.Designer.DesignerPropertyPanel.Refresh()
   at Xamarin.Designer.PropertyEditing.IPhoneDesignerPropertyPanel.HandleContentChanged(Object s, EventArgs args)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Xamarin.Designer.DesignerSession.OnContentChanged()
   at MonoTouch.Design.Client.IPhoneDesignerSession.<ReloadItemsAsync>d__160.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MonoTouch.Design.Tasks.<Cancellable>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MonoTouch.Design.Client.IPhoneDesignerSession.<ReloadItems>d__159.MoveNext()

[2016-06-02 10:45:36.3] INFO: Reloading: Serialization took 0ms
[2016-06-02 10:45:36.8] INFO: Reloading: Deserialization took 4ms
[2016-06-02 10:45:36.8] INFO: Reloading: Server rendering completed in 491ms with 508186 bytes
[2016-06-02 10:45:36.8] INFO: Reloading: EndDeferSelectionChanged took 0ms
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size
[2016-06-02 10:45:36.8] ERROR: UIView of type 'UITextField' with style '' did not have a known min/max size

The XML for the textfield on the storyboard is:

<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="331" translatesAutoresizingMaskIntoConstraints="NO" clearButtonMode="always" placeholder="Username" customClass="WhiteTextField">
  <rect key="frame" x="20" y="78" width="280" height="29"/>
  <fontDescription key="fontDescription" type="system" pointSize="14"/>
  <textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" returnKeyType="next"/>
</textField>

I hope this helps
Comment 5 Alan McGovern 2016-06-02 19:18:54 UTC
Great, thanks for that. I'll revisit this tomorrow and see if this helps shed some light on the issue.
Comment 6 Will 2016-06-02 20:10:01 UTC
Hi Alan, thanks, let me know if I can provide anything else helpful, I'll do my best :-)
Comment 7 Alan McGovern 2016-06-03 13:06:30 UTC
I'll have to leave this to QA to double check. I can't reproduce the problem in either master builds or c7 builds.

Can you attach the version information as described in the second comment? That will help us double check we're testing the right version.
Comment 8 Will 2016-06-03 13:33:52 UTC
Hi Alan, 

That's unfortunate, I'll see if I can reproduce on a cut down solution I can upload for debugging.

Version info:

Xamarin:         4.1.0.517 (2a984fb)
Xamarin.Android: 6.1.0.69  (5263594)
Xamarin.iOS:     9.8.0.319 (7b89851)

Many thanks!
Comment 9 Alan McGovern 2016-07-19 15:39:45 UTC
*** Bug 42662 has been marked as a duplicate of this bug. ***
Comment 10 Alan McGovern 2016-09-02 16:40:29 UTC
This seems to work with the latest releases, so without a way to reproduce the issue I will just close this and assume it has been fixed already. If there is a way to reproduce the issue with the latest releases, please reopen the bug. Thanks!