My Project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | List of all members
RoslynCSharp.Project.CSharpProjectFile Class Reference

Represents a .csproj file at a specific file location. Provides access to common project properties such as sources, references and more. More...

Inheritance diagram for RoslynCSharp.Project.CSharpProjectFile:
RoslynCSharp.Project.CSharpProject

Public Member Functions

override IMetadataReferenceProvider[] GetMetadataReferences ()
 Get all project references for this project as IMetadataReferenceProvider that can be passed straight to the compiler. Project references will not be resolved by their full path, only name and file extension.
 
IMetadataReferenceProvider[] GetMetadataProjectReferencesOnly ()
 
CSharpProjectFile[] GetProjectReferences ()
 Get all CSharpProjectFile that are referenced by this project.
 
virtual IMetadataReferenceProvider[] GetMetadataReferences ()
 Get all references for this project as IMetadataReferenceProvider that can be passed straight to the compiler.
 

Static Public Member Functions

static CSharpProjectFile ParseFile (string filePath)
 Parse a .csproj from the specified file path. This method will thrown an exception if anything goes wrong while parsing.
 
static bool TryParseFile (string filePath, out CSharpProjectFile projectFile)
 Try to parse a .csproj from the specified file path. This method will not throw an excepion. Use ParseException to access any exception that were thrown.
 
static CSharpProjectFile ParseUnityFile (UnityCSharpProjectFile unityProjectFile)
 
static bool TryParseUnityFile (UnityCSharpProjectFile unityProjectFile, out CSharpProjectFile projectFile)
 
static CSharpProjectFile ParseUnityFile (string assemblyNameOnly)
 
static bool TryParseUnityFile (string assemblyNameOnly, out CSharpProjectFile projectFile)
 
static string GetUnityProjectFileLocation (UnityCSharpProjectFile unityProjectFile)
 Try to get the file path for the specified Unity build in C# project. The return value will be null if the project file could not be found. This usually means that Unity has not generated the project yet, or your project does not require the specifed C# project to be created (No editor scripts for example).
 
- Static Public Member Functions inherited from RoslynCSharp.Project.CSharpProject
static CSharpProject ParseText (string csharpProjectText)
 Parse a .csproj from the specified string containing the raw xml data. This method will thrown an exception if anything goes wrong while parsing.
 
static bool TryParseText (string csharpProjectText, out CSharpProject project)
 Try to parse a .csproj from the specified string containing the raw xml data. This method will not throw an excepion. Use ParseException to access any exception that were thrown.
 

Protected Member Functions

 CSharpProjectFile (string projectPath)
 

Properties

static string UnityProjectDirectory [get]
 Get the folder path where the current Unity project is located. This will always be the parent folder to 'Assets'.
 
string ProjectPath [get]
 Get the file path where this project file was loaded from.
 
string ProjectDirectory [get]
 Get the folder path where this project file exists.
 
- Properties inherited from RoslynCSharp.Project.CSharpProject
string AssemblyName [get]
 Get the name of the assembly for the C# project.
 
IReadOnlyList< string > Sources [get]
 Get a collection of all C# source file paths included in this project.
 
IReadOnlyList< string > References [get]
 Get a collection of all C# reference assembly paths included in this project. The 'HintPath' node for the reference will be used if it is available.
 
IReadOnlyList< string > ProjectReferences [get]
 Get a collection of all C# project names that are referenced in this project. Project references are used to reference another .csproj.
 
IReadOnlyList< string > Defines [get]
 Get a collection of all compiler define symbols that are used in this project.
 
Exception ParseException [get, set]
 Get an exception that wa thrown while trying to parse the project.
 

Additional Inherited Members

- Protected Attributes inherited from RoslynCSharp.Project.CSharpProject
IMetadataReferenceProvider[] compilerReferences = null
 

Detailed Description

Represents a .csproj file at a specific file location. Provides access to common project properties such as sources, references and more.

Member Function Documentation

◆ GetMetadataReferences()

override IMetadataReferenceProvider[] RoslynCSharp.Project.CSharpProjectFile.GetMetadataReferences ( )
inlinevirtual

Get all project references for this project as IMetadataReferenceProvider that can be passed straight to the compiler. Project references will not be resolved by their full path, only name and file extension.

Returns

Reimplemented from RoslynCSharp.Project.CSharpProject.

◆ GetProjectReferences()

CSharpProjectFile[] RoslynCSharp.Project.CSharpProjectFile.GetProjectReferences ( )
inline

Get all CSharpProjectFile that are referenced by this project.

Returns

◆ GetUnityProjectFileLocation()

static string RoslynCSharp.Project.CSharpProjectFile.GetUnityProjectFileLocation ( UnityCSharpProjectFile  unityProjectFile)
inlinestatic

Try to get the file path for the specified Unity build in C# project. The return value will be null if the project file could not be found. This usually means that Unity has not generated the project yet, or your project does not require the specifed C# project to be created (No editor scripts for example).

Parameters
unityProjectFileThe UnityCSharpProjectFile to try and find the path for
Returns
A file path if the project was found or null if not

◆ ParseFile()

static CSharpProjectFile RoslynCSharp.Project.CSharpProjectFile.ParseFile ( string  filePath)
inlinestatic

Parse a .csproj from the specified file path. This method will thrown an exception if anything goes wrong while parsing.

Parameters
filePathThe file path of the .csproj file to parse
Returns
A CSharpProject representing the loaded project file

◆ TryParseFile()

static bool RoslynCSharp.Project.CSharpProjectFile.TryParseFile ( string  filePath,
out CSharpProjectFile  projectFile 
)
inlinestatic

Try to parse a .csproj from the specified file path. This method will not throw an excepion. Use ParseException to access any exception that were thrown.

Parameters
filePathThe file path of the .csproj file to parse
projectA CSharpProject representing the loaded project file
Returns
True if parsing was successful or false if not

The documentation for this class was generated from the following file: