Feedback Please...

Feb 17, 2008 at 3:29 AM
Edited Mar 24, 2008 at 5:45 AM

Here's a question for the 35 or so people who have downloaded ActiveSharp so far: do you have any feedback on it?

Would you use it?
If not, why not? (How could it be improved?)
Any suggestions about documentation?
Does the licence suit you? If not, what would suit better? Update: Licence is now MIT-style. That must suit you, right ;-)
What kind of documentation would you like to see?



Mar 24, 2008 at 12:55 AM
Interesting. I have seen a similar approach before but dismissed it, however your implementation appears to be much more robust. I need to find some more time to look into it but I am interested to see how well this can extend beyond the simple case of implementing INotifyPropertyChanged.

Currently I wrap all of my properties using generics to implement property change events as well as other things like undo/redo support, validation, etc..
ie. Property<int> MyInteger { get; set; }

Theoretically it seems that the same things should be possible using the technique you use here, without the ugly syntax burden of the Property<> wrapper. I will have to do some more research to see if this is viable, do you have any thoughts on the matter John?

Regards and thanks for sharing your code,
Mar 24, 2008 at 5:44 AM
Hi Steve,

Thanks for your comments.

Just out of curiosity, do you recall any details of the similar approach that you've seen before? I've heard of some that inspect the call stack (resulting in problems with inlining and possibly performance) but have not heard of any others yet.

Yes, it is definitely intended to be used for things other than property changed. All the things you mention, and more, are possibilities. (In fact, some of the code dates back to an earlier project of mine which focussed on validation). There's a surprisingly wide range of property-related functionality which can benefit from code that "knows" which property it has been called from. I'm hoping to blog about some possibilities in the future.

Interesting to hear about your "Property" generic wrapper. I presume that it has implicit casts to and from the type it wraps, right? I toyed with something similar myself some time ago. I vaguely recall striking some kind of issue with it, although I don't recall whether the issue related to my specific implementation or to the approach in general (i.e. exposing an "int" property as something which, technically speaking, is not an "int"). It may have been the latter, with regard to nullable types and lifted operators, but can't remember for sure.

Yes, my code is intended to do the same things without the wrapper. e.g.

int MyInteger
get { return GetValue(ref _myInteger); }
set { SetValue( ref _myInteger, value);}

private int _myInteger;

where GetValue and SetValue are generic methods that handle all the undo/redo, validation etc, calling ActiveSharp when they need to know which property they are working on.

This approach makes for a nicer experience for consumers of the objects (int's are exposed as ints, rather than Property<int>). However, its not so nice for authors of the property, because each property is more verbose than in the approach you use. I've submitted a suggestion to Microsoft to deal with the verbosity. If they were to accept it, the above could be written like this:

int MyInteger { get GetValue; set SetValue; }

I see this as potentially very useful -- and not just for ActiveSharp -- so hopefully people will show their support for the suggestion here:
Mar 25, 2008 at 2:43 AM

Thanks for the reply, I suspected you might be using this library for such scenarios. The other similar approach I have seen used delegates and reflection to do essentially the same thing (but with horrible performance), I believe it was in an OR mapping toolkit on googlecode that I saw this.

My implementation of Property<> wrapper is similar to the way it is done in 'DejaVu' on codeplex, which is also very similar to the method JetBrains uses in Resharper. I originally came across the technique while developing a Resharper plugin, their public API is worth taking a look at even if you aren't developing a plugin, they have some really good ideas. Speaking of Jetbrains, they just open sourced Omea also, some great stuff in there too. I am finding their setup/deployment scripts very useful!

I think your method is cleaner though, having the property definition be verbose is definitely preferable to having the extra syntax during consumption. It would be nice if MS listened to your suggestion and allowed for the cleaner syntax, I can see how that would come in handy in a number of situations.

One other possibility would be to use regular auto properties and then use PostSharp or another compile time weaver to rewrite the compiler generated get/set methods to call GetValue and SetValue methods, provided you can tolerate the use of attributes. ; )
Jul 15, 2008 at 10:04 AM
Here's the project I've been working on, which uses ActiveSharp to do some interesting stuff (namely bi-directional relationships between LINQ entities without codegen):
Jul 25, 2008 at 6:15 PM
Hi John, thanks for the update, that sounds like an interesting use for activesharp.  I am still using the library in my pet project with great results, unfortunately haven't had any time to work on it recently but hopefully I can get back in the swing of things soon. 

Really the only issue I have run into with ActiveSharp is some base class overriding members as is mentioned in the code comments.  I toyed with the idea of adding that functionality to the library but decided that it was probably better to just refactor my code as after looking at it again I noticed it was kind of a code smell.  I still might make a patch to add that into the library some day if you don't get around to it first, seems like it could be useful in some cases.

I will definitely have to check out your new project, I do a lot of codegen mapping between different entities or entities and DTO, never thought of using activesharp for that but it does sound like a great idea now that you mention it. 

Jul 27, 2008 at 12:16 AM
Hi again Steve,

Glad to hear its working well for you. 

I agree about the issue with overridden members.  I've logged it here in the project issue tracker too  I'm leaning towards using FieldInfos rather than names, and writing an equality comparer for the dictionaries which store them.  (Ditto for dictionaries where properties are keys).  Something like this:   I don't have an ETA on coding it just yet tho, sorry. 

Thanks also for your comments about the new project.  The challenge for me is in finding the time to take it from proof-of-concept to production status.  I'm partcularly interested in writing a small set of tools which would allow people to round-trip between existing LINQ generated entities and the Close2Poco style ones.  E.g. point the tool at an assembly containing LINQ entities, and it spits out the source code for a functionally-equivalent set of Close2Poco entities; point it at an assembly containing Close2Poco entities and it spits our the DMBL for a standard mapping, from which MS's generator can then re-generate code that should match your original generated source.  Nice for testing, and a nice way for people to get their feet wet with the product (just convert your existing entities and try it out.  If you don't like it; don't check the change into your source repository)


Mar 12, 2009 at 2:25 PM

Just thought that I would let you know that I am a fan of the ActiveSharp library and have been using it a wpf project I am involved with.

Mar 13, 2009 at 6:58 AM

- John
Jun 18, 2009 at 5:26 PM

Hi John - this seems very useful. One requirement in my project is to be able to track changes to collections - generic Lists and possibly Dictionaries.

Do you have any thoughts on whether ActiveSharp could be extended for this purpose.



Jun 22, 2009 at 6:00 AM

I can't think of a way to do that, I'm sorry.

Which kinds of changes do you need to track - simply that the list contents have changed, or do you need details of which things have been added and removed?  You may be able to wrap the lists/dictionaries which some kind of helper object that helps to detect additions and removals.

One other idea, if you are working with objects that maintain bi-directional relationships (e.g. if you do someCustomer.Orders.Add(myOrder) then myOrder.Customer is automatically set to someCustomer) then you really only need to detect the change at one end [and be able to figure out which list it relates to at the other end].  I played round with that kind of thing in Close2Poco, which you can see listed as a project related to ActiveSharp.



Nov 25, 2009 at 12:27 PM

Thanks for your hard work, we are trying it out on your CAL (Prism) project.

One need we have is to call property changes for other properties than the current one.

For example, we update first name property, we want fullname property updated as well.

With IPropertyChanged we simply call OnPropertyChanged for both properties in the correct order.

Fullname of course concatonates both first and last name properties to return its value.

Is there any way to do this with ActiveSharp?

Nov 27, 2009 at 1:57 AM

>With IPropertyChanged we simply call OnPropertyChanged for both properties in the correct order.

>Fullname of course concatonates both first and last name properties to return its value.

>Is there any way to do this with ActiveSharp?


Currently ActiveSharp doesn't help you with that.  (You can still call the notifcation method for fullname yourself, just like you would without ActiveSharp, but it doesn't help you do that, at all.)

I do have some code (not currently on the web) which can figure out which properties depend on other properties.  (E.g. it can figure out that fullname depends on firstname).  It would be interesting to use it to do a little codegen step, after the main assembly is built.  It could load an assembly, inspect the properties inside it, and produce some kind of mapping, like this:

new PropertyDependencyMap<Person>()

   .Add(p => p.FirstName, p => p.FullName)

   .Add(p => p.DateOfBirth, p => p.Age)



and then activesharp could consume that information at runtime, to automatically send a notification for fullname when firstname changes, and for age when dateOfBirthChanges.

Unfotunately, I don't have time to do that at present.  Sorry.