Skip to content

Commit ebbd08c

Browse files
samtrionCopilot
andauthored
feat!: ,NET 10 Support (#312)
* feat!: ,NET 10 Support * docs: Clarify dependency claim in README Features section (#313) * Initial plan * docs: clarify dependency in README Features section Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 6638fa7 commit ebbd08c

3 files changed

Lines changed: 109 additions & 9 deletions

File tree

README.md

Lines changed: 106 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,110 @@
11
# NetEvolve.Extensions.Strings
2-
This library provides a set of extension methods for `System.String`. It is a part of the [Daily DevOps & .NET - NetEvolve](https://daily-devops.net/) project, which aims to provide a set of useful libraries for .NET developers.
32

4-
## Methods
3+
[![NuGet](https://img.shields.io/nuget/v/NetEvolve.Extensions.Strings.svg)](https://www.nuget.org/packages/NetEvolve.Extensions.Strings/)
4+
[![NuGet Downloads](https://img.shields.io/nuget/dt/NetEvolve.Extensions.Strings.svg)](https://www.nuget.org/packages/NetEvolve.Extensions.Strings/)
5+
[![License](https://img.shields.io/github/license/dailydevops/extensions.strings.svg)](LICENSE)
56

6-
### `stringVariable.EnsureEndsWith(string, comparison)`
7-
Simple helper method to determine if the `value` ends with the `suffix`. If not, it will be appended.
7+
A modern .NET library providing essential extension methods for `System.String` to simplify common string operations. Part of the [Daily DevOps & .NET - NetEvolve](https://daily-devops.net/) project.
88

9-
### `stringVariable.EnsureStartsWith(string, comparison)`
10-
Simple helper method to determine if the `value` ends with the `prefix`. If not, this is prefixed.
9+
## Features
10+
11+
- 🎯 **Simple & Intuitive API** - Extension methods that feel natural to use
12+
- 🚀 **Multi-Framework Support** - Compatible with .NET Standard 2.0, .NET 8.0, .NET 9.0, and .NET 10.0
13+
- 📦 **Minimal Dependencies** - Single, lightweight external dependency (`NetEvolve.Arguments`)
14+
- 🔒 **Null-Safe** - Proper argument validation with meaningful exceptions
15+
16+
## Installation
17+
18+
Install the package via NuGet Package Manager:
19+
20+
```bash
21+
dotnet add package NetEvolve.Extensions.Strings
22+
```
23+
24+
Or via the Package Manager Console:
25+
26+
```powershell
27+
Install-Package NetEvolve.Extensions.Strings
28+
```
29+
30+
## Usage
31+
32+
### EnsureEndsWith
33+
34+
Ensures that a string ends with the specified suffix. If the string already ends with the suffix, the original string is returned; otherwise, the suffix is appended.
35+
36+
```csharp
37+
using System;
38+
39+
string path = "C:\\Users\\Documents";
40+
string result = path.EnsureEndsWith("\\");
41+
// Result: "C:\\Users\\Documents\\"
42+
43+
string url = "https://example.com/";
44+
string result2 = url.EnsureEndsWith("/");
45+
// Result: "https://example.com/" (unchanged, already ends with "/")
46+
47+
// Case-insensitive comparison
48+
string text = "Hello";
49+
string result3 = text.EnsureEndsWith("WORLD", StringComparison.OrdinalIgnoreCase);
50+
// Result: "HelloWORLD"
51+
```
52+
53+
**Parameters:**
54+
- `value` (string): The string to check
55+
- `suffix` (string): The suffix to ensure
56+
- `comparison` (StringComparison): Optional comparison mode (default: `CurrentCulture`)
57+
58+
**Exceptions:**
59+
- `ArgumentNullException`: Thrown if `value` or `suffix` is null
60+
61+
### EnsureStartsWith
62+
63+
Ensures that a string starts with the specified prefix. If the string already starts with the prefix, the original string is returned; otherwise, the prefix is prepended.
64+
65+
```csharp
66+
using System;
67+
68+
string path = "Documents\\file.txt";
69+
string result = path.EnsureStartsWith("C:\\");
70+
// Result: "C:\\Documents\\file.txt"
71+
72+
string url = "example.com";
73+
string result2 = url.EnsureStartsWith("https://");
74+
// Result: "https://example.com"
75+
76+
// Case-insensitive comparison
77+
string text = "world";
78+
string result3 = text.EnsureStartsWith("HELLO", StringComparison.OrdinalIgnoreCase);
79+
// Result: "HELLOworld"
80+
```
81+
82+
**Parameters:**
83+
- `value` (string): The string to check
84+
- `prefix` (string): The prefix to ensure
85+
- `comparison` (StringComparison): Optional comparison mode (default: `CurrentCulture`)
86+
87+
**Exceptions:**
88+
- `ArgumentNullException`: Thrown if `value` or `prefix` is null
89+
90+
## Supported Frameworks
91+
92+
- .NET Standard 2.0
93+
- .NET 8.0
94+
- .NET 9.0
95+
- .NET 10.0
96+
97+
## Contributing
98+
99+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
100+
101+
## License
102+
103+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
104+
105+
## Links
106+
107+
- [GitHub Repository](https://github.com/dailydevops/extensions.strings)
108+
- [NuGet Package](https://www.nuget.org/packages/NetEvolve.Extensions.Strings/)
109+
- [Release Notes](https://github.com/dailydevops/extensions.strings/releases)
110+
- [Daily DevOps & .NET](https://daily-devops.net/)

src/NetEvolve.Extensions.Strings/NetEvolve.Extensions.Strings.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
44
<Title>$(MSBuildProjectName)</Title>
55
<Description>Library with common `string` extension methods for easy reuse.</Description>
66
<PackageTags>string;extensions;methods</PackageTags>

tests/NetEvolve.Extensions.Strings.Tests.Unit/NetEvolve.Extensions.Strings.Tests.Unit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
3+
<TargetFrameworks>net6.0;net8.0;net9.0;net10.0</TargetFrameworks>
44
<NoWarn>$(NoWarn);CS8604;NU1701</NoWarn>
55
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
66
<CheckEolTargetFramework>false</CheckEolTargetFramework>

0 commit comments

Comments
 (0)