Skip to content

Commit 067471e

Browse files
committed
updated readme for v10.0.0
1 parent 0a2f2e7 commit 067471e

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
**A lightweight .NET library for expressive Guard Clauses.**
33

44
[![License](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://github.com/feO2x/Light.GuardClauses/blob/master/LICENSE)
5-
[![NuGet](https://img.shields.io/badge/NuGet-9.0.0-blue.svg?style=for-the-badge)](https://www.nuget.org/packages/Light.GuardClauses/)
6-
[![Source Code](https://img.shields.io/badge/Source%20Code-9.0.0-blue.svg?style=for-the-badge)](https://github.com/feO2x/Light.GuardClauses/blob/master/Light.GuardClauses.SingleFile.cs)
5+
[![NuGet](https://img.shields.io/badge/NuGet-10.0.0-blue.svg?style=for-the-badge)](https://www.nuget.org/packages/Light.GuardClauses/)
6+
[![Source Code](https://img.shields.io/badge/Source%20Code-10.0.0-blue.svg?style=for-the-badge)](https://github.com/feO2x/Light.GuardClauses/blob/master/Light.GuardClauses.SingleFile.cs)
77
[![Documentation](https://img.shields.io/badge/Docs-Wiki-yellowgreen.svg?style=for-the-badge)](https://github.com/feO2x/Light.GuardClauses/wiki)
88
[![Documentation](https://img.shields.io/badge/Docs-Changelog-yellowgreen.svg?style=for-the-badge)](https://github.com/feO2x/Light.GuardClauses/releases)
99

10-
[![Video introduction to Light.GuardClauses](Images/version2-video-logo.png)](https://youtu.be/wTDY_Gt46vU)
11-
1210
## Light.GuardClauses - easy precondition checks in C# / .NET
1311

1412
[Read the full docs in the Wiki](https://github.com/feO2x/Light.GuardClauses/wiki)
@@ -39,11 +37,13 @@ public class Foo
3937

4038
public Foo(IBar? bar)
4139
{
42-
_bar = bar.MustNotBeNull(nameof(bar));
40+
_bar = bar.MustNotBeNull();
4341
}
4442
}
4543
```
4644

45+
> As of version 10, Light.GuardClauses supports the [CallerArgumentExpressionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callerargumentexpressionattribute) of C# 10. If your C# compiler is on a lower version, then the `CallerArgumentExpressionAttribute` might not be respected - you should then call all assertions with an explicit parameter name, e.g. `bar.MustNotBeNull(nameof(bar))`. You can use the C# 10 compiler by e.g. installing .NET 6 and/or Visual Studio 2022. The `CallerArgumentExpressionAttribute` is backwards-compatible, so it can be used with projects targeting .NET Standard 2, .NET Framework, or .NET Core.
46+
4747
By using **Light.GuardClauses**, you'll gain access to assertions for a vast amount of scenarios like checking strings, collections, enums, URIs, `DateTime`, `Type`, `IComparable<T>`, `IEnumerable`, `IEnumerable<T>`, and `Span<T>`. Just have a look at these examples:
4848

4949
```csharp
@@ -52,7 +52,7 @@ public class ConsoleWriter
5252
private readonly ConsoleColor _foregroundColor;
5353

5454
public ConsoleWriter(ConsoleColor foregroundColor = ConsoleColor.Black) =>
55-
_foregroundColor = foregroundColor.MustBeValidEnumValue(nameof(foregroundColor));
55+
_foregroundColor = foregroundColor.MustBeValidEnumValue();
5656
}
5757
```
5858

@@ -75,8 +75,8 @@ public class WebGateway
7575

7676
public WebGateway(HttpClient? httpClient, Uri? targetUrl)
7777
{
78-
_httpClient = httpClient.MustNotBeNull(nameof(httpClient));
79-
_targetUrl = targetUrl.MustBeHttpOrHttpsUrl(nameof(targetUrl));
78+
_httpClient = httpClient.MustNotBeNull();
79+
_targetUrl = targetUrl.MustBeHttpOrHttpsUrl();
8080
}
8181
}
8282
```
@@ -92,7 +92,7 @@ Every assertion is well-documented - explore them using IntelliSense or check ou
9292

9393
## Light.GuardClauses is optimized
9494

95-
Since version 4.x, **Light.GuardClauses** is optimized for performance (measured in .NET 4.8 and .NET Core 3.x). With the incredible help of [@redknightlois](https://github.com/redknightlois) and the awesome tool [Benchmark.NET](https://github.com/dotnet/BenchmarkDotNet), most assertions are as fast as your imperative code would be.
95+
Since version 4.x, **Light.GuardClauses** is optimized for performance (measured in .NET 4.8 and .NET 6). With the incredible help of [@redknightlois](https://github.com/redknightlois) and the awesome tool [Benchmark.NET](https://github.com/dotnet/BenchmarkDotNet), most assertions are as fast as your imperative code would be.
9696

9797
**Light.GuardClauses** has support for [.NET analyzers / FxCopAnalyzers](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview) with the `ValidatedNotNullAttribute`. Analyzers will know when an assertion validated that a parameters is not null and consequently, CA1062 will not be raised.
9898

@@ -104,17 +104,15 @@ And, of course, the functional correctness of **Light.GuardClauses** is covered
104104

105105
## Supported Platforms
106106

107-
**Light.GuardClauses** supports the following platforms:
108-
- .NET Standard 2.0 or higher
109-
- .NET Core 3.0 or higher
107+
**Light.GuardClauses** is built against [.NET Standard 2.0 and 2.1](https://docs.microsoft.com/en-us/dotnet/standard/net-standard), thus it can be used in frameworks like .NET 6, .NET Core 3.1, .NET Framework 4.6.1 or newer, Unity, Mono, or UWP.
110108

111109
## How to Install
112110

113111
Light.GuardClauses is available as a [NuGet package](https://www.nuget.org/packages/Light.GuardClauses/).
114112

115113
- **dotnet CLI**: `dotnet add package Light.GuardClauses`
116114
- **Visual Studio Package Manager Console**: `Install-Package Light.GuardClauses`
117-
- **Package Reference in csproj**: `<PackageReference Include="Light.GuardClauses" Version="9.0.0" />`
115+
- **Package Reference in csproj**: `<PackageReference Include="Light.GuardClauses" Version="10.0.0" />`
118116

119117
Also, you can incorporate Light.GuardClauses as a **single source file** where the API is changed to `internal`. This is especially interesting for framework / library developers that do not want to have a dependency on the Light.GuardClauses DLL. You can grab the default .NET Standard 2.0 version in [Light.GuardClauses.SingleFile.cs](https://github.com/feO2x/Light.GuardClauses/blob/master/Light.GuardClauses.SingleFile.cs) or you can use the [Light.GuardClauses.SourceCodeTransformation](https://github.com/feO2x/Light.GuardClauses/tree/master/Code/Light.GuardClauses.SourceCodeTransformation) project to create your custom file. You can learn more about it [here](https://github.com/feO2x/Light.GuardClauses/wiki/Including-Light.GuardClauses-as-source-code).
120118

0 commit comments

Comments
 (0)