Skip to content

Add non-generic version of DistributedApplicationTestingBuilder.CreateAsync#3875

Merged
DamianEdwards merged 4 commits intomainfrom
damianedwards/non-generic-testing-builder
Apr 23, 2024
Merged

Add non-generic version of DistributedApplicationTestingBuilder.CreateAsync#3875
DamianEdwards merged 4 commits intomainfrom
damianedwards/non-generic-testing-builder

Conversation

@DamianEdwards
Copy link
Copy Markdown
Member

@DamianEdwards DamianEdwards commented Apr 23, 2024

This was a bit harder than I had originally anticipated due to API compat requirements now that we're locked down for GA. Unfortunately that meant I had to perform some less-than-ideal gymnastics to share implementation and preserve API details across the existing generic version and new non-generic version (inner types that override members and forward to outer type, etc.).

This is a breaking change for GA to unwind the generics and simply have a generic version of the top level factory method.

Fixes #3874

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Apr 23, 2024
@DamianEdwards DamianEdwards marked this pull request as ready for review April 23, 2024 18:33
@DamianEdwards DamianEdwards added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Apr 23, 2024
Copy link
Copy Markdown
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 minor-ish comments. This looks good to me.

Comment thread src/Aspire.Hosting.Testing/DistributedApplicationFactory.cs Outdated
/// <typeparam name="TEntryPoint">
/// A type in the entry point assembly of the target Aspire AppHost. Typically, the Program class can be used.
/// </typeparam>
public class DistributedApplicationFactory<TEntryPoint> : IDisposable, IAsyncDisposable where TEntryPoint : class
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to continue to validate where TEntryPoint : class. Was that important?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why that was there honestly. @ReubenBond?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems just a carry over from WebApplicationFactory<TEntryPoint> which this was based on but I can't see a good reason why it's restricted there too. I don't think it matters too much. We can always loosen the generic type parameter constraint if we ever get feedback on it and folks aren't willing to use the Type overload.

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
@DamianEdwards
Copy link
Copy Markdown
Member Author

/backport to release/8.0

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8807909101

@github-actions
Copy link
Copy Markdown
Contributor

@DamianEdwards backporting to release/8.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Add non-generic DistributedApplicationFactory
.git/rebase-apply/patch:1072: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
A	src/Aspire.Hosting.Testing/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): src/Aspire.Hosting.Testing/PublicAPI.Unshipped.txt deleted in HEAD and modified in Add non-generic DistributedApplicationFactory. Version Add non-generic DistributedApplicationFactory of src/Aspire.Hosting.Testing/PublicAPI.Unshipped.txt left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add non-generic DistributedApplicationFactory
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Copy Markdown
Contributor

@DamianEdwards an error occurred while backporting to release/8.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@mitchdenny
Copy link
Copy Markdown
Member

LGTM!

@DamianEdwards DamianEdwards merged commit e96138f into main Apr 23, 2024
@DamianEdwards DamianEdwards deleted the damianedwards/non-generic-testing-builder branch April 23, 2024 23:05
@github-actions github-actions Bot locked and limited conversation to collaborators May 24, 2024
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 breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add non-generic overload of DistributedApplicationTestingBuilder.CreateAsync

3 participants