** C# 9.0 ONLY ** Autogenerates public methods from a class . ( replace below single quotes with double quotes) [AutoMethods(template = TemplateMethod.CallerAtttributes, MethodPrefix ='pub', MethodSuffix ='bup')] partial class Person { public string LastName { get; set; } public string FirstName { get; set; } private string pubFullName() { return FirstName + ' ' + LastName; } private void pubWriteToConsoleFullName() { Console.WriteLine(this.FullName()); } } // it will generate for this class the public methods public string FullName public string WriteToConsoleFullName Add also Nuget package AOPMethodsCommon You can have your own template - read the readme.txt


Keywords
RoslynCodeGenerators, C#, CSharp, SkinnyControllers, aop, roslyn
License
MIT
Install
Install-Package AOPMethodsGenerator -Version 2022.5.20.2101

Documentation

AOP_With_Roslyn

GitHub license

NuGet

Build Status

codecov

Install as global tool as

dotnet tool install -g dotnet-aop

go to your solution folder run

dotnet aop

For customizing what you want to insert at every method at first line and last line, see https://github.com/ignatandrei/AOP_With_Roslyn/blob/master/AOPRoslyn/processme.txt

You can save the document in your solution root and execute with

dotnet aop <your file name>

The following table is generated by gathering statistics from dotnet aop tests with dotnet aop integrated :

Class Method(Line) NumberHit TotalTime AverageTime
TestLineDirective TestException(55) 1 2881 2881
TestArguments TestArgumentsFor(13) 1 543 543
RewriteCodeFile Rewrite(44) 5 533 106
TestLineDirective TestNoLineRefactoring(125) 1 79 79
RewriteCode RewriteCodeMethod(45) 13 566 43
TestSerialize TestSerializeRewriteCodeFolder(14) 1 26 26
TestComment TestUnComment(12) 1 22 22
TestCommandLine TestMethodRewriterSimple(9) 1 15 15
TestRewriteCode TestAOPFolder(78) 1 11 11
RewriteCodeFolder Rewrite(69) 1 9 9
MethodRewriter VisitMethodDeclaration(72) 23 140 6
TestRegion TestOneRegion(11) 1 5 5
TestAOPExtension TestExtensionIsModifierOnEnum(12) 1 5 5
TestInitializeAll Init(14) 1 4 4
RewriteAction UnSerializeMe(52) 3 14 4
RewriteAction SerializeMe(33) 3 12 4
TestRewriteCode TestAOPFile(64) 1 3 3
TestSerialize TestSerializeRewriteCodeFile(26) 1 1 1
TestRewriteCode TestModifierMethodNoCodeInFile(13) 1 1 1
TestLineDirective TestLineSimple(18) 1 0 0
TestLastLine TestMethodRewriterLastLine(9) 1 0 0
TestCommandLine TestMethodRewriterAddVariable(47) 1 0 0
Extensions IsOnEnum(78) 40 0 0
TestSerialize TestSerializeRewriteCodeFolderFormatter(42) 1 0 0
TestRewriteCode TestModifierMethod(25) 1 0 0