Giter Club home page Giter Club logo

feathersharp's Introduction

FeatherSharp

Feather# - An AOP utility for .NET, based on Mono.Cecil.

Features

  • INotifyPropertyChanged Injection w/ Property Dependencies
  • Logger TypeName and MethodName Injection
  • Merge Assemblies
  • Compatible with .NET 4.5 and Mono 4

Usage

[mono] FeatherSharp.exe <Feathers> <FileName>
  Available Feathers:
  -npc : Inject NotifyPropertyChanged
  -merge : Merge dependencies into <FileName>
  -log : Inject augmented log method calls
  Options:
  --sn=<StrongNameFile> : Re-sign with strong name

INotifyPropertyChanged Injection

Feather# turns byte code doing this...

class Class1 // ...
{
    public int MyPropertyA { get; set; }
    public string MyPropertyB { get; set; }

    public string Combined
    {
        get { return MyPropertyA.ToString() + MyPropertyB; }
    }
    // ...
}

...into byte code doing this

class Class1 // ...
{
    private int a;
    private string b;

    public int MyPropertyA
    {
        get { return this.a; }
        set
        {
            if (value != this.a)
            {
                this.a = value;

                OnPropertyChanged("MyPropertyA");
                OnPropertyChanged("Combined");
            }
        }
    }
    
    public string MyPropertyB
    {
        get { return this.b; }
        set
        {
            if (value != this.b)
            {
                this.b = value;

                OnPropertyChanged("MyPropertyB");
                OnPropertyChanged("Combined");
            }
        }
    }

    public string Combined
    {
        get { return MyPropertyA.ToString() + MyPropertyB; }
    }
    // ...
}

Implement the INotifyPropertyChanged interface without code bloat by calling [mono] FeatherSharp.exe -npc MyAssembly.dll

Logger TypeName and MethodName Injection

Feather# turns byte code doing this...

class Class1 //...
{
    public void LogMethod()
    {
        Log.Debug("This seems to work");
    }
    // ...
}

...into byte code doing this

class Class1 // ...
{
    public void LogMethod()
    {
        Log.Debug("This seems to work", "Test.FeatherSharp.LogInjection.Class1", "LogMethod");
    }
    // ...
}

Easily consume the log messages by subscribing to the Log.MessageRaised event, then pass it on to the logging backend of your choice.

Feather# is on NuGet

Visit the Feather# NuGet site:

https://www.nuget.org/packages/FeatherSharp/

Add the Feather# package to your project using the Package Manager Console:

Install-Package FeatherSharp

To make it work smoothly, create a batch file named FeatherSharp.cmd in your solution folder with the following contents:

@%1\packages\FeatherSharp.0.3.1.0\tools\FeatherSharp.exe %2 %3 %4 %5 %6 %7 %8 %9

or

@%1\packages\FeatherSharp.0.3.1.0\tools\FeatherSharp.exe --sn=<YourStrongNameFile> %2 %3 %4 %5 %6 %7 %8 %9

if your assembly is signed with a strong name.

Then create the following post build event for every project that uses Feather# (using the -log feather in this example):

$(SolutionDir)FeatherSharp.cmd $(SolutionDir) -log $(TargetPath)

feathersharp's People

Contributors

smackem avatar

Watchers

 avatar  avatar  avatar  avatar

feathersharp's Issues

Add log level "Trace"

In FeatherSharp.ComponentModel.Log, add log level "Trace". Make the Debug and Trace methods conditional.

Merge Feather does not support Portable Libraries

Merging portable libraries should not be supported. Although they can be merged, they fail to load from resource because of some special System.Core reference.
FeatherSharp should report this and skip the library instead of silently merging it.

A side effect of this issue is that FeatherSharp cannot merge itself into one executable because FeatherSharp.ComponentModel.dll is a portable library.

Improve Console Output

Console output leaves much to be desired. Improve the following:

  • Messages should state the feather that produced them
  • Replace enumeration.ToString()s with prettier info

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.