AOP Methods–Introduction

As I have done with Roslyn for SkinnyControllers,I said – what about generating public methods at compile time ?

For example,what if this method

private string pubFullName()
{

return FirstName + ” ” + LastName;

}

 

is transformed into this

public string FullName(
[CallerMemberName] string memberName = “”,
[CallerFilePath] string sourceFilePath = “”,
[CallerLineNumber] int sourceLineNumber = 0)
{
try
{
Console.WriteLine(“–pubFullName start ” + _cc);
Console.WriteLine(“called class :” + memberName);
Console.WriteLine(“called file :” + sourceFilePath);
Console.WriteLine(“called line :” + sourceLineNumber);

return pubFullName();
}
catch (Exception ex)
{
Console.WriteLine(“error in pubFullName:” + ex.Message);
throw;
}
finally
{
Console.WriteLine(“——–pubFullName end”);

}
}

automatically,based on a template ? And all methods will have this ?

Enter AOP Methods : https://www.nuget.org/packages/AOPMethodsGenerator/  and https://www.nuget.org/packages/AOPMethodsCommon/

The first one is the generator. The second one is containing the attribute that tells to transform.


Posted

in

, ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *