Git Product home page Git Product logo

solutionparser's Introduction

SolutionParser

SolutionParser parses a Visual Studio solution file into an object structure.

Get it on NuGet

Install-Package Onion.SolutionParser.Parser

Usage

SolutionParser is easy to use:

var solution = SolutionParser.Parse("/path/to/solution.sln");

//IEnumerable<GlobalSection>
var global = solution.Global;

//IEnumerable<Project>
var projects = solution.Projects;

Types

The included types mirror the various sections contained in a solution file.

###GlobalSection###

The GlobalSection type is made up of a name, a GlobalSectionType (either preSolution or postSolution), and a dictionary of environment entries.

public class GlobalSection : ISolutionItem
{
    public string Name { get; set; }
    public GlobalSectionType Type { get; set; }
    public IDictionary<string, string> Entries { get; set; }
}

public enum GlobalSectionType
{
    PostSolution,
    PreSolution
}

###Project###

The Project type is made up of a type guid, a name, a path to the project file, and a unique guid. A project may also contain a ProjectSection type that is composed of a name, a ProjectSectionType (either preProject or postProject) and a dictionary of environment entries.

public class Project : ISolutionItem
{
    public Guid TypeGuid { get; private set; }
    public string Name { get; set; }
    public string Path { get; set; }
    public Guid Guid { get; private set; }
    public ProjectSection ProjectSection { get; set; }
}

public class ProjectSection
{
    public string Name { get; set; }
    public ProjectSectionType Type { get; set; }
    public IDictionary<string, string> Entries { get; set; }
}

public enum ProjectSectionType
{
    PostProject,
    PreProject
}

###Solution###

The Solution type is composed of an IEnumerable<GlobalSection> and an IEnumerable<Project>.

public class Solution : ISolution
{
    public IEnumerable<GlobalSection> Global { get; set; }
    public IEnumerable<Project> Projects { get; set; } 
}

Parsers

SolutionParser contains three parsers for more or less detailed access to a solution file.

###SolutionParser###

The SolutionParser class is the most direct parser, and returns a fully composed Solution object.

var solution = SolutionParser.Parse("/path/to/solution.sln");

###GlobalSectionParser###

A GlobalSectionParser accepts the text contents of a solution file. The parse method returns an IEnumerable<GlobalSection>.

var parser = new GlobalSectionParser(solutionContents);

//IEnumerable<GlobalSection>
var sections = parser.Parse();

###ProjectParser###

A ProjectParser accepts the contents of a solution file. The parse method returns an IEnumerable<Project>.

var parser = new ProjectParser(solutionContents);

//IEnumerable<Project>
var projects = parser.Parse();

Running unit tests

SolutionParser assumes package restore is enabled. To run the tests just clone the project, hit build, and run the unit tests with your favorite NUnit runner.

solutionparser's People

Contributors

brianium avatar

Watchers

James Cloos avatar Jeff Marston avatar  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.