Skip to content

Commit

Permalink
github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Asli Yigit authored and Asli Yigit committed Dec 13, 2023
1 parent 2fc0b9f commit 538b102
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 26 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ NexusAop empowers developers to embrace the principles of AOP by providing a str
2. <b>Method Interruption:</b> <br />
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. <b>Result Retrieval:</b> <br />
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. <b>Custom Attributes:</b> <br />
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. <b>.NET 5.0 Compatibility:</b> <br />
Expand All @@ -61,7 +61,7 @@ public async Task<int> MyMethodAsync()
```
3. <b>Integrate Aspect-Oriented Behavior: </b><br />

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
Expand All @@ -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;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public class CacheMethodAttribute : NexusAopAttribute
return;
}

result = await context.SetResultAsync();
result = await context.ExecuteAndGetResultAsync();
await SetCacheAsync(context.TargetMethod, context.TargetMethodsArgs,result);
}

Expand Down
2 changes: 1 addition & 1 deletion samples/NexusAop.Console/Cache/CacheMethodAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
20 changes: 1 addition & 19 deletions samples/NexusAop.Console/CustomAspect/CustomAspectAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@ namespace NexusAop.Console.CustomAspect
{
public class CustomAspectAttribute : NexusAopAttribute
{
public Dictionary<string, object> Properties { get; }

public CustomAspectAttribute(params object[] propertyValues)
{
Properties = new Dictionary<string, object>();

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
Expand All @@ -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.");
Expand Down
20 changes: 19 additions & 1 deletion src/NexusAop/NexusAop.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<PackageId>AdsPush</PackageId>
<Authors>Anil Dursun SENEL, Asli YIGIT</Authors>
<PackageTags>aop;reflection;attribute;dispatch proxy;cache</PackageTags>
<Description>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.
</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>https://github.com/adessoTurkey-dotNET/NexusAop</PackageProjectUrl>
<RepositoryUrl>https://github.com/adessoTurkey-dotNET/NexusAop</RepositoryUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Copyright>Copyright (c) 2023, Anıl Dursun ŞENEL , Asli YIGIT</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="\" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0-rc.1.21451.13" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="NewFolder\" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/NexusAop/NexusAopContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task<object> NextAsync()
}
else return null;
}
public async Task<object> SetResultAsync()
public async Task<object> ExecuteAndGetResultAsync()
{
if (TargetMethod.ReturnType == typeof(void))
{
Expand Down

0 comments on commit 538b102

Please sign in to comment.