Giter Site home page Giter Site logo

msil-boxing-detector's Introduction

MSIL Boxing Detector

MSIL-level boxing detector tool for .Net (powered by ILReader)

Boxing patterns detected:

  1. Typical errors in string operations:
int a = 42;
string answer = string.Format("{0}", a); // boxing here
int a = 2; int b = 3;
string question = string.Concat(a," + ", b); // boxing here
  1. Boxing with the Enum.HasValue method call:
[Flags]
enum State { One, Two }
//...
var state = State.One | State.Two;
bool isOne = state.HasFlag(State.One); // boxing here

Usage scenarios:

  1. To process all the assemblies within the MSIL Boxing Detector current folder add all the specific assemblies into this folder and run the BoxingDetector.exe without arguments.

  2. To process the specific assemblies use the following snippet:

BoxingDetector.exe AssemblyXXX.dll AssemblyYYY.dll AssemblyZZZ.dll

Output:

ILREADER.ANALYZER
---------------------

ILReader.Analyzer.Tests.Boxing_Patterns_Tests.Format
->Stub2:
    IL_0007: box System.Int32
    IL_0012: call System.String Format(System.String, System.Object, System.Object)

ILReader.Analyzer.Tests.Boxing_Patterns_Tests.Concat
->Stub2:
    IL_0002: box System.Int32
    IL_000D: call System.String Concat(System.Object, System.Object)

ILReader.Analyzer.Tests.Boxing_Patterns_Tests.EnumHasFlag
->Stub2:
    IL_0002: box ILReader.Analyzer.Tests.Boxing_Patterns_Tests+EnumHasFlag+State
    IL_000D: call Boolean HasFlag(System.Enum)
->Stub4:
    IL_0003: constrained. ILReader.Analyzer.Tests.Boxing_Patterns_Tests+EnumHasFlag+State
    IL_0009: callvirt System.String ToString()

msil-boxing-detector's People

Contributors

dmitrygaravsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

zha0

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.