Skip to content

Commit a41b20b

Browse files
committed
Dedupe shared backchannel types
1 parent 2f03451 commit a41b20b

File tree

3 files changed

+9
-131
lines changed

3 files changed

+9
-131
lines changed

src/Aspire.Cli/Aspire.Cli.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
<PackageId>Aspire.Cli</PackageId>
2020
<RollForward>Major</RollForward>
2121
<PackageTags>aspire cli</PackageTags>
22+
<DefineConstants>$(DefineConstants);CLI</DefineConstants>
2223
<Description>Command line tool for Aspire developers.</Description>
2324
<!-- TODO: https://github.com/dotnet/aspire/issues/8677 - enable PublishAot when the build infrastructure supports all platforms. -->
24-
<!--<PublishAot>true</PublishAot>-->
25+
<!--<PublishAot>true</PublishAot>-->
2526
<!--JsonSerializerIsReflectionEnabledByDefault can be removed when PublishAot is enabled. -->
2627
<JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault>
2728
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
@@ -43,6 +44,7 @@
4344
<Compile Include="$(SharedDir)PathNormalizer.cs" Link="Utils\PathNormalizer.cs" />
4445
<Compile Include="$(SharedDir)CircularBuffer.cs" Link="Utils\CircularBuffer.cs" />
4546
<Compile Include="$(SharedDir)StringComparers.cs" Link="StringComparers.cs" />
47+
<Compile Include="$(RepoRoot)src\Aspire.Hosting\Backchannel\BackchannelDataTypes.cs" Link="Backchannel\BackchannelDataTypes.cs" />
4648
</ItemGroup>
4749

4850
<ItemGroup>

src/Aspire.Cli/Backchannel/BackchannelDataTypes.cs

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,6 @@
55

66
namespace Aspire.Cli.Backchannel;
77

8-
/// <summary>
9-
/// Represents the state of a resource reported via RPC.
10-
/// </summary>
11-
internal sealed class RpcResourceState
12-
{
13-
/// <summary>
14-
/// Gets the name of the resource.
15-
/// </summary>
16-
public required string Resource { get; init; }
17-
18-
/// <summary>
19-
/// Gets the type of the resource.
20-
/// </summary>
21-
public required string Type { get; init; }
22-
23-
/// <summary>
24-
/// Gets the state of the resource.
25-
/// </summary>
26-
public required string State { get; init; }
27-
28-
/// <summary>
29-
/// Gets the endpoints associated with the resource.
30-
/// </summary>
31-
public required string[] Endpoints { get; init; }
32-
33-
/// <summary>
34-
/// Gets the health status of the resource.
35-
/// </summary>
36-
public string? Health { get; init; }
37-
}
38-
39-
/// <summary>
40-
/// Represents dashboard URLs with authentication tokens.
41-
/// </summary>
42-
internal sealed class DashboardUrlsState
43-
{
44-
/// <summary>
45-
/// Gets the base dashboard URL with a login token.
46-
/// </summary>
47-
public required string BaseUrlWithLoginToken { get; init; }
48-
49-
/// <summary>
50-
/// Gets the Codespaces dashboard URL with a login token, if available.
51-
/// </summary>
52-
public string? CodespacesUrlWithLoginToken { get; init; }
53-
}
54-
558
/// <summary>
569
/// Represents a single line of output to be displayed, along with its associated stream (such as "stdout" or "stderr").
5710
/// </summary>
@@ -68,78 +21,6 @@ internal sealed class DisplayLineState(string stream, string line)
6821
public string Line { get; } = line;
6922
}
7023

71-
/// <summary>
72-
/// Envelope for publishing activity items sent over the backchannel.
73-
/// </summary>
74-
internal sealed class PublishingActivity
75-
{
76-
/// <summary>
77-
/// Gets the type discriminator for the publishing activity item.
78-
/// </summary>
79-
public required string Type { get; init; }
80-
81-
/// <summary>
82-
/// Gets the data containing all properties for the publishing activity item.
83-
/// </summary>
84-
public required PublishingActivityData Data { get; init; }
85-
}
86-
87-
/// <summary>
88-
/// Common data for all publishing activity items.
89-
/// </summary>
90-
internal sealed class PublishingActivityData
91-
{
92-
/// <summary>
93-
/// Gets the unique identifier for the publishing activity.
94-
/// </summary>
95-
public required string Id { get; init; }
96-
97-
/// <summary>
98-
/// Gets the status text describing the publishing activity.
99-
/// </summary>
100-
public required string StatusText { get; init; }
101-
102-
/// <summary>
103-
/// Gets the completion state of the publishing activity.
104-
/// </summary>
105-
public string CompletionState { get; init; } = CompletionStates.InProgress;
106-
107-
/// <summary>
108-
/// Gets a value indicating whether the publishing activity is complete.
109-
/// </summary>
110-
public bool IsComplete => CompletionState is not CompletionStates.InProgress;
111-
112-
/// <summary>
113-
/// Gets a value indicating whether the publishing activity encountered an error.
114-
/// </summary>
115-
public bool IsError => CompletionState is CompletionStates.CompletedWithError;
116-
117-
/// <summary>
118-
/// Gets a value indicating whether the publishing activity completed with warnings.
119-
/// </summary>
120-
public bool IsWarning => CompletionState is CompletionStates.CompletedWithWarning;
121-
122-
/// <summary>
123-
/// Gets the identifier of the step this task belongs to (only applicable for tasks).
124-
/// </summary>
125-
public string? StepId { get; init; }
126-
127-
/// <summary>
128-
/// Gets the completion message for the publishing activity (optional).
129-
/// </summary>
130-
public string? CompletionMessage { get; init; }
131-
}
132-
133-
/// <summary>
134-
/// Constants for publishing activity item types.
135-
/// </summary>
136-
internal static class PublishingActivityTypes
137-
{
138-
public const string Step = "step";
139-
public const string Task = "task";
140-
public const string PublishComplete = "publish-complete";
141-
}
142-
14324
internal class BackchannelLogEntry
14425
{
14526
public required EventId EventId { get; set; }
@@ -148,14 +29,3 @@ internal class BackchannelLogEntry
14829
public required DateTimeOffset Timestamp { get; set; }
14930
public required string CategoryName { get; set; }
15031
}
151-
152-
/// <summary>
153-
/// Constants for completion state values.
154-
/// </summary>
155-
internal static class CompletionStates
156-
{
157-
public const string InProgress = "InProgress";
158-
public const string Completed = "Completed";
159-
public const string CompletedWithWarning = "CompletedWithWarning";
160-
public const string CompletedWithError = "CompletedWithError";
161-
}

src/Aspire.Hosting/Backchannel/BackchannelDataTypes.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
// These types are source shared between the CLI and the Aspire.Hosting projects.
5+
// The CLI sets the types in its own namespace.
6+
#if CLI
7+
namespace Aspire.Cli.Backchannel;
8+
#else
49
namespace Aspire.Hosting.Backchannel;
10+
#endif
511

612
/// <summary>
713
/// Represents the state of a resource reported via RPC.

0 commit comments

Comments
 (0)