C# Class RunTimeCompiler.AllCsprojReader

This class should be able to process all (almost) kinds of .csproj files and retrieve the data needed for UI and compilation. It should successfully process .csproj files coming from Visual Studio 2005+. It processes ok files from Visual Studio 2010 (this is the most recent version), but the structure of the .csproj may change in future versions of Visual Studio, and therefore the class may not be able to process that .csproj files. It is also unknown if .csproj files created with Visual Studio 2001 or 2003 can be processed.
Exibir arquivo Open project: Virtual-Universe/Virtual-Universe

Public Methods

Method Description
ReadProject ( string filename ) : BasicProject

This method is called to read the specified .csproj file and retrieve all the data needed for UI or compilation. It loads the project file as an XML and then get the value of the relevant nodes. Note! It does not get every information available in .csproj. It only retrieves the information considered relevant for UI and compilation. Attention! There may be information in .csproj that are important for the compilation and I may be unaware of these or I may deliberately choose to ignore them. For example, I decided not to support projects that contain references to other projects.

Private Methods

Method Description
GetConfigs ( XmlDocument doc, XmlNamespaceManager mgr ) : List

Gets the config files. Config files are found in: < project > < ItemGroup > < None > Then: get name from the attribute "Include", get CopyToOutputDirectory from child element "CopyToOutputDirectory"

GetContent ( XmlDocument doc, XmlNamespaceManager mgr ) : List

Gets the content files. Content files are found in: < project > < ItemGroup > < Content > Then: get name from the attribute "Include", get CopyToOutputDirectory from child element "CopyToOutputDirectory"

GetCrtConfigurationNode ( XmlDocument doc, XmlNamespaceManager mgr, string configuration, string platform ) : XmlNode

It is used to get the node that contains the configuration-specific settings for the Configuration and Platform specified. Currently it looks for the section with the "Condition" attribute like: '$(Configuration)|$(Platform)' == '[Configuration]|[Platform]' The node should look like: < PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " > ... < PropertyGroup />

GetCrtConfigurationValue ( XmlNode crtConfigurationNode, XmlNamespaceManager mgr, string property ) : string

It is used to retrieve the value of a property from the configuration-specific section.

GetPropertyValue ( XmlDocument doc, XmlNamespaceManager mgr, string property ) : string

It is used to retrieve the value of a property from the generic properties section (as opposite to configuration-specific section).

GetReferences ( XmlDocument doc, XmlNamespaceManager mgr ) : List

Gets the list of referenced assemblies. Referenced assemblies are found in: < project > < ItemGroup > < Reference >

GetResources ( XmlDocument doc, XmlNamespaceManager mgr ) : List

Gets the resource files. Resource files are found in: < project > < ItemGroup > < EmbeddedResource > Then: get name from the attribute "Include", get DependentUpon from child element "DependentUpon", get CopyToOutputDirectory from child element "CopyToOutputDirectory"

GetSettings ( XmlDocument doc, XmlNamespaceManager mgr ) : ProjectSettings

It is used to read the project settings. It reads general settings (framework version, project type winexe/dll/console...,assembly name etc) and the settings for the active configuration (debug/release...) (output folder, warning level etc). Notes! 1. Form the general section it gets the Configuration and Platform (aka Debug/Release, AnyCPU) and the searches for the section having the condition: '$(Configuration)|$(Platform)' == '[Configuration]|[Platform]' That section is used to get configuration-specific settings. 2. Some important settings like .Net framework version and file alignment were added after .Net 2.0. So when these nodes are missing the values "v2.0" and "512" are used.

GetSources ( XmlDocument doc, XmlNamespaceManager mgr ) : List

Gets the source files. Source files are found in: < project > < ItemGroup > < Compile > Then: get name from the attribute "Include", get DependentUpon from child element "DependentUpon", get CopyToOutputDirectory from child element "CopyToOutputDirectory"

Method Details

ReadProject() public method

This method is called to read the specified .csproj file and retrieve all the data needed for UI or compilation. It loads the project file as an XML and then get the value of the relevant nodes. Note! It does not get every information available in .csproj. It only retrieves the information considered relevant for UI and compilation. Attention! There may be information in .csproj that are important for the compilation and I may be unaware of these or I may deliberately choose to ignore them. For example, I decided not to support projects that contain references to other projects.
public ReadProject ( string filename ) : BasicProject
filename string The name (and path) of the .csproj file.
return BasicProject