Skip to content

Commit 1399a41

Browse files
authored
Merge pull request #771 from adamralph/verify-public-api
switch from PublicApiAnalyzers to PublicApiGenerator and Verify
2 parents 1c16da1 + fabe72d commit 1399a41

File tree

9 files changed

+270
-24
lines changed

9 files changed

+270
-24
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: super-linter/super-linter@d5b0a2ab116623730dd094f15ddc1b6b25bf7b99 # v8.3.2
2121
env:
2222
DEFAULT_BRANCH: main
23-
FILTER_REGEX_EXCLUDE: \bcodeql-analysis\.yml$|\bLICENSE$
23+
FILTER_REGEX_EXCLUDE: \bcodeql-analysis\.yml$|\bLICENSE$|\.verified\.txt$
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525
VALIDATE_BIOME_FORMAT: false
2626
VALIDATE_DOTNET_SLN_FORMAT_ANALYZERS: false

SimpleExec/Command.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace SimpleExec;
88
/// <summary>
99
/// Contains methods for running commands and reading standard output (stdout).
1010
/// </summary>
11+
#pragma warning disable RS0026 // Do not add multiple overloads with optional parameters
1112
public static class Command
1213
{
1314
private static readonly Action<IDictionary<string, string?>> DefaultAction = _ => { };

SimpleExec/PublicAPI.Shipped.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

SimpleExec/PublicAPI.Unshipped.txt

Whitespace-only changes.

SimpleExec/SimpleExec.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<Description>Runs external commands.</Description>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<IsPackable>true</IsPackable>
7+
<NoWarn>$(NoWarn);RS0016</NoWarn> <!-- Add public types and members to the declared API -->
8+
<NoWarn>$(NoWarn);RS0037</NoWarn> <!-- Enable tracking of nullability of reference types in the declared API -->
79
<PackageIcon>simple-exec.png</PackageIcon>
810
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
911
<PackageProjectUrl>https://github.com/adamralph/simple-exec</PackageProjectUrl>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace SimpleExec
2+
{
3+
public static class Command
4+
{
5+
[return: System.Runtime.CompilerServices.TupleElementNames(new string[] {
6+
"StandardOutput",
7+
"StandardError"})]
8+
public static System.Threading.Tasks.Task<System.ValueTuple<string, string>> ReadAsync(string name, System.Collections.Generic.IEnumerable<string> args, string workingDirectory = "", System.Action<System.Collections.Generic.IDictionary<string, string?>>? configureEnvironment = null, System.Text.Encoding? encoding = null, System.Func<int, bool>? handleExitCode = null, string? standardInput = null, bool cancellationIgnoresProcessTree = false, System.Threading.CancellationToken cancellationToken = default) { }
9+
[return: System.Runtime.CompilerServices.TupleElementNames(new string[] {
10+
"StandardOutput",
11+
"StandardError"})]
12+
public static System.Threading.Tasks.Task<System.ValueTuple<string, string>> ReadAsync(string name, string args = "", string workingDirectory = "", System.Action<System.Collections.Generic.IDictionary<string, string?>>? configureEnvironment = null, System.Text.Encoding? encoding = null, System.Func<int, bool>? handleExitCode = null, string? standardInput = null, bool cancellationIgnoresProcessTree = false, System.Threading.CancellationToken cancellationToken = default) { }
13+
public static void Run(string name, System.Collections.Generic.IEnumerable<string> args, string workingDirectory = "", System.Collections.Generic.IEnumerable<string>? secrets = null, bool noEcho = false, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string, string?>>? configureEnvironment = null, bool createNoWindow = false, System.Func<int, bool>? handleExitCode = null, bool cancellationIgnoresProcessTree = false, System.Threading.CancellationToken cancellationToken = default) { }
14+
public static void Run(string name, string args = "", string workingDirectory = "", System.Collections.Generic.IEnumerable<string>? secrets = null, bool noEcho = false, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string, string?>>? configureEnvironment = null, bool createNoWindow = false, System.Func<int, bool>? handleExitCode = null, bool cancellationIgnoresProcessTree = false, System.Threading.CancellationToken cancellationToken = default) { }
15+
public static System.Threading.Tasks.Task RunAsync(string name, System.Collections.Generic.IEnumerable<string> args, string workingDirectory = "", System.Collections.Generic.IEnumerable<string>? secrets = null, bool noEcho = false, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string, string?>>? configureEnvironment = null, bool createNoWindow = false, System.Func<int, bool>? handleExitCode = null, bool cancellationIgnoresProcessTree = false, System.Threading.CancellationToken cancellationToken = default) { }
16+
public static System.Threading.Tasks.Task RunAsync(string name, string args = "", string workingDirectory = "", System.Collections.Generic.IEnumerable<string>? secrets = null, bool noEcho = false, string? echoPrefix = null, System.Action<System.Collections.Generic.IDictionary<string, string?>>? configureEnvironment = null, bool createNoWindow = false, System.Func<int, bool>? handleExitCode = null, bool cancellationIgnoresProcessTree = false, System.Threading.CancellationToken cancellationToken = default) { }
17+
}
18+
public class ExitCodeException : System.Exception
19+
{
20+
public ExitCodeException(int exitCode) { }
21+
public int ExitCode { get; }
22+
public override string Message { get; }
23+
}
24+
public class ExitCodeReadException : SimpleExec.ExitCodeException
25+
{
26+
public ExitCodeReadException(int exitCode, string standardOutput, string standardError) { }
27+
public override string Message { get; }
28+
public string StandardError { get; }
29+
public string StandardOutput { get; }
30+
}
31+
}

SimpleExecTests/PublicApi.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using SimpleExec;
2+
using PublicApiGenerator;
3+
using Xunit;
4+
5+
namespace SimpleExecTests;
6+
7+
public static class PublicApi
8+
{
9+
[Fact]
10+
public static async Task IsVerified()
11+
{
12+
var options = new ApiGeneratorOptions { IncludeAssemblyAttributes = false };
13+
14+
var publicApi = typeof(Command).Assembly.GeneratePublicApi(options);
15+
16+
_ = await Verify(publicApi);
17+
}
18+
}

SimpleExecTests/SimpleExecTests.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<ItemGroup>
1111
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.1" />
1212
<PackageReference Include="Microsoft.Testing.Platform" Version="2.0.2" />
13+
<PackageReference Include="PublicApiGenerator" Version="11.5.4" />
14+
<PackageReference Include="Verify.XunitV3" Version="31.9.0" />
1315
<PackageReference Include="xunit.v3.mtp-v2" Version="3.2.1" />
1416
</ItemGroup>
1517

@@ -18,10 +20,18 @@
1820
<ProjectReference Include="..\SimpleExecTester\SimpleExecTester.csproj" />
1921
</ItemGroup>
2022

23+
<ItemGroup Label="Clean up after Verify.Xunit">
24+
<Using Remove="VerifyTests" />
25+
<Using Remove="Xunit" />
26+
</ItemGroup>
27+
2128
<ItemGroup>
2229
<None Update="hello-world.cmd">
2330
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2431
</None>
32+
<None Update="PublicApi.*.verified.txt">
33+
<DependentUpon>PublicApi.cs</DependentUpon>
34+
</None>
2535
</ItemGroup>
2636

2737
</Project>

0 commit comments

Comments
 (0)