Skip to content

Commit 317b790

Browse files
Copilotsamtrion
andauthored
feat: Add PublicApiAttribute for marking PublicApi test definitions (#967)
* feat: Add PublicApiAttribute to all test frameworks Co-authored-by: samtrion <[email protected]> * chore: Update PublicApi test snapshots for new PublicApiAttribute Co-authored-by: samtrion <[email protected]> * fix(test): Added missing PublicAPI Defintiion --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: samtrion <[email protected]> Co-authored-by: Martin Stühmer <[email protected]>
1 parent 360f2ac commit 317b790

File tree

33 files changed

+288
-0
lines changed

33 files changed

+288
-0
lines changed

src/NetEvolve.Extensions.MSTest/Internals.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,9 @@ internal static class Internals
104104
/// TestGroup
105105
/// </summary>
106106
public const string TestGroup = nameof(TestGroup);
107+
108+
/// <summary>
109+
/// PublicApi
110+
/// </summary>
111+
public const string PublicApi = nameof(PublicApi);
107112
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace NetEvolve.Extensions.MSTest;
2+
3+
using System;
4+
using NetEvolve.Extensions.MSTest.Internal;
5+
6+
/// <summary>
7+
/// Attribute used to decorate a test class or method as <b>PublicApi</b>.
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
10+
public sealed class PublicApiAttribute : TestTraitBaseAttribute
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="PublicApiAttribute"/> class.
14+
/// </summary>
15+
public PublicApiAttribute()
16+
: base(Internals.PublicApi) { }
17+
}

src/NetEvolve.Extensions.NUnit/Internals.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,9 @@ internal static class Internals
104104
/// TestGroup
105105
/// </summary>
106106
public const string TestGroup = nameof(TestGroup);
107+
108+
/// <summary>
109+
/// PublicApi
110+
/// </summary>
111+
public const string PublicApi = nameof(PublicApi);
107112
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace NetEvolve.Extensions.NUnit;
2+
3+
using System;
4+
using global::NUnit.Framework;
5+
6+
/// <summary>
7+
/// Attribute used to decorate a test class or method as <b>PublicApi</b>.
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
10+
public sealed class PublicApiAttribute : CategoryAttribute
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="PublicApiAttribute"/> class.
14+
/// </summary>
15+
public PublicApiAttribute()
16+
: base(Internals.PublicApi) { }
17+
}

src/NetEvolve.Extensions.TUnit/Internals.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,9 @@ internal static class Internals
8989
/// TestGroup
9090
/// </summary>
9191
public const string TestGroup = nameof(TestGroup);
92+
93+
/// <summary>
94+
/// PublicApi
95+
/// </summary>
96+
public const string PublicApi = nameof(PublicApi);
9297
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace NetEvolve.Extensions.TUnit;
2+
3+
using System;
4+
using NetEvolve.Extensions.TUnit.Internal;
5+
6+
/// <summary>
7+
/// Attribute used to decorate a test class or method as <b>PublicApi</b>.
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
10+
public sealed class PublicApiAttribute : CategoryTraitBaseAttribute
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="PublicApiAttribute"/> class.
14+
/// </summary>
15+
public PublicApiAttribute()
16+
: base(Internals.PublicApi) { }
17+
}

src/NetEvolve.Extensions.XUnit.V3/Internals.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,9 @@ internal static class Internals
114114
/// TestGroup
115115
/// </summary>
116116
public const string TestGroup = nameof(TestGroup);
117+
118+
/// <summary>
119+
/// PublicApi
120+
/// </summary>
121+
public const string PublicApi = nameof(PublicApi);
117122
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace NetEvolve.Extensions.XUnit.V3;
2+
3+
using System;
4+
using NetEvolve.Extensions.XUnit.V3.Internal;
5+
6+
/// <summary>
7+
/// Attribute used to decorate a test class or method as <b>PublicApi</b>.
8+
/// </summary>
9+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
10+
public sealed class PublicApiAttribute : CategoryTraitBaseAttribute
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="PublicApiAttribute"/> class.
14+
/// </summary>
15+
public PublicApiAttribute()
16+
: base(Internals.PublicApi) { }
17+
}

tests/NetEvolve.Extensions.MSTest.Tests.PublicApi/_snapshots/DotNet10_0/PublicApiTests.PublicApi_HasNotChanged_Expected.verified.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
{
6161
public PreDeploymentAttribute() { }
6262
}
63+
public sealed class PublicApiAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute
64+
{
65+
public PublicApiAttribute() { }
66+
}
6367
public sealed class TestGroupAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute
6468
{
6569
public TestGroupAttribute(string id) { }

tests/NetEvolve.Extensions.MSTest.Tests.PublicApi/_snapshots/DotNet8_0/PublicApiTests.PublicApi_HasNotChanged_Expected.verified.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
{
6161
public PreDeploymentAttribute() { }
6262
}
63+
public sealed class PublicApiAttribute : NetEvolve.Extensions.MSTest.Internal.TestTraitBaseAttribute
64+
{
65+
public PublicApiAttribute() { }
66+
}
6367
public sealed class TestGroupAttribute : NetEvolve.Extensions.MSTest.Internal.TestCategoryWithIdBaseAttribute
6468
{
6569
public TestGroupAttribute(string id) { }

0 commit comments

Comments
 (0)