Method Creation at Build Time

Discuss simply about anything.

Re: Method Creation at Build Time

Postby yoavsion on Tue Jan 08, 2008 8:55 am


First of all - thanks so much so the detailed response. It would sure make the process much shorter.
I've downloaded the source pack and started working on it.
After struggling with the conversion to VS2008 a bit, I've managed to perform the suggested changes.
Even managed to compile (almost at first run, yey!). I've copied the assembly to the program files installation and then came the signing part.
When compiling my project, the assembly could not be loaded because it is a delayed signing. I've "installed" the PostSharp-32bit.reg file - But still, the assembly cannot be loaded. (I've checked the registry - The key's there.)
I've even tried (with doubt in the begining) to compile PostSharp.exe again and copy it into the program files as well.
Anything I'm missing here? I've read the whole readme.html file again and again. Can't seem to find the reason it won't load.
Thanks,
Yoav.

Yoav Sion
yoavsion
 
Posts: 12
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Yoav Sion

Re: Method Creation at Build Time

Postby gfraiteur on Tue Jan 08, 2008 9:22 am

Sorry, I have no clue. Check with the utility "sn -Vl" that strong name validation has properly been inactivated for PostSharp keys.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 673
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Method Creation at Build Time

Postby yoavsion on Tue Jan 08, 2008 11:18 am


Sorry to have bothered you, but it seems like a restart (System / Studio only? Don't know, have restarted the whole system) did the job!
The composed method was composed along with the implementing type's method attributes!
That is just beautiful!
Thanks!
(Now for some serious talk.. When do you think it will be possible to integrate this into any of the format releases of PostSharp?)


Thanks again,
Yoav Sion.
Yoav Sion
yoavsion
 
Posts: 12
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Yoav Sion

Re: Method Creation at Build Time

Postby yoavsion on Tue Jan 08, 2008 11:22 am


Sorry again.
It seems like I have mistaken (trigger finger). The attributes when not cloned to the composed method.
I will look into it later on.


Good day,
Yoav Sion.
Previously Yoav Sion wrote:

Sorry to have bothered you, but it seems like a restart (System / Studio only? Don't know, have restarted the whole system) did the job!
The composed method was composed along with the implementing type's method attributes!
That is just beautiful!
Thanks!
(Now for some serious talk.. When do you think it will be possible to integrate this into any of the format releases of PostSharp?)


Thanks again,
Yoav Sion.


Yoav Sion
yoavsion
 
Posts: 12
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Yoav Sion

Re: Method Creation at Build Time

Postby yoavsion on Tue Jan 08, 2008 1:40 pm


OK.. This time it's really done and checked.
The custom attributes were indeed copied from the declaring interface's method's Custom Attributes.
However, there was a small error with the code. Trying to call AddCloneRange with a CustomAttributeDefCollection failed, because CustomAttributeDefDeclaration does not implement IClonable.
Maybe the type constraint for ItemType at ElementCollection should limit it to be IClonable?
Anyways, I have changed the logics a bit and replace the call with the following forech statement:
foreach (CustomAttributeDeclaration sourceAtt in targetMethodDef.CustomAttributes)
{
    CustomAttributeDeclaration newAtt = new CustomAttributeDeclaration(sourceAtt);
    newMethod.CustomAttributes.Add(newAtt);
}
This copies the custom attributes just fine.
[b]Notice[/b]: The statement must follow the "targetType.Methods.Add( newMethod );" call, or else an error is raised saying that the attribute cannot be attached to the method, because the method is not attached by itself.
Gael - Thank you very much for your help.
Should I post a request for this feature anywhere else but here?
When is such a feature (if at all) expected to be integrated into formal PostSharp releases?
Yoav Sion
yoavsion
 
Posts: 12
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Yoav Sion

Re: Method Creation at Build Time

Postby gfraiteur on Tue Jan 08, 2008 9:35 pm

Yoav,

I don't plan to introduce this feature immediately, since it is not a general solution to the problem. I will think about this, however.

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 673
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Previous

Return to Unordered Thoughts


cron