Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Gael Fraiteur
    @gfraiteur
    Hi there, just opening this channel so people can share and ask in real time.
    hflorin
    @hflorin
    Hello
    hflorin
    @hflorin
    I have a question regarding exceptions and Metalama. I'm interested in logging the parameters value for the methods in the callstack when an exception is thrown. Is there something in Metalama that can help with that? I've been looking at EnrichExceptionAttribute sample from Metalama, which adds the paramater values in the exception context. This does not work for exceptions that are handled though. Is there any way that I can get the values in case of handled exceptions? Something equivalent to OnExceptionAttribute from Postsharp. Thank you
    Antonín Procházka
    @prochan2
    Hello, would this example work for you? https://try.metalama.net/#log-parameters
    hflorin
    @hflorin
    Not really, because if the exception is handled and not rethrown, then the aspect does not catch it.
    Antonín Procházka
    @prochan2

    I see, but the OnExceptionAttribute in PostSharp behaves the same way. You'd need to apply the aspect to the method which throws the exception. Here you can find the documentation of how to apply one aspect to multiple targets. https://doc.metalama.net/fabrics/fabrics-aspects

    Neither PostSharp nor Metalama process exceptions which are handled within a method. In such case, you'd need to log the exception manually or extract the part of the code throwing the exception to another method and apply the logging aspect on that method.

    hflorin
    @hflorin
    Yes, you are right, same behavior with OnExceptionAttribute in PostSharp.
    hflorin
    @hflorin
    Thank you
    Antonín Procházka
    @prochan2
    You're welcome. Thank you for trying Metalama :)
    Guy Cohen
    @gcohen12

    @prochan2
    Is there a way to plot out the parameters and values of the call stack after a cached exception?

    We were aiming to do it as OnExceptionAttribute and then we found out that it would work only for uncatched exceptions - which is not the case in our application.
    Saving the stack with Deep copy (immutable) all the way with a Method aspect seems quite costly in terms of Memory and CPU . correlating it via saving each thread context with our own data structure seems as a replication of data.

    Do you have a better suggestions?

    Thanks in advance.

    Guy Cohen
    @gcohen12
    And also - read that Metalama is released - will the nuget package be updated from less that version 1.0-preview to 1.0?
    hflorin
    @hflorin
    Hello,
    Is there a way to serialize a parameter value to JSON in the LogAttribute class from Logging with parameters sample? Currently it's logging parameter.Value, which is fine for primitive types, but for objects it just prints the object type.
    Gael Fraiteur
    @gfraiteur
    Hello, sorry for late answer. We had some issues with the management of this channel so we forgot to answer.
    In the example https://github.com/postsharp/Metalama.Samples/tree/0.5.24/src/Metalama.Samples.LogParameters, change the line stringBuilder.AddExpression( p.Value ); to stringBuilder.AddExpression( ExpressionFactory.Parse( $"System.Text.Json.JsonSerializer.Serialize( { p.Name } ) " ) );and it should work.