dennisdoomen / dennisdoomen/pathy
[API Proposal]: NameWithoutExtension
- Dominant language
- C#
- Stars
- 27
- Forks
- 5
- Avg merge
- 21h 29m
- Merged PRs (30d)
- 10
Description
### Background and motivation
`Name` gives the file name including the extension and `Extension` gives the extension including the dot, but there is no property for the file name without the extension. This is a very common need (deriving an assembly name from a project file, naming an output artifact after its input, building a report name). Today callers have to write `Path.GetFileNameWithoutExtension(path.ToString())`, which drops out of the fluent style the library is built around.
### API Proposal
```C#
namespace Pathy
{
public readonly struct ChainablePath
{
public string NameWithoutExtension { get; }
}
}
```
### API Usage
```C#
var project = ChainablePath.From("c:/work/repo/src/Pathy/Pathy.csproj");
project.Name; // "Pathy.csproj"
project.Extension; // ".csproj"
project.NameWithoutExtension; // "Pathy"
var package = artifactsDirectory / (project.NameWithoutExtension + ".nupkg");
```
### Alternative Designs
A `WithoutExtension()` method that returns a `ChainablePath` covers a related but different need: it keeps the directory. Both are useful, and this proposal is only about the string property. See the separate proposal for `WithExtension`, `WithName` and `WithoutExtension`.
### Risks
Behaviour on names such as `.gitignore` and `archive.tar.gz` needs to be documented explicitly. Matching `Path.GetFileNameWithoutExtension` is the least surprising choice.
Contributor guide
Research direction
Start at the ChainablePath entry point and inspect how the existing Name and Extension properties are implemented and tested. Use Path.GetFileNameWithoutExtension as the stated behavior, including the proposed handling for .gitignore and archive.tar.gz. Done means the string property supports the shown API usage and its edge-case behavior is documented and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100