Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add regression test for bxc #1147.

  • Loading branch information...
commit e66adeddcd679f54a6bf32179f0ecf168cfef5dd 1 parent 2721a0c
@kumpera kumpera authored
Showing with 98 additions and 2 deletions.
  1. +4 −2 mono/tests/Makefile.am
  2. +94 −0 mono/tests/bug-1147.cs
View
6 mono/tests/Makefile.am
@@ -377,7 +377,8 @@ BASE_TEST_CS_SRC= \
sgen-long-vtype.cs \
delegate-invoke.cs \
bug-696593.cs \
- bug-705140.cs
+ bug-705140.cs \
+ bug-1147.cs
TEST_CS_SRC_DIST= \
$(BASE_TEST_CS_SRC) \
@@ -902,7 +903,8 @@ GSHARED_TESTS = \
generic-stack-traces.2.exe generic-stack-traces2.2.exe \
bug-472600.2.exe bug-473482.2.exe bug-473999.2.exe \
bug-479763.2.exe generic-xdomain.2.exe \
- generic-type-load-exception.2.exe bug-616463.exe
+ generic-type-load-exception.2.exe bug-616463.exe \
+ bug-1147.exe
test-generic-sharing-normal: $(GSHARED_TESTS)
@for fn in $+ ; do \
View
94 mono/tests/bug-1147.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+
+namespace Program {
+ public class AxControlEventArgs<T> : EventArgs where T : WindowlessControl
+{
+ public T Control { get; private set; }
+
+ public AxControlEventArgs(T control) {
+ Control = control;
+ }
+ }
+ public class AxControlEventArgs : AxControlEventArgs<WindowlessControl> {
+ public AxControlEventArgs(WindowlessControl c) : base(c) { }
+ }
+
+ public class AlignPadLayoutPanel : AlignPadLayoutPanel<WindowlessControl> {
+}
+
+ public class AlignPadLayoutPanel<T> : WindowlessControl where T :
+WindowlessControl {
+ protected override void OnControlAdded(AxControlEventArgs e) {
+ e.Control.Resize += Content_Resize; //OK if removed
+ base.OnControlAdded(e);
+ }
+
+ private void Content_Resize(object sender, EventArgs e) { }
+ }
+
+ public class GroupBox : AlignPadLayoutPanel { } //NOT OK
+ //public class GroupBox : AlignPadLayoutPanel<WindowlessControl> {} //OK
+
+ public class Program {
+ public static readonly AttachedProperty<string> EDITING_TEXT = new
+AttachedProperty<string>(null);
+
+ static void Main(string[] args) {
+ Console.WriteLine("Program 6");
+
+ var gr = new GroupBox();
+
+ //gr.InsertControl(0, new WindowlessControl()); //OK
+
+ /* need this block(A) this to crash */
+ var item = new WindowlessControl();
+
+ new AlignPadLayoutPanel<WindowlessControl>().InsertControl(0,
+item); //OK if removed
+
+ item.SetAttachedProperty(EDITING_TEXT, "label.Text");
+ /*end block(A)*/
+
+ gr.InsertControl(0, new WindowlessControl()); //NOT OK
+
+ var wc = new WindowlessControl();
+ wc.SetAttachedProperty(EDITING_TEXT, "label.Text");
+ var str = wc.GetAttachedProperty(EDITING_TEXT);
+
+ Console.WriteLine("DONE");
+ }
+ }
+
+ public class WindowlessControl {
+ internal readonly Dictionary<object, object> _AttachedProperties = new
+Dictionary<object, object>();
+
+ public void SetAttachedProperty<T>(AttachedProperty<T> prop, T val) {
+ Console.WriteLine("SetAttachedProperty 1");
+ _AttachedProperties[prop] = val;
+ Console.WriteLine("SetAttachedProperty 2");
+ }
+
+ public T GetAttachedProperty<T>(AttachedProperty<T> prop) {
+ Console.WriteLine("GET AttachedProperty");
+ return (T)(_AttachedProperties[prop] ?? prop.DefaultValue);
+ }
+
+ public event EventHandler Resize;
+
+ public void InsertControl(int index, WindowlessControl control) {
+ OnControlAdded(new AxControlEventArgs(control));
+ }
+
+ protected virtual void OnControlAdded(AxControlEventArgs e) { }
+ }
+
+ public struct AttachedProperty<T> {
+ public T DefaultValue { get; private set; }
+
+ public AttachedProperty(T defaultValue) : this() {
+ DefaultValue = defaultValue;
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.