Skip to content

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

Notifications You must be signed in to change notification settings

DmitryGaravsky/MSIL-Boxing-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages