├── .editorconfig
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ └── application.yml
├── .gitignore
├── .vscode
├── launch.json
├── settings.json
└── tasks.json
├── AspectInjector-Key.snk
├── AspectInjector.sln
├── Directory.Build.props
├── LICENSE
├── README.md
├── aspects
├── Cache
│ ├── AbstractAttributes.cs
│ ├── Aspects.Cache.csproj
│ ├── CacheAspect.cs
│ ├── MemoryCacheAttribute.cs
│ └── readme.md
├── Directory.Build.targets
├── Freezable
│ ├── Aspects.Freezable.csproj
│ ├── Freezable.cs
│ └── readme.md
├── Lazy
│ ├── Aspects.Lazy.csproj
│ ├── LazyAspect.cs
│ ├── LazyAttribute.cs
│ ├── readme-cn.md
│ └── readme.md
├── Logging
│ ├── Aspects.Logging.csproj
│ ├── LogAttribute.cs
│ └── LoggingAspect.cs
├── Notify
│ ├── Aspects.Notify.csproj
│ ├── NotifyAspect.cs
│ └── readme.md
├── Universal
│ ├── Aspects.Universal.csproj
│ ├── Aspects
│ │ ├── BaseUniversalWrapperAspect.cs
│ │ ├── MethodWrapperAspect.cs
│ │ ├── PrivateMethodWrapperAspect.cs
│ │ ├── PublicMethodWrapperAspect.cs
│ │ └── PublicWrapperAspect.cs
│ ├── Attributes
│ │ ├── BaseMethodPointsAspectAttribute.cs
│ │ ├── BaseUniversalWrapperAttribute.cs
│ │ ├── MethodAspectAttribute.cs
│ │ ├── PrivateMethodAspectAttribute.cs
│ │ ├── PublicAspectAttribute.cs
│ │ └── PublicMethodAspectAttribute.cs
│ └── Events
│ │ └── AspectEventArgs.cs
└── readme.md
├── docs
├── advice.md
├── advicearguments.md
├── aspect.md
├── errors
│ ├── AIAM001.md
│ ├── AI_A000.md
│ ├── AI_A001.md
│ ├── AI_A002.md
│ ├── AI_A003.md
│ └── readme.md
├── injection.md
├── mixin.md
├── readme.md
└── terminology.md
├── global.json
├── package.png
├── src
├── AspectInjector.Analyzer.Vsix
│ ├── AspectInjector.Analyzer.Vsix.csproj
│ └── source.extension.vsixmanifest
├── AspectInjector.Analyzer
│ ├── Analyzers
│ │ ├── AdviceAttributeAnalyzer.cs
│ │ ├── ArgumentAttributeAnalyzer.cs
│ │ ├── AspectAttributeAnalyzer.cs
│ │ ├── InjectionAttributeAnalyzer.cs
│ │ └── MixinAttributeAnalyzer.cs
│ ├── AspectInjector.Analyzer.csproj
│ ├── CodeFixes
│ │ ├── AspectCodeFixProvider.cs
│ │ └── MixinCodeFixProvider.cs
│ ├── Extensions.cs
│ ├── Refactorings
│ │ ├── AdviceAttributeCodeRefactoringProvider.cs
│ │ ├── AdviceCodeRefactoringProvider.cs
│ │ ├── AspectAttributeCodeRefactoringProvider.cs
│ │ ├── AspectCodeRefactoringProvider.cs
│ │ ├── PossibleMixinCodeRefactoringProvider.cs
│ │ ├── SampleAdvices.cs
│ │ └── SampleParameters.cs
│ ├── RoslynExtensions.cs
│ ├── SyntaxBasicBlocks.cs
│ └── WellKnown.cs
├── AspectInjector.Broker
│ ├── Advice.cs
│ ├── Argument.cs
│ ├── Aspect.cs
│ ├── AspectInjector.Broker.csproj
│ ├── Injection.cs
│ ├── Kind.cs
│ ├── Mixin.cs
│ ├── PropagateTo.cs
│ ├── Scope.cs
│ ├── SkipInjection.cs
│ ├── Source.cs
│ └── Target.cs
├── AspectInjector.Core.Advice
│ ├── AdviceReader.cs
│ ├── AspectInjector.Core.Advice.csproj
│ ├── Constants.cs
│ ├── Effects
│ │ ├── AdviceArgument.cs
│ │ ├── AdviceEffectBase.cs
│ │ ├── AfterAdviceEffect.cs
│ │ ├── AroundAdviceEffect.cs
│ │ └── BeforeAdviceEffect.cs
│ └── Weavers
│ │ ├── AdviceAroundWeaver.cs
│ │ ├── AdviceInlineWeaver.cs
│ │ ├── AdviceStateMachineWeaver.cs
│ │ └── Processes
│ │ ├── AdviceAfterProcess.cs
│ │ ├── AdviceAroundProcess.cs
│ │ ├── AdviceBeforeProcess.cs
│ │ ├── AdviceWeaveProcessBase.cs
│ │ ├── AfterAsyncWeaveProcess.cs
│ │ ├── AfterIteratorWeaveProcess.cs
│ │ └── AfterStateMachineWeaveProcessBase.cs
├── AspectInjector.Core.Mixin
│ ├── AspectInjector.Core.Mixin.csproj
│ ├── MixinEffect.cs
│ ├── MixinReader.cs
│ ├── MixinWeaveProcess.cs
│ └── MixinWeaver.cs
├── AspectInjector.Core
│ ├── AspectInjector.Core.csproj
│ ├── Constants.cs
│ ├── Contracts
│ │ ├── IAspectReader.cs
│ │ ├── IAspectWeaver.cs
│ │ ├── IEffectReader.cs
│ │ ├── IEffectWeaver.cs
│ │ └── IInjectionReader.cs
│ ├── Extensions
│ │ ├── CustomAttributeExtensions.cs
│ │ └── FluentExtensions.cs
│ ├── Models
│ │ ├── AspectDefinition.cs
│ │ ├── Assets.cs
│ │ ├── Effect.cs
│ │ └── InjectionDefinition.cs
│ ├── Processor.cs
│ ├── Services
│ │ ├── AspectReader.cs
│ │ ├── AspectWeaver.cs
│ │ └── InjectionReader.cs
│ └── WellKnownTypes.cs
├── AspectInjector.Rules
│ ├── AspectInjector.Rules.csproj
│ ├── AspectRules.cs
│ ├── EffectRules.cs
│ ├── GeneralRules.cs
│ └── InjectionRules.cs
├── AspectInjector
│ ├── AspectInjector.csproj
│ ├── AspectInjectorTask.cs
│ ├── Compiler.cs
│ ├── MsBuildLogger.cs
│ ├── build
│ │ └── AspectInjector.targets
│ └── tools
│ │ ├── install.ps1
│ │ └── uninstall.ps1
├── FluentIL.Common
│ ├── FluentIL.Common.csproj
│ └── Rule.cs
└── FluentIL
│ ├── Cuts
│ ├── Arrays.cs
│ ├── Statements.cs
│ ├── TypeMembers.cs
│ └── Values.cs
│ ├── Extensions
│ ├── CecilReferenceExtensions.cs
│ ├── GenericsExtensions.cs
│ ├── MemberDefinitionExtensions.cs
│ ├── PointCutExtensions.cs
│ └── TypeSystemExtension.cs
│ ├── FluentIL.csproj
│ ├── Logging
│ ├── ILogger.cs
│ ├── Logger.cs
│ └── LoggerExtensions.cs
│ ├── MethodEditor.cs
│ ├── PatcherBase.cs
│ ├── PointCut.cs
│ ├── Resolvers
│ ├── CachedAssemblyResolver.cs
│ └── KnownReferencesAssemblyResolver.cs
│ └── StandardTypes.cs
└── tests
├── AspectInjector.Analyzer.Tests
├── Analyzers
│ ├── AdviceAnalyzerTests.cs
│ ├── ArgumentAnalyzerTests.cs
│ ├── AspectAnalyzerTests.cs
│ ├── CorrectDefinitionsTests.cs
│ └── MixinAnalyzerTests.cs
├── AspectAttributeTests.cs
├── AspectInjector.Analyzer.Tests.csproj
├── Helpers
│ ├── CodeFixVerifier.Helper.cs
│ ├── DiagnosticResult.cs
│ └── DiagnosticVerifier.Helper.cs
├── MixinAttributeTests.cs
└── Verifiers
│ ├── CodeFixVerifier.cs
│ └── DiagnosticVerifier.cs
├── AspectInjector.Tests.Generics
├── AspectInjector.Tests.Generics.csproj
├── Class1.cs
└── Class2.cs
├── AspectInjector.Tests.Integrity
├── AspectInjector.Tests.Integrity.csproj
├── PDBTest.cs
└── PETest.cs
├── AspectInjector.Tests.Runtime
├── Advices
│ ├── AccessModifiersTests.cs
│ ├── AfterTests.cs
│ ├── ArgumentsTests.cs
│ ├── AroundTests.cs
│ ├── AsyncTests.cs
│ ├── BeforeTests.cs
│ ├── CompilerGeneratedTargetsTests.cs
│ ├── DebugTests.cs
│ ├── FilterTests.cs
│ ├── GenericTests.cs
│ ├── IteratorTests.cs
│ ├── NestedClassesTests.cs
│ ├── OrderTests.cs
│ └── StaticTests.cs
├── After
│ ├── TargetsGlobalTests.cs
│ └── TargetsIstanceTests.cs
├── Around
│ ├── TargetsGlobalTests.cs
│ └── TargetsIstanceTests.cs
├── AspectInjector.Tests.Runtime.csproj
├── Before
│ ├── TargetsGlobalTests.cs
│ └── TargetsIstanceTests.cs
├── Config.cs
├── Control.cs
├── Events.cs
├── General
│ ├── AspectFactoryTests.cs
│ ├── AspectScopeTests.cs
│ ├── CustomAttributesTests.cs
│ ├── PropagationControlTests.cs
│ ├── ReferencesTests.cs
│ └── UnmanagedTests.cs
├── InheritedInjections
│ └── InheritedInjectionsTests.cs
├── Injections
│ ├── DirectInjectionsTests.cs
│ ├── InjectionOrderTests.cs
│ ├── InterfaceTriggers.cs
│ ├── SkipInjectionAttributeTests.cs
│ └── SkipInjectionsTests.cs
├── Interfaces
│ ├── GeneralTests.cs
│ ├── GenericInterfacesTests.cs
│ └── InheritanceTests.cs
├── Issues
│ ├── 0097.cs
│ ├── 0098.cs
│ ├── 0114.cs
│ ├── 0123.cs
│ ├── 0140.cs
│ └── 0142.cs
├── Mixins
│ └── TestClass.cs
├── TestClass.cs
├── TestRunner.cs
├── Utils
│ └── Checker.cs
└── test.key.snk
├── AspectInjector.Tests.RuntimeAssets
├── AspectInjector.Tests.RuntimeAssets.csproj
├── CrossAssemblyHelpers
│ ├── BaseAttribute.cs
│ ├── BaseGenericClass.cs
│ ├── SomeType.cs
│ ├── TestAspect.cs
│ └── TestBaseClass.cs
├── GlobalAspect.cs
├── InstanceAspect.cs
├── TestAspectBase.cs
├── TestAssets.cs
├── TestLog.cs
└── key.snk
├── AspectInjector.Tests.VBRuntime
├── AspectInjector.Tests.VBRuntime.vbproj
└── Issue_0182.vb
├── Aspects.Tests
├── Aspects.Tests.csproj
├── CacheTests.cs
├── FreezableTests.cs
├── LazyTests.cs
└── NotifyTests.cs
└── Directory.Build.targets
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | [*.csproj]
7 | indent_size = 2
8 |
9 | [*.json]
10 | indent_size = 2
11 |
12 | [*.cs]
13 | indent_size = 4
14 |
15 | [*]
16 | end_of_line = lf
17 | charset = utf-8
18 | trim_trailing_whitespace = true
19 | insert_final_newline = true
20 | indent_style = space
21 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | # no eol conversions!
5 | * -text
6 |
7 | ###############################################################################
8 | # Set default behavior for command prompt diff.
9 | #
10 | # This is need for earlier builds of msysgit that does not have it on by
11 | # default for csharp files.
12 | # Note: This is only used by command line
13 | ###############################################################################
14 | #*.cs diff=csharp
15 |
16 | ###############################################################################
17 | # Set the merge driver for project and solution files
18 | #
19 | # Merging from the command prompt will add diff markers to the files if there
20 | # are conflicts (Merging from VS is not affected by the settings below, in VS
21 | # the diff markers are never inserted). Diff markers may cause the following
22 | # file extensions to fail to load in VS. An alternative would be to treat
23 | # these files as binary and thus will always conflict and require user
24 | # intervention with every merge. To do so, just uncomment the entries below
25 | ###############################################################################
26 | #*.sln merge=binary
27 | #*.csproj merge=binary
28 | #*.vbproj merge=binary
29 | #*.vcxproj merge=binary
30 | #*.vcproj merge=binary
31 | #*.dbproj merge=binary
32 | #*.fsproj merge=binary
33 | #*.lsproj merge=binary
34 | #*.wixproj merge=binary
35 | #*.modelproj merge=binary
36 | #*.sqlproj merge=binary
37 | #*.wwaproj merge=binary
38 |
39 | ###############################################################################
40 | # behavior for image files
41 | #
42 | # image files are treated as binary by default.
43 | ###############################################################################
44 | #*.jpg binary
45 | #*.png binary
46 | #*.gif binary
47 |
48 | ###############################################################################
49 | # diff behavior for common document formats
50 | #
51 | # Convert binary document formats to text before diffing them. This feature
52 | # is only available from the command line. Turn it on by uncommenting the
53 | # entries below.
54 | ###############################################################################
55 | #*.doc diff=astextplain
56 | #*.DOC diff=astextplain
57 | #*.docx diff=astextplain
58 | #*.DOCX diff=astextplain
59 | #*.dot diff=astextplain
60 | #*.DOT diff=astextplain
61 | #*.pdf diff=astextplain
62 | #*.PDF diff=astextplain
63 | #*.rtf diff=astextplain
64 | #*.RTF diff=astextplain
65 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Environment (please complete the following information):**
11 | - OS: [e.g. windows, linux, macos]
12 | - Framework: [e.g. net461, netcoreapp3.1, net6.0]
13 | - Type of application: [e.g. console, webapp, winforms, wpf, xamarin, mobile etc]
14 | - Version of AspectInjector: [e.g. 2.7.1]
15 |
16 | **Describe the bug**
17 | A clear and concise description of what the bug is. An what is expected behavior.
18 |
19 | **To Reproduce**
20 | A steps to reproduce the bug. Or a description when it happens (in compile-time, in runtime).
21 |
22 | **Additional context**
23 | Add any other context about the problem here. Please add stack trace here. Please put it under spoiler if possible.
24 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: 'Feature: '
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the solution you'd like**
11 | A clear and concise description of what you want to happen.
12 |
13 | **Describe alternatives you've considered**
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | **Additional context**
17 | Add any other context or code snippets about the feature request here.
18 |
--------------------------------------------------------------------------------
/.github/workflows/application.yml:
--------------------------------------------------------------------------------
1 | name: Application
2 | on:
3 | push:
4 | branches:
5 | - master
6 | tags:
7 | - '**'
8 | pull_request:
9 |
10 | env:
11 | app_release: false
12 | app_conf: Release
13 | nuget_url: https://api.nuget.org/v3/index.json
14 |
15 | jobs:
16 | build:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: actions/checkout@v2
20 | with:
21 | fetch-depth: 0
22 | - uses: actions/setup-dotnet@v1
23 | with:
24 | dotnet-version: 6.0.x
25 | - uses: actions/setup-dotnet@v1
26 | with:
27 | dotnet-version: 8.0.x
28 | - name: Get version
29 | run: echo "app_version=`git describe --tags`" >> $GITHUB_ENV
30 | - name: Get release status
31 | run: echo "app_release=`(git describe --tags --exact-match>/dev/null 2>&1 && echo true) || echo false`" >> $GITHUB_ENV
32 | - name: Status
33 | run: echo "Release=$app_release, version=$app_version"
34 | - name: Compile
35 | run: dotnet build -c $app_conf -p:Version=$app_version -p:InformationalVersion="$app_version:$GITHUB_SHA"
36 | - name: Test net6
37 | run: dotnet test -c $app_conf --no-build -f net6.0
38 | - name: Test net8
39 | run: dotnet test -c $app_conf --no-build -f net8.0
40 | - name: Pack
41 | run: dotnet pack -c $app_conf -o `pwd`/artifacts -p:Version=$app_version -p:InformationalVersion="$app_version:$GITHUB_SHA" -p:CommitSHA=$GITHUB_SHA
42 | - uses: actions/upload-artifact@v3.2.1
43 | with:
44 | name: artifacts
45 | path: ./artifacts
46 | - name: Publish
47 | if: env.app_release == 'true'
48 | env:
49 | NUGETKEY: ${{ secrets.NUGET_KEY }}
50 | working-directory: artifacts
51 | run: dotnet nuget push ./*.nupkg -s $nuget_url -k $NUGETKEY
52 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Attach",
9 | "type": "coreclr",
10 | "request": "attach",
11 | "processId": "${command:pickProcess}"
12 | }
13 | ]
14 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude": {
3 | "**/bin": true,
4 | "**/obj": true
5 | },
6 | "search.exclude": {
7 | "**/obj": true
8 | }
9 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build_injector",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/src/AspectInjector/AspectInjector.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "build_analyzer",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "build",
22 | "${workspaceFolder}/analyzers/AspectInjector.Analyzer/AspectInjector.Analyzer.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "build_runtime",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "build",
34 | "--no-incremental",
35 | "-c",
36 | "DebugTests",
37 | "-f",
38 | "net6.0",
39 | "${workspaceFolder}/tests/AspectInjector.Tests.Runtime/AspectInjector.Tests.Runtime.csproj",
40 | "/property:GenerateFullPaths=true",
41 | "/p:AspectInjector_Debug=true",
42 | "/p:AspectInjector_Verbose=true",
43 | "/consoleloggerparameters:NoSummary"
44 | ],
45 | "problemMatcher": "$msCompile",
46 | "dependsOn": ["build_injector"]
47 | }
48 | ]
49 | }
50 |
--------------------------------------------------------------------------------
/AspectInjector-Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pamidur/aspect-injector/2a4a154857f4389a96ff4a0421e97ff91e2e060d/AspectInjector-Key.snk
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | Aspect Injector
4 | Aspect Injector Contributors
5 | Aspect Injector Contributors
6 | 12.0
7 | package.png
8 | https://github.com/pamidur/aspect-injector
9 | https://github.com/pamidur/aspect-injector
10 | https://raw.githubusercontent.com/pamidur/aspect-injector/master/package.png
11 | git
12 | $(CommitSHA)
13 | Apache-2.0
14 | 0.0.0
15 | false
16 |
17 |
18 | True
19 | $(MSBuildThisFileDirectory)AspectInjector-Key.snk
20 |
21 |
22 |
23 | all
24 | runtime; build; native; contentfiles; analyzers; buildtransitive
25 |
26 |
27 | all
28 | runtime; build; native; contentfiles; analyzers; buildtransitive
29 |
30 |
31 | all
32 | runtime; build; native; contentfiles; analyzers; buildtransitive
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/aspects/Cache/Aspects.Cache.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | aspect cache memorycache method methodcache
5 |
6 | This package provides cache aspect for your methods. Put [MemoryCache(seconds)] attribure on your methods. And enjoy hassle-free memory cache for your methods.
7 | Or implement your own cache mechanics by inheriting CacheAttribute class.
8 | Powered by AspectInjector.
9 |
10 | https://github.com/pamidur/aspect-injector/tree/master/samples/src/Cache
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/aspects/Cache/CacheAspect.cs:
--------------------------------------------------------------------------------
1 | using AspectInjector.Broker;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Reflection;
6 |
7 | namespace Aspects.Cache
8 | {
9 | [Aspect(Scope.Global)]
10 | public class CacheAspect
11 | {
12 | private static readonly object NullMarker = new { __is_null = "$_is_null" };
13 |
14 | [Advice(Kind.Around)]
15 | public object Handle(
16 | [Argument(Source.Target)] Func