An exotic DevEx’ ReportDesigner breaking change in 12.2

If you ever customized (excellent) DevExpress ReportDesigner you might have used this line of code to obtain a reference to IDataSourceCollectionProvider within ReportDesigner class which allows to access field list:

IDataSourceCollectionProvider dataSourceCollectionProvider = 
    as IDataSourceCollectionProvider;

This code worked well in 12.1 and perhaps in earlier 12.2 versions but it certainly won’t work in 12.2.5. The bad part is that it fails in runtime, while it still compiles perfectly. At least it fails consistently – always. The reason is that access to various services (IDataSourceCollectionProvider is one of them) is now through ReportDesigner.GetService(Type serviceType) method. Replacing the part above with the one below does the trick:

IDataSourceCollectionProvider dataSourceCollectionProvider = 

The new is more readable and it could be even better if it used generics. I’d certainly consider this declaration instead:

T GetService<T>()
  where T: class

which would yield even more readable assignment:

IDataSourceCollectionProvider dataSourceCollectionProvider = 

There you have the fix.