Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin Forms Free AOP Library

$
0
0

I am looking to implement logging functionality to my Xamarin.Forms application.

I heard about MetroLog which seem to be interesting; however, I dont like the fact that a clean method like in example below gets cluttered with code that makes this method literally "polluted". In addition, it violates KISS, 10/100, SRP, .... principles:

public void DoSomething()
{
  Logger.Log("DoSomething - start");

  try
  {
     // do something here and possible do more logging
  } 
  catch(Exception ex)
  {
     Logger.Log("DoSomething threw exception: {0}", ex.Message);
  }

  Logger.Log("DoSomething - end");
}

This pollutes the code and violates the principles I mentioned above. This method should really look like this

public void DoSomething()
{
   // do something here
}

Then I read something about AOP (Aspect Oriented Programming) in which case, all the logging calls could be moved to a separate aspect class LoggerAspect and the method above could be used like:

[LoggerAspect]
public void DoSomething()
{
   // do something here
}

Has anyone used any free Xamarin.Forms friendly AOP library? Something like PostSharp (which unfortunately is not free and not Xamarin.Forms friendly)?

Can you recommend one?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>