Code Monkey home page Code Monkey logo

structex's Introduction

StructEx

Have you ever needed to programmatically inspect the contents of a .net solution and look on its projects, its files and the references of each project for other projects and external assemblies?

StructEx is a small .net library that exposes a DSL to inspect a .net solution and its contents.

Why StructEx?

StructEx can be used or extended on scenarios that you need to deal with .net source code. Some of these scenareios are: (very) basic foundation for a static code analysis tool, inspection of project contents to automatically configure build tasks, configure Continous Integration environment dynamically by selecting which files to include or compile, etc.

Usage

The usage of StructEx is straightforward. Just create a solution object by passing it the solution file path and inspect its contents:

using StructEx;

//...

var solution = new Solution(@"C:\work\SomeSolution.sln")

// inspect the solutions projects
foreach(var project in solution.Projects)
{
  var projectName = project.Name;
  var projectPath = project.FileName;
  var assemblyName = project.AssemblyName;
  
  // inspect referenced assemblies
  foreach(var assembly in project.ReferencedAssemblies)
  {
    var assemblyPath = assembly;
  }
  
  // inspect another projects from the solution and referenced by this project
  foreach(var referencedProject in project.ReferencedProjects)
  {
    // ... do some stuff with referenced projects
  }
  
  // inspect the files on the current project
  foreach(var file in project.Files)
  {
    var fileName = file.Name;
    var fileContent = file.Content;
    
    // ...
  }
  
}

// ...

Limitations

The current version only works with C# projects (including class libraries, console, windows forms, asp.net mvc, and other project types)

Inspiration and References

This project is largely inspired on the work and samples provided by Daniel Grunwald. Please, check the original article for more information.

structex's People

Contributors

rpepato avatar

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.