Kimono 0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Kimono --version 0.0.3
                    
NuGet\Install-Package Kimono -Version 0.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kimono" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kimono" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Kimono" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kimono --version 0.0.3
                    
#r "nuget: Kimono, 0.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kimono@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kimono&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Kimono&version=0.0.3
                    
Install as a Cake Tool

Kimono

DOTNET Build

_ _
| | ()
| | ___ _ __ ___ ___ _ __ ___
| |/ / | '
` _ \ / _ | '_ \ / _ \ | <| | | | | | | () | | | | () | ||__|| || ||_/|| ||_/

Kimono is a dynamic proxy framework that allows intercepting methods and properties. Currently in development! Working on generating MSIL for out and ref parameters definitions. See below for examples.

	public class Program
	{
		public void Main(string[] args)
		{
			var examples = new KimonoExamples();
			examples.NoTargetWithHandlersInterceptorExample();
			examples.TargetWithHandlersInterceptorExample();
			examples.NoTargetWithCallbackInterceptorExample();
			examples.TargetWithHandlersInterceptorExample();
			examples.TargetWithInvocationChainInterceptorExample();
			examples.NoTargetWithInvocationChainInterceptorExample();
		}
	}
    public class KimonoExamples
    {
        public void NoTargetWithCallbackInterceptorExample()
        {
            var interceptorWithCallback = Interceptor.WithCallback<IFoo>(context => {
				if (context.MemberName == "Baz") {
					context.ReturnValue = new Baz {
						A = context.Parameters.Get<string>("a"),
						B = context.Parameters.Get<string>("b")
					};
				}
            });

            interceptorWithCallback.Bar();
		}
		public void TargetWithCallbackInterceptorExample()
		{
			var interceptorWithCallback = Interceptor.ForTarget<IFoo, Foo>(new Foo(), context => {
				if (context.MemberName == "Baz") {
					context.ReturnValue = new Baz {
						A = context.Parameters.Get<string>("a"),
						B = context.Parameters.Get<string>("b")
					};
				}
			});

			interceptorWithCallback.Bar();
		}
		public void NoTargetWithHandlersInterceptorExample()
		{
			var interceptorWithCallback = Interceptor.WithHandlers<IFoo>(new BazReturnInvocationHandler());

			interceptorWithCallback.Bar();
		}
		public void TargetWithHandlersInterceptorExample()
		{
			var interceptorWithCallback = Interceptor.ForTargetWithHandlers<IFoo, Foo>(new Foo(), new BazReturnInvocationHandler());

			interceptorWithCallback.Bar();
		}
		public void NoTargetWithInvocationChainInterceptorExample()
		{
			var interceptorWithCallback = Interceptor.ForTargetWithInovcationChain<IFoo, Foo>(new Foo(), builder => {
				builder.Add((next, context) => {
					if (context.MemberName == "Baz") {
						context.ReturnValue = new Baz {
							A = context.Parameters.Get<string>("a"),
							B = context.Parameters.Get<string>("b")
						};
					}

					next(context);
				});
			});

			interceptorWithCallback.Bar();
		}
		public void TargetWithInvocationChainInterceptorExample()
		{
			var interceptorWithCallback = Interceptor.WithInovcationChain<IFoo>(builder => {
				builder.Add((next, context) => {
					if (context.MemberName == "Baz") {
						context.ReturnValue = new Baz {
							A = context.Parameters.Get<string>("a"),
							B = context.Parameters.Get<string>("b")
						};
					}

					next(context);
				});
			});

			interceptorWithCallback.Bar();
		}
		private class BazReturnInvocationHandler : IInvocationHandler
		{
			public void Handle(IInvocationContext context)
			{
				if (context.MemberName == "Baz") {
					context.ReturnValue = new Baz {
						A = context.Parameters.Get<string>("a"),
						B = context.Parameters.Get<string>("b")
					};
				}
			}
		}
	}
    public interface IFoo
    {
        void Bar();

        Baz Baz(string  a, string b);
    }
	public class Foo : IFoo
	{
		public void Bar()
		{
		}

		public Baz Baz(string a, string b)
		{
			return new Baz { A = a, B = b };
		}
	}
	public class Baz
	{
        public string A { get; set; }
        public string B { get; set; }
	}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Kimono:

Package Downloads
Overmock

Overmock is a mocking framework that allows for very robust mocking configuration and validation.

Kimono.Extensions.DependencyInjection

Kimono.Extensions.DependencyInjection contains extension methods for adding of interceptors to DI.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 250 8/15/2024
0.1.0 233 8/9/2024
0.0.12 372 3/27/2024
0.0.11-RC01 292 10/16/2023
0.0.10 230 10/11/2023
0.0.9 243 9/17/2023
0.0.9-RD01 228 8/28/2023
0.0.9-RC03 184 9/15/2023
0.0.9-RC02 217 8/30/2023
0.0.8 270 8/27/2023
0.0.7 254 8/27/2023
0.0.7-RC05 167 8/25/2023
0.0.7-RC04 190 8/24/2023
0.0.7-RC03 203 8/22/2023
0.0.7-RC02 177 8/19/2023
0.0.7-RC01 183 8/16/2023
0.0.6 237 8/15/2023
0.0.6-RC01 194 8/14/2023
0.0.5 235 8/14/2023
0.0.4 245 8/13/2023
0.0.3 233 8/13/2023
0.0.1 232 8/13/2023
0.0.1-RC03 199 8/13/2023
0.0.1-RC02 199 8/13/2023
0.0.1-RC01 215 8/11/2023

This is a first release and is meant for internal usages until further notice.