Git Product home page Git Product logo

assemblyinfo's Introduction

This small library uses cecil to inspect MSIL code found in .NET assemblies instead of Assembly.Load which ensures that you do not have to load it's dependencies beforehand. This is particularly useful if you just want to know what .NET target framework an assembly is targeting without running the risk of catching an exception from Assembly.Load because of a missing dependency.

Powershell

A powershell version is available here. Please note that there's a limitation where you cannot differentiate between NET45 and NET451. This is because the Microsoft PE and COFF Specification does not reveal this information.

Install via nuget

Install-Package assemblyinfo

Supported frameworks

  • NET 4.5.1
  • NET 4.5
  • NET 4.0
  • NET 3.5
  • NET 2.0

Examples

Additional examples are available here

// Read from disk 
AssemblyInfo.GetTargetFramework("myassembly.dll").IsEqualTo(TargetFramework.Net_2_0);

// Read from byte array
AssemblyInfo.GetTargetFramework(
	File.ReadAllBytes("myassembly.dll")
).IsEqualTo(TargetFramework.Net_2_0);

// Read from stream
AssemblyInfo.GetTargetFramework(
	new MemoryStream(File.ReadAllBytes("myassembly.dll"))
).IsEqualTo(TargetFramework.Net_2_0);

// Read from current assembly
AssemblyInfo.GetTargetFramework(
	Assembly.GetExecutingAssembly()
).IsEqualTo(TargetFramework.Net_2_0);

// Determine minimum supported target framework
AssemblyInfo.GetTargetFramework(new List<string> { 
	"assembly1.dll",
	"assembly2.dll"
}).IsGreaterThan(TargetFramework.Net_2_0);

// Determine minimum supported target framework
AssemblyInfo.GetTargetFramework(new List<string> { 
	"assembly1.dll",
	"assembly2.dll"
}).IsLessThanOrEqualTo(TargetFramework.Net_4_5_1);

// Determine minimum supported target framework
AssemblyInfo.GetTargetFramework(new List<byte[]> { 
	File.ReadAllBytes("assembly1.dll"),
	File.ReadAllBytes("assembly2.dll")
}).IsGreaterThanOrEqualTo(TargetFramework.Net_4_5_1);

License

MIT

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.