Import Attribut Commandline

Questions about integration in Visual Studio, MSBuild or other IDEs or build tools.

Import Attribut Commandline

Postby mreis on Fri Apr 25, 2008 11:43 am

Hello Community,

I need an example for import an attribut in a assembly with the commandline-Tool.

Code: Select all
"C:\Program Files\PostSharp 1.0\Postsharp.exe" "C:\Program files\PostSharp 1.0\Default.psproj"  "D:\REISM\Visual Studio 2005\Projects\Testprojekte\tracer_postsharp\tester.App.TracerPostsharp.PostSharpEnhanced\bin\Debug\tester.App.TracerPostsharp.PostSharpEnhanced.dll" /P:Output="D:\REISM\Visual Studio 2005\Projects\Testprojekte\tracer_postsharp\tester.App.TracerPostsharp.PostSharpEnhanced\bin\Debug\Test.dll" /p:IntermediateDirectory=. /P:SignAssembly=true /P:CleanIntermediate=false /P:PrivateKeyLocation="D:\REISM\Visual Studio 2005\Projects\Testprojekte\tracer_postsharp\tracer_postsharp\tester.snk" /P:SearchPath="D:\REISM\Visual Studio 2005\Projects\Testprojekte\tracer_postsharp\tracer_postsharp\bin\Debug\Tracer.dll"


This works!!!

My problem is, I will automatically import the following line in my Assembly:

[assembly: Tracer.TraceAspect(AttributeTargetTypes = "MyNamespace.*")]

Please help me! Where is a help of Configurationfile?

Thank you

Mathias Reis
Last edited by mreis on Sun Apr 27, 2008 8:04 pm, edited 1 time in total.
mreis
 

Re: Import Attribut Commandline

Postby gfraiteur on Fri Apr 25, 2008 1:44 pm

Hi,

There is no off-the-shelf way currently. You have to have the source code and to add the custom attribute to the code.

Alternatively, you can develop a custom task (ICustomAttributeProvider) using PostSharp Core and include it in the PostSharp project.

Gael
gfraiteur
 

Re: Import Attribut Commandline

Postby mreis on Mon Apr 28, 2008 5:51 pm

Hallo Gael,

thanks for your answer. I have another question, the following line is implement in my project:

[assembly: TraceAspect(AttributeTargetElements = PostSharp.Extensibility.MulticastTargets.Method)]

I think, the AttributeTargetElements to filter the Assembly and import the functions only in "Methods" of the project. That is not correct. It is implement in all Elements (Propeties, Constructors ...) What can I do?

Mathias
mreis
 

Re: Import Attribut Commandline

Postby gfraiteur on Mon Apr 28, 2008 9:07 pm

This should apply the aspect to all methods, including property and event accessors, but not on constructors.
gfraiteur
 

Re: Import Attribut Commandline

Postby mreis on Tue Apr 29, 2008 9:37 am

Hallo Gael,

that is an error. Its also in Constructors. Look the following section:

Code: Select all
public Kunde()
{
    MethodExecutionEventArgs ~laosEventArgs~1;
    try
    {
        ~laosEventArgs~1 = new MethodExecutionEventArgs(methodof(Kunde..ctor, Kunde), this, null);
        ~PostSharp~Laos~Implementation.TraceAspectAttribute~10.OnEntry(~laosEventArgs~1);
        if (~laosEventArgs~1.FlowBehavior != FlowBehavior.Return)
        {
            ~PostSharp~Laos~Implementation.TraceAspectAttribute~10.OnSuccess(~laosEventArgs~1);
        }
    }
    catch (Exception ~exception~0)
    {
        ~laosEventArgs~1.Exception = ~exception~0;
        ~PostSharp~Laos~Implementation.TraceAspectAttribute~10.OnException(~laosEventArgs~1);
        switch (~laosEventArgs~1.FlowBehavior)
        {
            case FlowBehavior.Continue:
            case FlowBehavior.Return:
                return;
        }
        throw;
    }
    finally
    {
        ~PostSharp~Laos~Implementation.TraceAspectAttribute~10.OnExit(~laosEventArgs~1);
    }
}


I have only include the Attribut:
[assembly: TraceAspect(AttributeTargetElements = PostSharp.Extensibility.MulticastTargets.Method)]

What can I do?

Very thanks for your help

Mathias
mreis
 


Return to Integration with IDE and Build Scripts