Thursday 21 June 2012

Third Party Creep

Just Out Of Interest...

The somewhat laborious DevExpress build processes described in the previous article did eventually bear fruit, letting me pare down the problem to its bare essentials. Now I need to send this sample code off to DevExpress, together with as many caveats as I can muster - otherwise, they're sure just to write back with some entirely unworkable suggestions, like refactoring our entire business object hierarchy (test impact = humongous).
// Run this project using DevExpress version 9.2.6, and inspect the Field List tab.
// "Contacts" will contain two properties, "Name" and "Telephone".
// Run it again using DevExpress version 12.1, and inspect the Field List tab again.
// "Contacts" will contain only the "Name" property - "Telephone" has disappeared!

using System;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;

namespace XtraReportsTest
{
 public partial class Form1 : Form
 {
  public Form1()
  {
   InitializeComponent();
  }

  private void Form1_Load(object sender, EventArgs e)
  {
   new XtraReport {DataSource = new ContactTypedList()}.ShowDesignerDialog();
   Close();
  }
 }

 public class ContactTypedList : ArrayList, ITypedList
 {
  public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
  {
   return TypeDescriptor.GetProperties(typeof (Contact));
  }

  public string GetListName(PropertyDescriptor[] listAccessors)
  {
   return "Contacts";
  }
 }

 public class Contact
 {
  public string Name { get; set; }
  [Browsable(false)]
  public string Telephone { get; set; }
 }
}
Suitably squashed to highlight the relevant areas, here are the results of the test runs with DX version 9.2.6 (left) and 12.1 (right):



This calls for a course on defensive programming!

1 comment:

  1. Gabriel Vonlanten C. Lopes13 July 2012 at 19:10

    Probably because of your Browsable(False) attribute on Telephone, maybe the previous version did not respect it and now they are doing.

    ReplyDelete