Project

Struct Project 

Source
pub struct Project { /* private fields */ }
Expand description

Represents a .NET project.

Implementations§

Source§

impl Project

Source

pub fn new<P>(path: P) -> Result<Self, ParseError>
where P: AsRef<Path>,

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 the AsRef<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);
    }
}
Source

pub fn get_project_name<P>(path: P) -> Option<String>
where P: AsRef<Path>,

Returns the name of the project based on the file name of the provided path.

§Arguments
  • path - A reference to a path that implements the AsRef<Path> trait.
§Returns

An Option<String> containing the project name if it could be extracted, otherwise None.

Source

pub fn name(&self) -> &String

Returns the name of the project.

Source

pub fn language(&self) -> ProjectLanguage

Returns the language of the project.

Source

pub fn path(&self) -> &PathBuf

Returns the path of the project.

Source

pub fn target_framework(&self) -> Option<&String>

Returns the target framework of the project, if any.

Source

pub fn project_references(&self) -> &Vec<ProjectReference>

Returns a reference to the list of project references.

Source

pub fn add_project_reference(&mut self, value: ProjectReference)

Adds a new project reference to the list of project references.

Source

pub fn package_references(&self) -> &Vec<PackageReference>

Returns a reference to the list of package references.

Source

pub fn add_package_reference(&mut self, value: PackageReference)

Adds a new package reference to the list of package references.

Trait Implementations§

Source§

impl Clone for Project

Source§

fn clone(&self) -> Project

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Project

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Project

Source§

fn eq(&self, other: &Project) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Project

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.