The Upcoming Caliburn v1.1 Release and More Breaking Changes in v2.0

Coordinator
Jun 23, 2010 at 12:12 AM

For those of you who are using Caliburn v1.1, please grab the latest revision, build and try it out with your applications. Assuming there are no further major issues, we will be releasing v1.1 shortly.

If you aren’t using v1.1, then you are probably using the 2.0 Alpha in the Trunk. I’m planning to make some further breaking changes there. So, I just want to warn you in advance. Below is a list of what I am planning on doing. There are a couple of things I haven’t quite decided fully about. I would enjoy your feedback on those items.

 

CaliburnApplication

Currently the standard approach to building an application is to inherit your application class from CaliburnApplication. I’m going to do away with this. I think having to alter the application object itself is a negative. But, there’s a bigger reason I want to change this. I need a way to discover various configuration settings at design-time without instantiating an application class. This will open up the possibility for better design-time support, possibly including the ability to apply a developer’s custom conventions at design-time. What I am going to add is a base Bootstrapper class. Developers will inherit from this class, receiving access to all the methods they currently get from the CaliburnApplication class, then they will simply add the bootstrapper to their application’s resources. When the application starts, the resource will be created and will hook the same events the CaliburnApplication class does now.

 

ScreenConductor, et al.

In many cases I have the need for a ScreenConductor-like functionality across ViewModels which do not implement the IScreen interface or which only require a portion of that interface such as Activation. I’m planning to break the IScreen interface into a series of composable interfaces and rework the ScreenConductor classes around that. So, instead of ScreenConductor<T>, you will have Conductor<T>. If T implements the IActivate interface, it will be activated, if it implemented the IDeactivate interface, it will be deactivated, etc. I’m also planning some signature changes to the methods on those interfaces to simplify certain scenarios and to account for lifecycle events in a cleaner way. Below are the proposed changes in brief:

   public interface IActivate

   {

       void Activate();

       event EventHandler<ActivationEventArgs> Activated;

   }

 

   public interface IDeactivate

   {

       void Deactivate(bool close);

       event EventHandler<DeactivationEventArgs> Deactivated;

   }

 

   public interface IGuardClose

   {

       void CanClose(Action<bool> callback);

   }

 

   public interface IHaveDisplayName

   {

       string DisplayName { get; set; }

   }

 

   public interface IScreen : IHaveDisplayName, IActivate, IDeactivate, IGuardClose, INotifyPropertyChangedEx

   {

   }

 

   public class ActivationEventArgs : EventArgs

   {

       public bool WasInitialized;

   }

 

   public class DeactivationEventArgs : EventArgs

   {

       public bool WasClosed;

   }

I believe this will add much greater flexibility and simplify some of the inner workings as well.

 

CommonServiceLocator

I’d like your feedback on this item. I am considering removing the dependency on the CSL. In general, it has lost favor with many developers. Additionally, there’s really no benefit to Caliburn from keeping the dependency, since the Caliburn project maintains all the container adapters itself. When I first added it, there was some thought that it might be added to a future version of the .NET Framework. Recently, discussion seems to indicate that Microsoft has no plans to ever do that and additionally they have made no effort to update it for newer versions of .NET or to incorporate improvements/feedback from the community. In such a case it would be easier for Caliburn to simply define its own interface. This would also reduce the number of assemblies and the overall size of Caliburn. If I do this, the API probably won’t change at all. I’ll combine Caliburn’s existing IRegistry and IContainer interfaces with a basic Service Locator interface so that it essentially looks and works exactly like it does now. Thoughts?

 

System.Windows.Interactivity and Version Support

I’m planning to drop support for Silverlight 2.0 in v2. My question is: Can I drop support for Silverlight 3.0 as well? If we can support only .NET and SL4 (and later), then we can make some major improvements to Caliburn’s routed messaging and Actions implementation. You may have noticed that Microsoft’s System.Windows.Interactivity.Interaction.Triggers et al, look a lot like Caliburn’s Message.Triggers syntax. (I’ve often wondered if they copied Caliburn, since my implementation predates theirs by a year or two.) If we only have to support SL4 and beyond, I can remove my duplicate implementation and base Caliburn’s mechanism on the Microsoft supported Triggers mechanism. This would reduce a lot of duplicate code in Caliburn. It would also provide instant Blendability to Caliburn’s actions, since Blend already supports Interaction.Triggers with a nice design-time experience. Furthermore, it would allow any community developed Interaction.Trigger to be plugged into Caliburn to trigger Actions/Commands/RoutedMessages. So, there are a lot of huge benefits. But, it cannot be done with SL3, due to platform limitations, which were finally fixed in SL4. I’ve been fighting for these fixes since SL2, and they finally got it done. So, again, my question is: Would it be ok to only support .NET and SL4 going forward in order to make these improvements?

 

Jun 23, 2010 at 12:25 AM

I agree with everything you've said. CSL seemed like a good idea for the reasons you described, but after a while seemed to only get in the way. I found myself going more towards a static class with a Func instead just setup at startup, and easily mocked for tests.

I am always a fan of cutting out fat where you can. If it makes your life easier, go for it.

Jun 23, 2010 at 1:18 AM

+1 for dropping support for older versions of Silverlight. There is Caliburn 1.1 for people who need to support SL 2 or 3, I think it would be a mistake at this stage to hold back the types of improvements you're suggesting for platforms which are shrinking fast.

Jun 23, 2010 at 1:24 AM

If there's a lot of demand for Silverlight 3 support it's not too difficult to support binding to System.Interactivity behavior properties in Silverlight 3. I've used nRoute Toolkit's Bindinable Triggers,Actions,Behaviors where are inherited versions of the ones in System.Interactivity which provide a very easy to use syntax for creating behaviors that supporting binding to behavior property targets, extremely useful before Silverlight 4 added binding support for Dependency Object targets (in SL3 it was only FrameworkElement).  I don't know if this is true or not, but the nRoute toolkit, or something like it may still be necessary for behavior binding support in Windows Phone 7. 

Coordinator
Jun 23, 2010 at 2:32 AM

The real problem with System.Interactivity and SL3 is not binding to the ActionMessage itself. That will work. The problem is binding to the Parameters. That will not work because the DependencyObject and ElementName binding support was really only partially done in SL3. They finished the work in SL4. So, if I still had to support SL3, I would have to keep all the current hacks I have in place now, which is what I really want to remove.

Jun 23, 2010 at 6:05 AM
+1 to use SL 4.0. Most applications will upgrade to SL4.0 and others that don't can always use v1.1.
Jun 23, 2010 at 8:59 AM
Go ahead :-)
Jun 23, 2010 at 4:36 PM
Rob, These all sound like good changes. They are significant changes though. Can you gauge the impact to consumers? I can imagine one metric is to see how much the NavigationShell sample project will have to be updated to accommodate these changes. The reason I'm dwelling on this is because just yesterday I branched our own product to begin the process of evaluating level of effort to migrate to Caliburn v2. from v1.1. So you can imagine my surprise this morning. :) I wish these proposed changes were already in place. Rob Cecil
Coordinator
Jun 23, 2010 at 5:48 PM

Here are what I think you would have to change:

1. Switch your application back to inheriting from Application and move the code previously in your application class into a new class called Bootstrapper. Add the bootstrapper to your application's resources.

2. Change the base classes related to ScreenConductors. The compiler should tell you everything that is wrong here. Some properties are going to change. For example, the Screens property will be renamed to Items and ActiveScreen to ActiveItem (to reflect that we will  be able to conduct any object). This is probably the biggest issue for those using conventions and relying on element name convention binding. This will be the first thing I work on because it is the most destructive. If you are doing a lot of coding against the ILifecycleNotifier interface, you will need to adapt that to the new IActivate, etc interfaces as well.

3. Hopefully, removal of CSL will be transparent. If there are any changes, the compiler will help in finding them. I don't think this will be a big deal.

4. If you are using Message.Attach, you should see no changes to how you handle Actions. If you are using the long syntax via Message.Triggers, you will have to change all instances of this to use Interaction.Triggers.

So, the ScreenConductor changes are the biggest issue. But, if you are coming from v1.1 to 2.0, you would have to deal with that anyways.

Jun 23, 2010 at 5:53 PM
So, the question in my mind is *when* they we be ready? :)
Coordinator
Jun 23, 2010 at 6:29 PM

That's the question on my mind too ;)

Jun 24, 2010 at 4:30 AM

+1 for SL4 only. +1 for removal of CommonServiceLocator.  The CaliburnApplication and IScreen changes sound good as well. Is EventAggregator coming in 2.0?

Jun 24, 2010 at 8:25 AM
@roblcecil If you are evaluating the migration effort, you might find useful to read my post about that: http://marcoamendola.wordpress.com/2010/01/25/migration-to-caliburn-v2/ It's a little outdated, but as far I can remember, there was no other big breaking change on Caliburn from that time, at least involving application model property names. I did 1.1 to 2.0 migration on a couple projects, both with quite a lot framework customization. It was fairly straightforward to accomodate the change in the framework; the biggest issue, as Rob already pointed out, was changing all bindings to Application Model's property that changed their names, expecially if you don't have unit tests of bindings in place. Anyway, I was able to do this with text search on xaml files very quickly (it was boring, though :-) ). The whole migration took a couple days.
Jun 24, 2010 at 10:34 AM
Edited Jun 24, 2010 at 10:34 AM

@mlinnen It's already in the trunk and based on Reactive Extensions. See here. :)

Coordinator
Jun 24, 2010 at 12:59 PM

I should also mention that there are improvements/extensions planned for the event aggregator as well.

Jun 24, 2010 at 6:31 PM

SL4 only please!  Other changes make sense too.

Jun 25, 2010 at 2:37 PM

+1 for dropping CSL. Less is more in this case.

+1 for dropping SL3 in caliburn 2 too. As others said. if you're still on SL3, use v1.1

Remco

Jun 25, 2010 at 11:48 PM
Thanks Marco. It's not comprehensive, but it does help solidify that I'm not missing too much in this process... :)

I'm still looking around for:

1. How do add Interaction Defaults for custom controls (I used to do it through the IRoutedMessageController)
2. How do control binding conventions versus message conventions. Previously, I had only used IBinder.EnableBindingConventions(), but not IBinder.EnableMessageConventions. Are those two concepts rolled into one thing now in V2?
3. What is the whole concept of Subject about? I'm not sure what a Subject implies.

Thanks

On Thu, Jun 24, 2010 at 2:26 AM, marcoamendola <notifications@codeplex.com> wrote:

From: marcoamendola

@roblcecil If you are evaluating the migration effort, you might find useful to read my post about that: http://marcoamendola.wordpress.com/2010/01/25/migration-to-caliburn-v2/ It's a little outdated, but as far I can remember, there was no other big breaking change on Caliburn from that time, at least involving application model property names. I did 1.1 to 2.0 migration on a couple projects, both with quite a lot framework customization. It was fairly straightforward to accomodate the change in the framework; the biggest issue, as Rob already pointed out, was changing all bindings to Application Model's property that changed their names, expecially if you don't have unit tests of bindings in place. Anyway, I was able to do this with text search on xaml files very quickly (it was boring, though :-) ). The whole migration took a couple days.

Read the full discussion online.

To add a post to this discussion, reply to this email (caliburn@discussions.codeplex.com)

To start a new discussion for this project, email caliburn@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Jun 26, 2010 at 9:29 AM
Edited Jun 26, 2010 at 9:30 AM

Sorry, the post was actually about *my* migration result, not a general guide; I should have pointed this out.
About your questions:

1) You can use IConventionManager.AddElementConvention method to inject new interaction defaults into the default manager, or you can provide a custom IConventionManager inheriting from DefaultConventionManager and override DefaultConventionManager.GetDefaultElementConventions.

2) Conventions applied to a view are grouped into IViewConventionCategory-ies, depending on the the View Model "target" they apply to.
Let me elaborate a bit: to attempt conventional bindings, the framework enumerates all components available in the VM that could possibly be bound to a view element; this "target" (exposed by IViewModelDescription) includes properties, actions and filters.
A IViewConventionCategory is composed by a set of "rules" (IViewConvention-s) focused on uniform targets (for example, all actions available in a VM) and figures out a set of applications.

You can add new IViewConventionCategory-ies with IConventionManager.AddViewConventions, but to fine trim the default rules you have to provide a custom IConventionManager and override SetupDefaultViewConventions.

3) Subject are useful in scenarios using composition in VM, where you have multiple screens exposing the same "sub-viewmodel", or the same screen working with multiple kind of object:

public class PersonEditorScreen: Screen, IPersonEditorScreen {
  public Person ThePerson {get;set;}
}
public class PersonOverviewScreen: Screen, IPersonOverviewScreen {
  public Person ThePerson {get;set;}
}
public class OrganizationOverviewScreen: Screen, IOrganizationOverviewScreen {
  public Organization TheOrganization {get;set;}
}

You can reorganize screens like:

public class PersonEditorScreen: Screen<Person>, IPersonEditorScreen {}
public class GenericOverviewScreen: Screen<T>, IOverviewScreen<T> {
 //common overview behaviors
}
public class PersonOverviewScreen: GenericOverviewScreen<Person> {}
public class OrganizationOverviewScreen: GenericOverviewScreen<Organization>  {}

This allows to qualify the screen as "a screen presenting a subject", gaining some facility from the ScreenConductor/IScreenSubject infrastructure: when you open a subject in a conductor, the latter takes care of creating a new screen against the given subject or to activate an existing one if already present.

Jun 27, 2010 at 3:47 AM

+1 for SL4 only. +1 for removal of CommonServiceLocator.

Jun 27, 2010 at 5:24 PM

+1 for SL4 only. All other ideas sounds good as well.

Jun 29, 2010 at 10:28 AM

-1 for SL4 only. My current project is rather large and complex (+700,000 LOC code-base) to which we have added Silverlight components using Caliburn trunk and the customer has no plans to upgrade to VS 2010 in the near future which makes SL4 unreachable for us. From what I gather using SL4 only will require VS 2010 and that upgrade isn't done overnight in larger codebases and teams. So SL4 is no problem for us but VS 2010 is. Please correct me if I have the wrong idea about the VS 2010+SL4 coupling that Microsoft has done. Also I think we cannot partially upgrade since the csproj/vbproj/sln format is not compatible so all developers would have to go into 2010 in one go (or we need to split the codebase into binary only dependencies which will make inter-operability painful). 

If Caliburn has to be SL4-only to be great I understand that you will have to do.... But it would be nice to have a way out for us poor VS 2008-only guys...

 

 

Coordinator
Jun 29, 2010 at 12:28 PM

All changes above except System.Windows.Interactivity will work for SL3. The interactivity piece will work partially; Action Parameters bound to elements will not work. Would you be able to live with that? If so, I could continue with my plan but keep SL3 as part of the build.

Jun 29, 2010 at 12:59 PM
Yes that would work for us. We are not using action parameters bound to elements (that I know of, I will check with the rest of our team). We could probably work around anything as long as there is a Silverlight 3 build for the core stuff so that would be nice. Thank you for considering our situation :-). I will lobby for upgrade to VS 2010 so perhaps in the end it will be SL4 for us as well. A side note: I have been able to use data-binding to indexers using strings as index even though that should not be possible in SL3 so I think even though we are using VS 2008, when we debug the project it is run with SL4-runtime somehow (it only works if you have SL4 runtime installed)...or perhaps the indexers work for other reasons, I haven't investigated why they work but it is interesting that they do...
Jun 29, 2010 at 3:38 PM
Jonas, et. al., I can completely understand your hesitancy on these proposals... I too have a complicated project (will approach 1M LOC). One thing that occurred to us last week was that you can never really control what versions of SL a person will have installed on their PC's (unless they are corporate-bound, locked down PCs). Therefore it is possible for someone to install SL4 and still try to run your product. If that is the case, the highest available version of Silverlight will be used and you may get some interesting results. It's not like .Net with full side-by-side parallel runtime environment binding. See: http://forums.silverlight.net/forums/t/186949.aspx. Our product is currently linked against the SL3 fx, and toolkit. However, when one of our testers, who only had SL3 installed tried to run some new functionality he received a DataContractSerializationException. All the developers on the team had both SL3 and SL4 installed and never witnessed the error because it was masked by the fact the higher framework version was installed on the developer machines. So in reality, even though the VS solution was a collection of SL3 projects, it *really* was a SL4 application because that is the environment developers used to validate functionality. How did we fix the testers situation? Had him install SL4. Frustrating. Rob
Jun 30, 2010 at 2:06 AM

I think people in general are more willing to upgrade their projects to the latest Silverlight in general, sans Caliburn, since every Silverlight release so far has had must have core feature adds. It's not like the move from WPF 3 to 3.51 or 4, the feature adds tends to be more dramatic (printing, webcam support, com interop, out of browser, core binding/styling features, etc..).

Jul 22, 2010 at 6:06 AM

Hi, I am currently using caliburn-50837 trunk.

I want to use my own bootstrapper instead of using CaliburnApplication class.

Is the base calss for Bootstrapper is added in this trunk? I have tried to look into the trunk but couldn't  find it.

If yes how I can use it.

 

Thanks,  Rajendra.

 

Coordinator
Jul 22, 2010 at 12:21 PM

None of the changes discussed here are in the Trunk yet. The first round of changes, related to ScreenConductor, will be checked in soon. After that I'll probably work on the IoC piece, then the Bootstrapper and finally the Interactivity. You should know, that using CaliburnApplication is not required. You could create your own Bootstrapper fairly easily by using the raw configuration API. Have a look at the basic samples for actions, etc. They all use the config API directly.

Jul 22, 2010 at 12:24 PM

@Rajendra

No, the refactoring is not done yet. Anyway, if you would like to anticipate segregation of bootstrapping code from Application class, you can use the "fluent" configuration rather than CaliburnApplication base class:

http://caliburn.codeplex.com/wikipage?title=Project%20Setup&referringTitle=Documentation
 

Jul 22, 2010 at 5:03 PM

Can't we getting a view of "Coming Attractions" with Caliburn.Micro?

 

Rob

Coordinator
Jul 22, 2010 at 8:36 PM

Yes. Essentially the Conductors from Micro are being ported over. I'm working on that now and have made a few improvements int the process which I will probably feedback into Micro as well. Bootstrapper and ActionMessage will be coming over as well, though their implementations will probably be quite a bit different in Caliburn in the end, due to the fact that they have to support a lot more features.

Feb 3, 2011 at 3:14 AM
Edited Feb 3, 2011 at 3:24 AM

How do you use dragable event triggers in blend to fire view model methods? With MvvmLite I would have been able to select a delegate command from the binding in blend, but I'm not really sure how to do this with Caliburn. I'm fairly new to this but I see that Caliburn is using normal methods instead of delegate commands but blend will not let me select a method as a Command. What am I missing?

Edit: Found the ActionMessage haha.

Feb 11, 2011 at 7:49 PM
Edited Feb 11, 2011 at 7:50 PM

I just downloaded the source and figure that one indication this isn't complete is that the solution in still VS2008..

Since I don't work with WP7 I have no compelling reason to need CM's smaller footprint, and I like that Caliburn (Classic?) has more in the way of validation and unit testing support (not to mention unit tests!).

I saw the recommendation to "prefer CM", but I'm not totally sure why. Is there a latest statement of direction for both products that I'm missing? 

Cheers

Feb 13, 2011 at 6:16 PM

+1 for SL4 only