> > Well, the way to do it is have a "using" directive for the namespace
> > containing the new set of extensions, and get rid of the one for the
[quoted text clipped - 3 lines]
> since it will require rewriting them? I just want to have the ability to
> modify a few if necessary, say, for specific applications.
Then you'd be well advised to keep different extensions in different
namespaces.
Personally I don't like the way extension method discovery worked - I
wish you had to specify the exact *class* to get stuff from instead of
a namespace. Basically at the moment you're well advised to keep to a
few extended types per namespace, if not just one.
> Lets say I override 30 types and one of those is DateTime. But for a
> specific application I want to change what the extension does(say instead of
[quoted text clipped - 9 lines]
> (which means there is no easy way to extend it... but maybe reflection can
> help?)
One lesson there is to keep source code!
> Seems like a bad thing to make extensions unextendable ;/ (not sure if the
> is a programmatic reason or what)
I can't easily think of an *elegant* way to do it, to be honest -
beyond what I suggested earlier.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jon Slaughter - 04 Apr 2008 03:23 GMT
>> > Well, the way to do it is have a "using" directive for the namespace
>> > containing the new set of extensions, and get rid of the one for the
[quoted text clipped - 40 lines]
> I can't easily think of an *elegant* way to do it, to be honest -
> beyond what I suggested earlier.
But I might want to distribute the code or use it in a different program
without worrying about the source code. I don't think namespaces can help
here because ultimately it still requires me to redefine all extensions.
What I mean is, suppose I have some extension to Int32 and I write an app
that uses that extension. Then I want to modify the extensions internal
workings which does not effect the apps behavior in the least bit... but
this can't be done!?!?! Why? Because I can't use the same name or I'll have
to recode all the extensions. (since you get all or nothing... unless I had
one extension per namespace ;/)
Another example:
suppose I have 20 extensions to the basic types all in the same namespace
and an app that uses them all. I want to modify the internals of just one
but still have it work with the app. Can't be done unless I recode them all
or use a different name.
Now I suppose I could replace method names in all the files but seems like
a.s backwards way to do it.
I suppose it would be better to have a way to tell the compiler which
extension to use when there is a collision. This would solve the problem and
probably could be done quite easily using an attribute or something.
Jon Skeet [C# MVP] - 04 Apr 2008 08:18 GMT
> > I can't easily think of an *elegant* way to do it, to be honest -
> > beyond what I suggested earlier.
[quoted text clipped - 9 lines]
> to recode all the extensions. (since you get all or nothing... unless I had
> one extension per namespace ;/)
It sounds like really you just want to rebuild the class library with
the replaced internals. This is no different to any other peice o code
versioning - how would you do it if you wanted to replace the
implementation of a normal instance method?

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk