Skip to content

Commit

Permalink
Fix readme because of nuget.org
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Oct 1, 2024
1 parent e5ea79c commit 43ae8d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<PackageProjectUrl>https://github.com/MarkCiliaVincenti/Backport.System.Threading.Lock</PackageProjectUrl>
<Copyright>MIT</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Version>2.0.4</Version>
<Version>2.0.5</Version>
<PackageIcon>logo.png</PackageIcon>
<PackageReleaseNotes>Made IsHeldByCurrentThread unavailable for frameworks that don't support Monitor.IsEntered rather than throwing a NotSupportedException.</PackageReleaseNotes>
<Description>A micro-library that backports/polyfills .NET 9.0+'s System.Threading.Lock to prior framework versions (from .NET Framework 3.5 up to .NET 8.0), providing as much backward compatibility as possible.</Description>
<Copyright>© 2024 Mark Cilia Vincenti</Copyright>
<PackageTags>System.Threading.Lock,lock,backport,polyfill,backward,compatible,compatibility,synchronization,synchronisation</PackageTags>
<RepositoryType>git</RepositoryType>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AssemblyVersion>2.0.4.0</AssemblyVersion>
<FileVersion>2.0.4.0</FileVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<FileVersion>2.0.5.0</FileVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IsPackable>true</IsPackable>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ If you want to avoid limiting what you are able to do, you need a solution such
## Usage
There are two methods for using this library:

1. **Clean method** If you are only targeting .NET 5.0 or greater, then you are strongly recommended to use the [clean method](#net50-or-greater).
2. **Factory method** If you need to target frameworks prior to .NET 5.0 (and that would also include .NET Standard 2.0 and 2.1), then you need to use the [factory method](#prior-to-net50) because the clean method cannot be hardened against thread aborts which were removed in .NET 5.0.
1. **Clean method:** If you are only targeting .NET 5.0 or greater, then you are strongly recommended to use the clean method.
2. **Factory method:** If you need to target frameworks prior to .NET 5.0 (and that would also include .NET Standard 2.0 and 2.1), then you need to use the factory method because the clean method cannot be hardened against thread aborts which were removed in .NET 5.0.

### <a name="net50-or-greater"></a>Clean method (if only targeting .NET 5.0 or greater)
### Clean method (if only targeting .NET 5.0 or greater)
In order to get the performance benefits of `System.Threading.Lock`, you must however [multi-target frameworks](https://learn.microsoft.com/en-us/nuget/create-packages/multiple-target-frameworks-project-file) in your `.csproj` file.

Example:
Expand All @@ -67,7 +67,7 @@ There is also no need to reference this library as a dependency for .NET 9.0+. Y

```
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
<PackageReference Include="Backport.System.Threading.Lock" Version="2.0.4" />
<PackageReference Include="Backport.System.Threading.Lock" Version="2.0.5" />
</ItemGroup>
```

Expand All @@ -93,8 +93,7 @@ public void Bar()
}
```


### <a name="prior-to-net50"></a>Factory method (if targeting frameworks prior to .NET 5.0)
### Factory method (if targeting frameworks prior to .NET 5.0)
Due to frameworks prior to .NET 5.0 supporting the notorious `Thread.Abort`, we cannot use the same `System.Threading.Lock` namespace or else the locks would not be hardened against thread aborts, so we need to use a creator method instead.

**IMPORTANT:** You MUST also [multi-target](https://learn.microsoft.com/en-us/nuget/create-packages/multiple-target-frameworks-project-file) .NET 9.0 in your `.csproj` file as well.
Expand Down

0 comments on commit 43ae8d0

Please sign in to comment.