Skip to content

Add DebuggerDisplayAttribute to CustomResourceSnapshot Collections#7012

Merged
JamesNK merged 2 commits intomicrosoft:mainfrom
afscrome:debugdisplay
Jan 7, 2025
Merged

Add DebuggerDisplayAttribute to CustomResourceSnapshot Collections#7012
JamesNK merged 2 commits intomicrosoft:mainfrom
afscrome:debugdisplay

Conversation

@afscrome
Copy link
Copy Markdown
Collaborator

@afscrome afscrome commented Jan 2, 2025

Description

Adds debugger display attributes to collection types in CustomResourceSnapshot.
This makes it easier to view the resource event snapshots in the debugger.

Before:
before

After:
after

The above screenshots were produces with the following code:

var builder = DistributedApplication.CreateBuilder(args);

var other = builder.AddExecutable("other", "cmd.exe", ".");

var redis = builder.AddRedis("redis")
    .WithDataVolume()
    .WithBindMount("c:\\temp", "/mnt/tmp")
    .WithRelationship(other.Resource, "Relationship Type");

builder.Eventing.Subscribe<ResourceReadyEvent>(redis.Resource, (evt, ct) =>
{
    var _ = Task.Run(async () =>
    {
        await foreach (var resourceEvent in evt.Services.GetRequiredService<ResourceNotificationService>().WatchAsync(ct))
        {
            if (resourceEvent.Resource.Name == "redis")
            {
                // Set Breakpoint Here
            }
        }
    }, ct);

    return Task.CompletedTask;
});

builder.Build().Run();

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Microsoft Reviewers: Open in CodeFlow

Adds debugger display attributes to collection types in `CustomResourceSnapshot`.
This makes it easier to view the resource event snapshots in the debugger.
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jan 2, 2025
Comment thread src/Aspire.Hosting/ApplicationModel/CustomResourceSnapshot.cs Outdated
Comment thread src/Aspire.Hosting/ApplicationModel/CustomResourceSnapshot.cs Outdated
Comment thread src/Aspire.Hosting/ApplicationModel/CustomResourceSnapshot.cs Outdated
Co-authored-by: James Newton-King <james@newtonking.com>
@afscrome
Copy link
Copy Markdown
Collaborator Author

afscrome commented Jan 6, 2025

Hi @JamesNK is there anything more I need to do to get this mergeable?

@JamesNK
Copy link
Copy Markdown
Member

JamesNK commented Jan 7, 2025

Looks good to me. Thanks.

@JamesNK JamesNK merged commit fa96117 into microsoft:main Jan 7, 2025
@afscrome afscrome deleted the debugdisplay branch January 8, 2025 13:58
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 8, 2025
@github-actions github-actions Bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants