Skip to content

Commit ad04257

Browse files
Mark IDeveloperCertificateService experimental (#12653)
Co-authored-by: David Negstad <[email protected]>
1 parent 9d9f394 commit ad04257

File tree

10 files changed

+28
-0
lines changed

10 files changed

+28
-0
lines changed

src/Aspire.Hosting.Yarp/YarpResourceExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public static IResourceBuilder<YarpResource> AddYarp(
4343
{
4444
yarpBuilder.WithEnvironment(ctx =>
4545
{
46+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
4647
var developerCertificateService = ctx.ExecutionContext.ServiceProvider.GetRequiredService<IDeveloperCertificateService>();
48+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
4749
if (!developerCertificateService.SupportsContainerTrust)
4850
{
4951
// On systems without the ASP.NET DevCert updates introduced in .NET 10, YARP will not trust the cert used

src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,9 @@ internal static NetworkIdentifier GetDefaultResourceNetwork(this IResource resou
404404
NetworkIdentifier? networkContext = null,
405405
CancellationToken cancellationToken = default)
406406
{
407+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
407408
var developerCertificateService = executionContext.ServiceProvider.GetRequiredService<IDeveloperCertificateService>();
409+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
408410
var trustDevCert = developerCertificateService.TrustCertificate;
409411

410412
var certificates = new X509Certificate2Collection();

src/Aspire.Hosting/Dcp/DcpExecutor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ internal sealed partial class DcpExecutor : IDcpExecutor, IConsoleLogsService, I
7070
private readonly CancellationTokenSource _shutdownCancellation = new();
7171
private readonly DcpExecutorEvents _executorEvents;
7272
private readonly Locations _locations;
73+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
7374
private readonly IDeveloperCertificateService _developerCertificateService;
75+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
7476

7577
private readonly DcpResourceState _resourceState;
7678
private readonly ResourceSnapshotBuilder _snapshotBuilder;
@@ -105,7 +107,9 @@ public DcpExecutor(ILogger<DcpExecutor> logger,
105107
DcpNameGenerator nameGenerator,
106108
DcpExecutorEvents executorEvents,
107109
Locations locations,
110+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
108111
IDeveloperCertificateService developerCertificateService)
112+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
109113
{
110114
_distributedApplicationLogger = distributedApplicationLogger;
111115
_kubernetesService = kubernetesService;

src/Aspire.Hosting/DeveloperCertificateService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
namespace Aspire.Hosting;
1111

12+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
1213
internal class DeveloperCertificateService : IDeveloperCertificateService
14+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
1315
{
1416
private readonly Lazy<ImmutableList<X509Certificate2>> _certificates;
1517
private readonly Lazy<bool> _supportsContainerTrust;

src/Aspire.Hosting/DistributedApplicationBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ public DistributedApplicationBuilder(DistributedApplicationOptions options)
325325

326326
return new AspireStore(Path.Combine(aspireDir, ".aspire"));
327327
});
328+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
328329
_innerBuilder.Services.AddSingleton<IDeveloperCertificateService, DeveloperCertificateService>();
330+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
329331

330332
// Shared DCP things (even though DCP isn't used in 'publish' and 'inspect' mode
331333
// we still honour the DCP options around container runtime selection.

src/Aspire.Hosting/IDeveloperCertificateService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Immutable;
5+
using System.Diagnostics.CodeAnalysis;
56
using System.Security.Cryptography.X509Certificates;
67

78
namespace Aspire.Hosting;
89

910
/// <summary>
1011
/// Service that provides information about developer certificate trust capabilities.
1112
/// </summary>
13+
[Experimental("ASPIRECERTIFICATES001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")]
1214
public interface IDeveloperCertificateService
1315
{
1416
/// <summary>

tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,7 @@ private static DcpExecutor CreateAppExecutor(
20212021

20222022
var developerCertificateService = new TestDeveloperCertificateService(new List<X509Certificate2>(), false, false);
20232023

2024+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
20242025
return new DcpExecutor(
20252026
NullLogger<DcpExecutor>.Instance,
20262027
NullLogger<DistributedApplication>.Instance,
@@ -2042,6 +2043,7 @@ private static DcpExecutor CreateAppExecutor(
20422043
events ?? new DcpExecutorEvents(),
20432044
new Locations(),
20442045
developerCertificateService);
2046+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
20452047
}
20462048

20472049
private sealed class TestExecutableResource(string directory) : ExecutableResource("TestExecutable", "test", directory);

tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,9 @@ public async Task VerifyContainerIncludesExpectedDevCertificateConfiguration(boo
652652
await app.StartAsync().DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout);
653653

654654
var s = app.Services.GetRequiredService<IKubernetesService>();
655+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
655656
var dc = app.Services.GetRequiredService<IDeveloperCertificateService>();
657+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
656658
var list = await s.ListAsync<Container>().DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout);
657659

658660
Assert.Collection(list,

tests/Aspire.Hosting.Tests/Utils/TestDeveloperCertificateService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
namespace Aspire.Hosting.Tests.Utils;
88

9+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
910
public sealed class TestDeveloperCertificateService(List<X509Certificate2> certificates, bool supportsContainerTrust, bool trustCertificate) : IDeveloperCertificateService
11+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
1012
{
1113
/// <inheritdoc />
1214
public ImmutableList<X509Certificate2> Certificates { get; } = certificates.ToImmutableList();

tests/Aspire.Hosting.Yarp.Tests/AddYarpTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void VerifyYarpResourceWithTargetPort()
2828
[InlineData(false)]
2929
public async Task VerifyRunEnvVariablesAreSet(bool containerCertificateSupport)
3030
{
31+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
3132
var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run);
3233

3334
// Report that developer certificates won't support container scenarios
@@ -54,6 +55,7 @@ public async Task VerifyRunEnvVariablesAreSet(bool containerCertificateSupport)
5455
var value = Assert.Contains("YARP_UNSAFE_OLTP_CERT_ACCEPT_ANY_SERVER_CERTIFICATE", env);
5556
Assert.Equal("true", value);
5657
}
58+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
5759
}
5860

5961
[Fact]
@@ -75,6 +77,7 @@ public async Task VerifyPublishEnvVariablesAreSet()
7577
[Fact]
7678
public async Task VerifyWithStaticFilesAddsEnvironmentVariable()
7779
{
80+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
7881
var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run);
7982

8083
// Yarp requires an IDeveloperCertificateService in run mode when building it's environment variables.
@@ -90,11 +93,13 @@ public async Task VerifyWithStaticFilesAddsEnvironmentVariable()
9093

9194
var value = Assert.Contains("YARP_ENABLE_STATIC_FILES", env);
9295
Assert.Equal("true", value);
96+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
9397
}
9498

9599
[Fact]
96100
public async Task VerifyWithStaticFilesWorksInPublishOperation()
97101
{
102+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
98103
var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish);
99104

100105
// Yarp requires an IDeveloperCertificateService in run mode when building it's environment variables.
@@ -110,11 +115,13 @@ public async Task VerifyWithStaticFilesWorksInPublishOperation()
110115

111116
var value = Assert.Contains("YARP_ENABLE_STATIC_FILES", env);
112117
Assert.Equal("true", value);
118+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
113119
}
114120

115121
[Fact]
116122
public async Task VerifyWithStaticFilesBindMountAddsEnvironmentVariable()
117123
{
124+
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
118125
var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Run);
119126

120127
// Yarp requires an IDeveloperCertificateService in run mode when building it's environment variables.
@@ -132,6 +139,7 @@ public async Task VerifyWithStaticFilesBindMountAddsEnvironmentVariable()
132139

133140
var value = Assert.Contains("YARP_ENABLE_STATIC_FILES", env);
134141
Assert.Equal("true", value);
142+
#pragma warning restore ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
135143
}
136144

137145
[Fact]

0 commit comments

Comments
 (0)