AlastairLundy.DotExtensions 8.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package AlastairLundy.DotExtensions --version 8.0.0
                    
NuGet\Install-Package AlastairLundy.DotExtensions -Version 8.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AlastairLundy.DotExtensions" Version="8.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlastairLundy.DotExtensions" Version="8.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AlastairLundy.DotExtensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AlastairLundy.DotExtensions --version 8.0.0
                    
#r "nuget: AlastairLundy.DotExtensions, 8.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AlastairLundy.DotExtensions@8.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AlastairLundy.DotExtensions&version=8.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AlastairLundy.DotExtensions&version=8.0.0
                    
Install as a Cake Tool

DotExtensions

An extension method library that enhances the experience of using .NET's types with useful features.

DotExtensions NuGet NuGet

Table of Contents

Features

  • Empty directory detection via IsDirectoryEmpty extension method for the DirectoryInfo class.
  • Support for comparing versions via easy to understand methods e.g. version.IsNewerThan(Version otherVersion) etc.
  • DateTime and DateOnly extensions e.g. DateOnly's ToDateTime extension
  • Support for Detecting and Removing Special Characters
  • Support for Detecting and Removing Escape Characters

^1 - StringSegment extensions are part of the AlastairLundy.DotExtensions.MsExtensions package.

How to install and use DotExtensions

DotExtensions can be installed via the .NET SDK CLI, Nuget via your IDE or code editor's package interface, or via the Nuget website.

Package Name Nuget Link .NET SDK CLI command
AlastairLundy.DotExtensions AlastairLundy.DotExtensions Nuget dotnet add package AlastairLundy.DotExtensions

Compatibility

DotExtensions supports:

  • .NET 8
  • .NET 9

However, it is important to note that not all features may be supported by all TFMs.

Note for DateOnly: Though DateOnly was originally part of .NET 6, this library's DateOnly extension methods are only supported for .NET 8 and .NET 9 users since we don't target .NET 6 as a TFM due to being out of support.

How to Build the code

Requirements

DotExtensions requires the latest .NET release SDK to be installed to target all supported TFM (Target Framework Moniker) build targets.

Currently, the required .NET SDK is .NET 9.

The current build targets include:

  • .NET 8
  • .NET 9

Any version of the .NET 9 SDK can be used, but using the latest version is preferred.

Versioning new releases

DotExtensions aims to follow Semantic versioning with [Major].[Minor].[Build] for most circumstances and an optional .[Revision] when only a configuration change is made, or a new build of a preview release or a new build of a previous release is made.

Pre-releases

Pre-release versions should have a suffix of -alpha, -beta, -rc, or -preview followed by a . and what pre-release version number they are. The number should be incremented by 1 after each release unless it only contains a configuration change, or another packaging, or build change. An example pre-release version may look like 1.1.0-alpha.2 , this version string would indicate it is the 2nd alpha pre-release version of 1.1.0 .

Stable Releases

Stable versions should follow semantic versioning and should only increment the Revision number if a release only contains configuration or build packaging changes, with no change in functionality, features, or even bug or security fixes.

Releases that only implement bug fixes should see the Build version incremented.

Releases that add new non-breaking changes should increment the Minor version. Minor breaking changes may be permitted in Minor version releases where doing so is necessary to maintain compatibility with an existing supported platform, or an existing piece of code that requires a breaking change to continue to function as intended.

Releases that add major breaking changes or significantly affect the API should increment the Major version. Major version releases should not be released with excessive frequency and should be released when there is a genuine need for the API to change significantly for the improvement of the project.

Building for Testing

You can build for testing by building the project within your IDE or VS Code, or manually by entering the following command: dotnet build -c Debug.

If you encounter any bugs or issues, try testing your code with breakpoints in the affected code where appropriate. Failing that, please report the issue if one doesn't already exist for the bug(s).

Building for Release

Before building a release build, ensure you apply the relevant changes to the AlastairLundy.DotExtensions.csproj file:

  • Update the Package Version variable
  • Update the project file's Changelog

You should ensure the project builds under debug settings before producing a release build.

Producing Release Builds

To manually build for release, enter dotnet build -c Release for a release with SourceLink enabled.

Builds should generally always include SourceLink and symbol packages if intended for wider distribution.

How to Contribute

Thank you in advance for considering contributing to DotExtensions .

Please see the CONTRIBUTING.md file for code and localization contributions.

If you want to file a bug report or suggest a potential feature to add, please check out the GitHub issues page to see if a similar or identical issue is already open. If there is not already a relevant issue filed, please file one here and follow the respective guidance from the appropriate issue template.

Thanks.

Roadmap

DotExtensions aims to make working with different types in the System namespace in C# easier.

All stable releases must be stable and should not contain regressions.

Future updates should aim focus on one or more of the following:

  • Adding extension methods that improve ease of use
  • Enhancing existing extension methods

Note: This library is not a primitive library and also does not seek to add new interfaces or implementations of interfaces. It is purely a library for extension methods.

License

This project is licensed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on AlastairLundy.DotExtensions:

Package Downloads
PlatformKit

Cross-platform Operating System Detection, Operating System Version Detection, Apple Silicon Mac Detection, programmatic .NET Runtime ID Generation, and more. For a full list of features please visit: https://github.com/alastairlundy/PlatformKit/blob/main/docs/FeatureComparisonByPlatform.md

AlastairLundy.CliInvoke

CliInvoke is a .NET Library for interacting with Command Line Interfaces, CliInvoke is a library for interacting with Command Line Interfaces and wrapping around executables.

AlastairLundy.CliInvoke.Core

Process and Cli program running related abstractions implemented by AlastairLundy.CliInvoke

AlastairLundy.Resyslib.IO

A library to make programmatic directory deletion and creation in .NET easier.

AlastairLundy.OsReleaseNet

Linux OsRelease detection, SteamOS detection, and helpful detection code for Linux.

GitHub repositories

This package is not used by any popular GitHub repositories.

## Changes since 7.6.x

__Breaking Changes__:
* Removed .NET Standard 2.0 and 2.1 support
* Removed deprecated code
* Moved most LINQ style Span and IEnumerable, ICollection, and IList extensions out of DotExtensions to a different library
* Improved code formatting
* Removed String ``IndicesOf`` extension methods - These methods will be moved to ExtraLinq
* Updated Number Range Enumerable and Array extensions to throw exceptions if count parameter is 0
* Moved Integer Range enumerable and array methods to ExtraLinq

__Non Breaking Changes__:
* Added new string Insert(int index, char c) extension method
* Improved code formatting
* Reworked Span Resize method
* Reworked Span CopyTo methods
* Added Span TryCopyTo extension methods
* Added Span OptimisticCopy extension methods
* Moved LINQ style extensions for StringSegment to a different library.
* Added DateTime, DateOnly, and TimeOnly Abs absolute difference extension methods
* Updated DateTime and DateOnly Subtract extension method internal code
* Reworked string case detection and capitalization methods
* Clarified unsupported Operating Systems for Process ``HasStarted`` extension method