Skip to content

Commit

Permalink
Added UseInterceptData.
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-tkachev committed Dec 28, 2023
1 parent c220f7a commit 9707797
Show file tree
Hide file tree
Showing 21 changed files with 165 additions and 102 deletions.
6 changes: 6 additions & 0 deletions AspectGenerator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MainApp", "Examples\MultiPr
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary", "Examples\MultiProject\ClassLibrary\ClassLibrary.csproj", "{13F7F7AC-F932-4784-992B-261FFEA27F7B}"
ProjectSection(ProjectDependencies) = postProject
{91353603-C41C-42C6-8A02-A5C451DBD280} = {91353603-C41C-42C6-8A02-A5C451DBD280}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aspects", "Aspects", "{5A4A61C1-F7EB-47A3-9E85-8706DBC5C9E7}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -54,6 +57,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspectGenerator.ClassLibrary", "UnitTests\ClassLibrary\AspectGenerator.ClassLibrary.csproj", "{00265084-D136-41BD-AE9F-C1D620E347C5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspectLibrary", "AspectLibrary", "{BB0C7C09-00AE-453A-9CE6-B750B4AB68F2}"
ProjectSection(SolutionItems) = preProject
Examples\AspectLibrary\Directory.Build.props = Examples\AspectLibrary\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspectLibrary", "Examples\AspectLibrary\AspectLibrary\AspectLibrary.csproj", "{FCF37E8B-F490-4B43-AF8B-534E3310D182}"
ProjectSection(ProjectDependencies) = postProject
Expand Down
9 changes: 1 addition & 8 deletions Examples/AspectLibrary/AspectLibrary/AspectLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<DefineConstants>$(DefineConstants);AG_PUBLIC_API</DefineConstants>
<DefineConstants>$(DefineConstants);AG_PUBLIC_API;AG_GENERATE_API</DefineConstants>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>

<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);AspectGenerator</InterceptorsPreviewNamespaces>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspectGenerator" Version="0.0.8-preview" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Examples/AspectLibrary/AspectLibrary/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace AspectLibrary
{
[Aspect(
OnBeforeCall = nameof(OnBeforeCall),
OnAfterCall = nameof(OnAfterCall)
OnBeforeCall = nameof(OnBeforeCall),
OnAfterCall = nameof(OnAfterCall)
)]
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public class LogAttribute : Attribute
public class ConsoleLogAttribute : Attribute
{
public static void OnBeforeCall(InterceptInfo info)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;

#if !AG_NOT_GENERATE_API
#if AG_GENERATE_API || !AG_NOT_GENERATE_API

namespace AspectGenerator
{
Expand Down Expand Up @@ -94,7 +94,7 @@ class InterceptInfo<T> : InterceptInfo

#endif

#if !AG_NOT_GENERATE_InterceptsLocationAttribute
#if AG_GENERATE_InterceptsLocationAttribute || !AG_NOT_GENERATE_InterceptsLocationAttribute

namespace System.Runtime.CompilerServices
{
Expand Down
4 changes: 2 additions & 2 deletions Examples/AspectLibrary/ClassLibrary/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace ClassLibrary
{
public class Class1
{
[Log]
[ConsoleLog]
public void InstanceMethod()
{
StaticMethod();
}

[Log]
[ConsoleLog]
public static void StaticMethod()
{
}
Expand Down
8 changes: 0 additions & 8 deletions Examples/AspectLibrary/ClassLibrary/ClassLibrary.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<DefineConstants>$(DefineConstants);AG_NOT_GENERATE_API</DefineConstants>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>

Expand All @@ -14,7 +8,5 @@

<ItemGroup>
<ProjectReference Include="..\AspectLibrary\AspectLibrary.csproj" />

<PackageReference Include="AspectGenerator" Version="0.0.8-preview" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;

#if !AG_NOT_GENERATE_API
#if AG_GENERATE_API || !AG_NOT_GENERATE_API

namespace AspectGenerator
{
Expand Down Expand Up @@ -94,7 +94,7 @@ class InterceptInfo<T> : InterceptInfo

#endif

#if !AG_NOT_GENERATE_InterceptsLocationAttribute
#if AG_GENERATE_InterceptsLocationAttribute || !AG_NOT_GENERATE_InterceptsLocationAttribute

namespace System.Runtime.CompilerServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ static SR.MethodInfo GetMethodInfo(SLE.Expression expr)
//[System.Diagnostics.DebuggerStepThrough]
public static void StaticMethod_Interceptor()
{
// AspectLibrary.LogAttribute
// AspectLibrary.ConsoleLogAttribute
//
var __info__0 = new AspectGenerator.InterceptInfo<AspectGenerator.Void>
{
MemberInfo = StaticMethod_Interceptor_MemberInfo,
AspectType = typeof(AspectLibrary.LogAttribute),
AspectType = typeof(AspectLibrary.ConsoleLogAttribute),
AspectArguments = StaticMethod_Interceptor_AspectArguments_0,
};

AspectLibrary.LogAttribute.OnBeforeCall(__info__0);
AspectLibrary.ConsoleLogAttribute.OnBeforeCall(__info__0);

if (__info__0.InterceptResult != AspectGenerator.InterceptResult.Return)
{
ClassLibrary.Class1.StaticMethod();

AspectLibrary.LogAttribute.OnAfterCall(__info__0);
AspectLibrary.ConsoleLogAttribute.OnAfterCall(__info__0);
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions Examples/AspectLibrary/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<DefineConstants>$(DefineConstants);AG_NOT_GENERATE_API</DefineConstants>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
Expand All @@ -16,7 +11,5 @@
<ItemGroup>
<ProjectReference Include="..\AspectLibrary\AspectLibrary.csproj" />
<ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj" />

<PackageReference Include="AspectGenerator" Version="0.0.8-preview" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;

#if !AG_NOT_GENERATE_API
#if AG_GENERATE_API || !AG_NOT_GENERATE_API

namespace AspectGenerator
{
Expand Down Expand Up @@ -94,7 +94,7 @@ class InterceptInfo<T> : InterceptInfo

#endif

#if !AG_NOT_GENERATE_InterceptsLocationAttribute
#if AG_GENERATE_InterceptsLocationAttribute || !AG_NOT_GENERATE_InterceptsLocationAttribute

namespace System.Runtime.CompilerServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ static SR.MethodInfo GetMethodInfo(SLE.Expression expr)
//[System.Diagnostics.DebuggerStepThrough]
public static void InstanceMethod_Interceptor(this ClassLibrary.Class1 __this__)
{
// AspectLibrary.LogAttribute
// AspectLibrary.ConsoleLogAttribute
//
var __info__0 = new AspectGenerator.InterceptInfo<AspectGenerator.Void>
{
MemberInfo = InstanceMethod_Interceptor_MemberInfo,
AspectType = typeof(AspectLibrary.LogAttribute),
AspectType = typeof(AspectLibrary.ConsoleLogAttribute),
AspectArguments = InstanceMethod_Interceptor_AspectArguments_0,
};

AspectLibrary.LogAttribute.OnBeforeCall(__info__0);
AspectLibrary.ConsoleLogAttribute.OnBeforeCall(__info__0);

if (__info__0.InterceptResult != AspectGenerator.InterceptResult.Return)
{
__this__.InstanceMethod();

AspectLibrary.LogAttribute.OnAfterCall(__info__0);
AspectLibrary.ConsoleLogAttribute.OnAfterCall(__info__0);
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions Examples/AspectLibrary/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>

<DefineConstants>$(DefineConstants);AG_NOT_GENERATE_API</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspectGenerator" Version="0.0.8.1-preview" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;

#if !AG_NOT_GENERATE_API
#if AG_GENERATE_API || !AG_NOT_GENERATE_API

namespace AspectGenerator
{
Expand Down Expand Up @@ -94,7 +94,7 @@ class InterceptInfo<T> : InterceptInfo

#endif

#if !AG_NOT_GENERATE_InterceptsLocationAttribute
#if AG_GENERATE_InterceptsLocationAttribute || !AG_NOT_GENERATE_InterceptsLocationAttribute

namespace System.Runtime.CompilerServices
{
Expand Down
2 changes: 1 addition & 1 deletion Examples/MultiProject/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<ItemGroup>
<Compile Include="..\Aspects\*.cs" />

<PackageReference Include="AspectGenerator" Version="0.0.8-preview" />
<PackageReference Include="AspectGenerator" Version="0.0.8.1-preview" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;

#if !AG_NOT_GENERATE_API
#if AG_GENERATE_API || !AG_NOT_GENERATE_API

namespace AspectGenerator
{
Expand Down Expand Up @@ -94,7 +94,7 @@ class InterceptInfo<T> : InterceptInfo

#endif

#if !AG_NOT_GENERATE_InterceptsLocationAttribute
#if AG_GENERATE_InterceptsLocationAttribute || !AG_NOT_GENERATE_InterceptsLocationAttribute

namespace System.Runtime.CompilerServices
{
Expand Down
2 changes: 1 addition & 1 deletion Source/AspectGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>

<Version>0.0.8-preview</Version>
<Version>0.0.8.1-preview</Version>

<IsPackage>true</IsPackage>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
Loading

0 comments on commit 9707797

Please sign in to comment.