//TODO: Extensible Metadata

I was talking to a friend of mine called Mario "Cubano" Rodriguez who is a Java guy that have started working in .Net, he's a very smart guy and he really likes to talk about development and programming languages. He's very advocated to create some support for C# similar for the features provided by Eiffel and he created an interesting implementation of it using the ContextBoundObject interception and an Xml configuration file to place the invariant rules, preconditions and postconditions. He can place rules for his objects in an Xml file using any .Net languaje and the framework can apply those rules on every object usage during runtime.

I asked him why he does not uses attributes and he says the problem of placing rules in atttribues is that he must recompile his code every time a rule is changed. And he's correct. I was thinking about that and the original idea of the Atrtibutes was the ability to extend the language "expresiveness" without extening the language itself. It's a great solution for the __export in MS C compiler, for all the IDL language in the C++ compiler, and many of the #pragmas in the C/C++ compiler. But some information is related to the program structure (in/out parameters, parameter marshall information, external methods) that should not be changed without also changing the code implementation. But some other metadata information may be changed without having to recompile the code (transactions, security attributes, business rules, etc).

So I really like to have a framework to extend the compiled metadata with an external file, so i can override the metadata in the original assembly. There should be some restrictions in order to provide security, for example the extended metadata should be signed with the same key.

I was wondering how to implement this in .Net, in Java i can create a class loader and the JVM will call my class to load any class, if i have such suppoort i can load the assembly and the metadata extension, merge the metadata in a single assembly and tell the CLR to use that assembly. But seems I can't hook the assembly loader in .Net. So i think the only way to do this is the ROTOR code.

Anyway i'm very busy in theese days to do that so i'll keep thinking about it.

7 Comments

  • ::he says the problem of placing rules in

    ::atttribues is that he must recompile his

    ::code every time a rule is changed.



    Hm. not sure yet, but it seems to me that this is WRONG WRONG WRONG.



    I am hunting a way right now to dynamically return attributes at runtime that are determined at runtime. It looks like this is possible.

  • yes sure, agree with you

  • Wouldn't this be what is usually called Aspect Oriented Programming?

  • I don't know if is the same as AOP. AOP is about crosscutting concerns or functionality that applies horizontally to many classes. My idea is about composing metadata (attributes) dynamically in run-time.

    Probably this is closer to a complain, because the metadata in .Net is static and also there's no way to intercept the loading of the assemblies.

  • I think the most important issue for AOP is interception in instance boundaries. I mean every time you call a method, access a field, etc. If you can do that without changind the code of the intercepted class you can do AOP is a clean fashion. Of course AspectJ is a compiler that generates new code using the Java source code and the AOP declarations.



    What I say about interception is only during assembly loading to change metadata. Not about changing code.



    Thanks for asking about blogging, I was very busy working many projects over here and also for PAG in Microsoft Corp. so blogging has low priority in my everyday scheduler :)

    I have a couple of news I'll post very shortly.

  • with his energetic, uplifting and euphoric sets incorporating styles from across the spectrum of dancefloor drum & bass.

  • Thanks , I?ˉve recently been searching for details roughly this topic for ages and yours may be the greatest I have found so far. But, what concerning the conclusion? Are you currently particular concerning the supply?

Comments have been disabled for this content.