-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5aec46d
commit 5a98205
Showing
9 changed files
with
116 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
<Project Condition="'$(MSBuildProjectExtension)' == '.csproj' and '$(MSBuildProjectFile)' != '_build.csproj'"> | ||
|
||
<PropertyGroup> | ||
<Project> | ||
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'"> | ||
<Nullable>enable</Nullable> | ||
<WarningsAsErrors>CS8600;CS8602;CS8603;CS8604;CS8625;CS8618;CS8620;CS0219</WarningsAsErrors> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<WarningsAsErrors>CS8600;CS8602;CS8603;CS8604;CS8625;CS8618;CS8620</WarningsAsErrors> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" Version="4.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="AsyncFixer" Version="1.6.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'"> | ||
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="AsyncFixer" Version="1.6.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace CSharpPlus; | ||
|
||
/// <summary> | ||
/// Disposable static functions | ||
/// </summary> | ||
public static class Disposable | ||
{ | ||
/// <inheritdoc /> | ||
public readonly struct Deferred : IDisposable | ||
{ | ||
readonly Action action; | ||
|
||
/// <summary> | ||
/// Create new deferred context | ||
/// </summary> | ||
public Deferred(Action action) => this.action = action; | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() => action?.Invoke(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public readonly struct DeferredTask : IAsyncDisposable | ||
{ | ||
readonly Func<ValueTask> action; | ||
|
||
/// <summary> | ||
/// Create new deferred context | ||
/// </summary> | ||
public DeferredTask(Func<ValueTask> action) => this.action = action; | ||
|
||
/// <inheritdoc /> | ||
public async ValueTask DisposeAsync() | ||
{ | ||
if (action is not null) | ||
await action(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Defer action execution with Dispose | ||
/// </summary> | ||
public static Deferred Defer(Action action) => new(action); | ||
|
||
/// <summary> | ||
/// Defer async action execution with DisposeAsync | ||
/// </summary> | ||
public static DeferredTask Defer(Func<ValueTask> action) => new(action); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
namespace CSharpPlus.LinqArray; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,46 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<InvariantGlobalization>false</InvariantGlobalization> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="AutoBogus" Version="2.13.1"/> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0"/> | ||
<PackageReference Include="FsCheck.NUnit" Version="2.16.6"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/> | ||
<PackageReference Include="NUnit" Version="3.13.3"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.8.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="Roslynator.Analyzers" Version="4.2.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="Roslynator.CodeAnalysis.Analyzers" Version="4.2.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="Roslynator.Formatting.Analyzers" Version="4.5.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="SonarAnalyzer.CSharp" Version="8.50.0.58025"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AutoBogus" Version="2.13.1" /> | ||
<PackageReference Include="FluentAssertions" Version="6.8.0" /> | ||
<PackageReference Include="FsCheck.NUnit" Version="2.16.5" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="NUnit" Version="3.13.3" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" /> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.8.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="Roslynator.Analyzers" Version="4.2.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="Roslynator.CodeAnalysis.Analyzers" Version="4.2.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="Roslynator.Formatting.Analyzers" Version="4.5.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="SonarAnalyzer.CSharp" Version="8.50.0.58025"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\CSharpPlus.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\CSharpPlus.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using CSharpPlus.LinqArray; | ||
|
||
namespace CSharpPlus.Tests; | ||
|
||
public class LinqArrayExtensionsTests | ||
|