From 538b1020768a043623cfb800aa56bea6dbef6e5f Mon Sep 17 00:00:00 2001 From: Asli Yigit Date: Wed, 13 Dec 2023 17:51:44 +0300 Subject: [PATCH] github workflows --- .github/workflows/dotnet-build.yml | 25 ++++++++++++ .github/workflows/publish.yml | 40 +++++++++++++++++++ README.md | 8 ++-- .../Cache/CacheMethodAttribute.cs | 2 +- .../CustomAspect/CustomAspectAttribute.cs | 20 +--------- src/NexusAop/NexusAop.csproj | 20 +++++++++- src/NexusAop/NexusAopContext.cs | 2 +- 7 files changed, 91 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/dotnet-build.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml new file mode 100644 index 0000000..5a7e3d3 --- /dev/null +++ b/.github/workflows/dotnet-build.yml @@ -0,0 +1,25 @@ +name: .NET + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 5.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6506866 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,40 @@ +name: "Nuget-NexusAop" + +on: + push: + tags: + - 'v*' + +env: + PROJECT_PATH: 'src/NexusAop/NexusAop.csproj' + PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}\output + NUGET_SOURCE_URL: 'https://api.nuget.org/v3/index.json' + +jobs: + deploy: + name: 'Deploy' + runs-on: 'windows-latest' + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + + - name: 'Install dotnet' + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '5.0.x' + + - name: 'Restore packages' + run: dotnet restore ${{ env.PROJECT_PATH }} + + - name: 'Build project' + run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release + + - name: 'Get Version' + id: version + uses: battila7/get-version-action@v2 + + - name: 'Pack project' + run: dotnet pack ${{ env.PROJECT_PATH }} --no-restore --no-build --configuration Release --include-symbols -p:PackageVersion=${{ steps.version.outputs.version-without-v }} --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }} + + - name: 'Push package' + run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY }}\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ env.NUGET_SOURCE_URL }} --skip-duplicate \ No newline at end of file diff --git a/README.md b/README.md index 6a58adc..57c4121 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ NexusAop empowers developers to embrace the principles of AOP by providing a str 2. Method Interruption:
Leverage the NextAsync() method to interrupt the execution of a method and perform specific actions before allowing the method to continue. This allows for dynamic and context-aware behavior in your applications. 3. Result Retrieval:
-Utilize the SetResultAsync() method to retrieve the result of the related method. This feature is particularly useful when you need to capture and manipulate the output of a method in a controlled manner. +Utilize the ExecuteAndGetResultAsync() method to retrieve the result of the related method. This feature is particularly useful when you need to capture and manipulate the output of a method in a controlled manner. 4. Custom Attributes:
Easily create and apply custom attributes to your methods, enabling a clean and declarative way to define aspects. Custom attributes in NexusAop serve as the building blocks for weaving cross-cutting concerns into your application. 5. .NET 5.0 Compatibility:
@@ -61,7 +61,7 @@ public async Task MyMethodAsync() ``` 3. Integrate Aspect-Oriented Behavior:
-Use the provided methods such as NextAsync() and SetResultAsync() within your custom aspects to influence the method execution flow. +Use the provided methods such as NextAsync() and ExecuteAndGetResultAsync() within your custom aspects to influence the method execution flow. ```csharp public class CustomAspectAttribute : NexusAopAttribute @@ -76,7 +76,7 @@ public class CustomAspectAttribute : NexusAopAttribute // User-defined logic after the target method // Get the result if you needed - var setResult= await context.SetResultAsync(); + var setResult= await context.ExecuteAndGetResultAsync(); return result; } @@ -117,7 +117,7 @@ public class CacheMethodAttribute : NexusAopAttribute return; } - result = await context.SetResultAsync(); + result = await context.ExecuteAndGetResultAsync(); await SetCacheAsync(context.TargetMethod, context.TargetMethodsArgs,result); } diff --git a/samples/NexusAop.Console/Cache/CacheMethodAttribute.cs b/samples/NexusAop.Console/Cache/CacheMethodAttribute.cs index 45bc0d3..11d7cab 100644 --- a/samples/NexusAop.Console/Cache/CacheMethodAttribute.cs +++ b/samples/NexusAop.Console/Cache/CacheMethodAttribute.cs @@ -43,7 +43,7 @@ public override async Task ExecuteAsync(NexusAopContext context) return; } - result = await context.SetResultAsync(); + result = await context.ExecuteAndGetResultAsync(); await SetCacheAsync(context.TargetMethod, context.TargetMethodsArgs,result); } diff --git a/samples/NexusAop.Console/CustomAspect/CustomAspectAttribute.cs b/samples/NexusAop.Console/CustomAspect/CustomAspectAttribute.cs index 92168d5..c7c6e9f 100644 --- a/samples/NexusAop.Console/CustomAspect/CustomAspectAttribute.cs +++ b/samples/NexusAop.Console/CustomAspect/CustomAspectAttribute.cs @@ -6,24 +6,6 @@ namespace NexusAop.Console.CustomAspect { public class CustomAspectAttribute : NexusAopAttribute { - public Dictionary Properties { get; } - - public CustomAspectAttribute(params object[] propertyValues) - { - Properties = new Dictionary(); - - if (propertyValues.Length % 2 != 0) - throw new ArgumentException("Property values must be provided as name-value pairs."); - - for (int i = 0; i < propertyValues.Length; i += 2) - { - if (!(propertyValues[i] is string propertyName)) - throw new ArgumentException("Property name must be a string."); - - Properties[propertyName] = propertyValues[i + 1]; - } - } - public override async Task ExecuteAsync(NexusAopContext context) { // User-defined logic before the target method @@ -33,7 +15,7 @@ public override async Task ExecuteAsync(NexusAopContext context) var result=await context.NextAsync(); - var setResult= await context.SetResultAsync(); + var setResult= await context.ExecuteAndGetResultAsync(); // User-defined logic after the target method //System.Console.WriteLine("After invoking the target method."); diff --git a/src/NexusAop/NexusAop.csproj b/src/NexusAop/NexusAop.csproj index db75467..d823cf3 100644 --- a/src/NexusAop/NexusAop.csproj +++ b/src/NexusAop/NexusAop.csproj @@ -1,13 +1,31 @@ - net5.0 + net5.0 + AdsPush + Anil Dursun SENEL, Asli YIGIT + aop;reflection;attribute;dispatch proxy;cache + NexusAop is a powerful and flexible library for reflection and aspect-oriented programming (AOP) in .NET 5.0. This library enables developers to easily apply cross-cutting concerns to their applications by utilizing custom attributes. With NexusAop, you can interrupt method executions, perform specific actions, and retrieve results seamlessly. + + true + https://github.com/adessoTurkey-dotNET/NexusAop + https://github.com/adessoTurkey-dotNET/NexusAop + LICENSE + Copyright (c) 2023, Anıl Dursun ŞENEL , Asli YIGIT + README.md + true + + + + + + diff --git a/src/NexusAop/NexusAopContext.cs b/src/NexusAop/NexusAopContext.cs index c7fa78a..01a8e94 100644 --- a/src/NexusAop/NexusAopContext.cs +++ b/src/NexusAop/NexusAopContext.cs @@ -37,7 +37,7 @@ public async Task NextAsync() } else return null; } - public async Task SetResultAsync() + public async Task ExecuteAndGetResultAsync() { if (TargetMethod.ReturnType == typeof(void)) {