pub struct Project { /* private fields */ }Expand description
Represents a .NET project.
Implementations§
Source§impl Project
impl Project
Sourcepub fn new<P>(path: P) -> Result<Self, ParseError>
pub fn new<P>(path: P) -> Result<Self, ParseError>
Creates a new Project instance by parsing a .NET project file.
This function opens the file specified by the path, reads its contents, and parses it
into a Project instance using the parser::parse function.
§Arguments
path- A path to the .NET project file that implements theAsRef<Path>trait.
§Returns
A Result<Self, ParseError> where Ok(Self) contains the parsed Project instance, and
Err(ParseError) contains the error if the file could not be read or parsed.
§Errors
This function will return an error if:
- The file could not be opened.
- The file could not be parsed as a .NET project file.
§Examples
use dotnet_lens::{Project, parser::ParseError};
use std::path::Path;
match Project::new(Path::new("path/to/MyProject.csproj")) {
Ok(project) => {
println!("Project parsed successfully: {:?}", project);
},
Err(e) => {
eprintln!("Failed to parse project: {:?}", e);
}
}Sourcepub fn get_project_name<P>(path: P) -> Option<String>
pub fn get_project_name<P>(path: P) -> Option<String>
Sourcepub fn language(&self) -> ProjectLanguage
pub fn language(&self) -> ProjectLanguage
Returns the language of the project.
Sourcepub fn target_framework(&self) -> Option<&String>
pub fn target_framework(&self) -> Option<&String>
Returns the target framework of the project, if any.
Sourcepub fn project_references(&self) -> &Vec<ProjectReference>
pub fn project_references(&self) -> &Vec<ProjectReference>
Returns a reference to the list of project references.
Sourcepub fn add_project_reference(&mut self, value: ProjectReference)
pub fn add_project_reference(&mut self, value: ProjectReference)
Adds a new project reference to the list of project references.
Sourcepub fn package_references(&self) -> &Vec<PackageReference>
pub fn package_references(&self) -> &Vec<PackageReference>
Returns a reference to the list of package references.
Sourcepub fn add_package_reference(&mut self, value: PackageReference)
pub fn add_package_reference(&mut self, value: PackageReference)
Adds a new package reference to the list of package references.