https://github.com/milleniumbug/vancestubbs
https://github.com/milleniumbug/vancestubbs
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/milleniumbug/vancestubbs
- Owner: milleniumbug
- License: mit
- Created: 2017-12-17T06:18:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-22T21:15:18.000Z (almost 8 years ago)
- Last Synced: 2025-01-10T20:42:09.484Z (over 1 year ago)
- Language: C#
- Size: 213 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
VanceStubbs [](https://ci.appveyor.com/project/milleniumbug/vancestubbs)
======
Reflection.Emit-based library that provides stubs, proxies, AOP and magic.
[NuGet](https://www.nuget.org/packages/VanceStubbs/1.0.0)
API
-----
Given a `var factory = new VanceStubbs.Factory();`:
- `factory.OfStubs.WhiteHole()` - creates an instance of `T` that implements every abstract method and property by throwing a `NotImplementedException`
- `factory.OfStubs.BlackHole()` - creates an instance of `T` that implements every abstract method and property by returning a `default` and otherwise doing nothing.
- `factory.OfProxies.NotifyChangedProxy(args)` - creates an instance of `T` (with the passed constructor arguments) that implements every abstract property as a notifying property with a backing field.
- `factory.OfProxies.For()` - creates an AOP proxy type builder.
- `new TypeDictionary(enumerableOfTypeToValueMappings)` - creates a `IReadOnlyDictionary` that uses overload resolution rules to match a most specific type. (warning: passing a `typeof(AbstractNonDefaultConstructibleClass)` as a key doesn't currently work. This will change in the future)
Memory usage
------
All instances can be created either through a static factory or non-static factories. Each dynamically created type is never freed if you use a static factory, therefore it's highly recommended to use a non-static factory if you want to control over memory usage.
*Implementation detail*: A `VanceStubbs.Factory` composes over an `AssemblyBuilder` created with `RunAndCollect`. These assemblies will be collected if there's no reference to a factory or dynamically created object instances.
Name...?
--------
[Vance Stubbs from WH40K: Dawn of War: Soulstorm](https://1d4chan.org/wiki/Vance_Motherfucking_Stubbs)