-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
c8f9693
commit 53d5f6d
Showing
5 changed files
with
2,799 additions
and
3 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
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,43 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
using PublicApiGenerator; | ||
using VerifyXunit; | ||
|
||
namespace DynamicData.APITests | ||
{ | ||
/// <summary> | ||
/// Api Approval Base. | ||
/// </summary> | ||
[ExcludeFromCodeCoverage] | ||
[UsesVerify] | ||
public abstract class ApiApprovalBase | ||
{ | ||
/// <summary> | ||
/// Check Approval. | ||
/// </summary> | ||
/// <param name="assembly">The assembly.</param> | ||
/// <param name="filePath">The file path.</param> | ||
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns> | ||
protected static Task CheckApproval(Assembly assembly, [CallerFilePath] string? filePath = null) | ||
{ | ||
if (filePath is null) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
var generatorOptions = new ApiGeneratorOptions { AllowNamespacePrefixes = ["DynamicData"] }; | ||
var apiText = assembly.GeneratePublicApi(generatorOptions); | ||
return Verifier.Verify(apiText, null, filePath) | ||
.UniqueForRuntimeAndVersion() | ||
.ScrubEmptyLines() | ||
.ScrubLines(l => | ||
l.StartsWith("[assembly: AssemblyVersion(", StringComparison.InvariantCulture) || | ||
l.StartsWith("[assembly: AssemblyFileVersion(", StringComparison.InvariantCulture) || | ||
l.StartsWith("[assembly: AssemblyInformationalVersion(", StringComparison.InvariantCulture) || | ||
l.StartsWith("[assembly: System.Reflection.AssemblyMetadata(", StringComparison.InvariantCulture)); | ||
} | ||
} | ||
} |
Oops, something went wrong.