[MonoDevelop] [Patch] Mark T4-generated classes with 'partial'

Olivier Dagenais olivier.dagenais at gmail.com
Tue Dec 1 20:42:40 EST 2009


> Yup, I see no harm in it either. It should be especially useful when
> we allow generating template classes from tt files within MD, like
> VS2010 does (http://monodevelop.com/Developers/Tasks/Tools/T4#_task_a_T4.ClassGenerator).

Cool, I already wrote code to make this happen for me with Visual
Studio 2008.  See
<http://code.google.com/p/softwareninjas/source/detail?r=29> for the
initial MSBuild task I wrote based on some of the code in
GenerationTests.  The T4 patches I have been submitting (a few more
are on the way) are the changes I made to help make this happen.

While I have your attention, I would like to discuss the next patch I
was going to submit:  fixing the multi-threading nightmare that is
ToStringHelper.  I realize it was Microsoft who introduced it, but I
see no compelling reason to have the functionality it provides be
implemented as a singleton.  In my project, I incorporated its
functionality as instance methods on TextTransformation so that
parallel instances of TextTransformation (from the same or different
template) could use their own IFormatProvider instances without
risking a race condition in TemplatingEngine.Run().

See <http://code.google.com/p/softwareninjas/source/detail?r=26> for
my implementation, which suits my purposes.  It has the side-effect
that compiled templates would only need to reference
TextTransformation and thus end-users could include Mono's
implementation of TextTransformation.cs in their projects much the
same way that end-users of Mono.Options can simply include
Mono.Options.cs in their projects.

In the general case, however, I think we would be better off adding a
read-write property called FormatProvider to TextTransformation and
thus avoid touching the TextTransformation constructor.  As you can
see in revision 26, I ended up painting myself into a corner with
TemplatingEngine.cs with my first approach while the approach I'm
proposing here (i.e. the property) would be simpler because it
wouldn't have to deal with instantiation by reflection.

What do you think?
- Oli


More information about the Monodevelop-list mailing list