-
Notifications
You must be signed in to change notification settings - Fork 893
Enrich AppHost codegen TypeLoadException diagnostics #17262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c9366b5
Enrich AppHost codegen TypeLoadException diagnostics (#16709)
IEvangelist 9760504
Address PR review feedback for #16709
IEvangelist b1e3bac
Fix stale CLI socket cleanup matching
sebastienros 0ee9003
Address PR feedback on codegen diagnostics
IEvangelist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/Aspire.Cli/Projects/AppHostCodeGenerationDiagnostic.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Cli.Projects; | ||
|
|
||
| /// <summary> | ||
| /// JSON-RPC error codes returned by the AppHost server for code-generation failures. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Values mirror those defined server-side in <c>Aspire.Hosting.RemoteHost</c>. | ||
| /// </remarks> | ||
| internal static class AppHostCodeGenerationErrorCodes | ||
| { | ||
| /// <summary> | ||
| /// The AppHost server failed to load reflection-based code generation metadata. | ||
| /// Typically caused by an assembly-version mismatch between the bundled | ||
| /// <c>Aspire.Hosting</c> runtime and the user-restored integration assemblies. | ||
| /// </summary> | ||
| public const int IncompatibleAspireSdk = -32050; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// CLI-side representation of the structured diagnostic payload the AppHost server attaches to | ||
| /// code-generation failures (mirrors <c>CodeGenerationDiagnostic</c> in | ||
| /// <c>Aspire.Hosting.RemoteHost</c>). The JSON shape is contractual; updating one side without | ||
| /// the other will break the round-trip. | ||
| /// </summary> | ||
| internal sealed class AppHostCodeGenerationDiagnostic | ||
| { | ||
| /// <summary> | ||
| /// Gets the CLR type name of the original exception thrown by the AppHost server | ||
| /// (e.g. <c>System.TypeLoadException</c>). | ||
| /// </summary> | ||
| public string OriginalExceptionType { get; init; } = ""; | ||
|
|
||
| /// <summary> | ||
| /// Gets the name of the type that failed to load, if known. | ||
| /// </summary> | ||
| public string? TypeName { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the name of the missing member, if the failure was a missing-method or | ||
| /// missing-field error. | ||
| /// </summary> | ||
| public string? MemberName { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the informational version of the bundled <c>Aspire.Hosting</c> assembly on the | ||
| /// server side, if it could be discovered. | ||
| /// </summary> | ||
| public string? RuntimeAspireHostingVersion { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the on-disk location of the bundled <c>Aspire.Hosting</c> assembly, if it could be | ||
| /// discovered. | ||
| /// </summary> | ||
| public string? RuntimeAspireHostingPath { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the loaded integration assemblies probed by the AppHost server at the time of the | ||
| /// failure. | ||
| /// </summary> | ||
| public List<AppHostLoadedAssemblyInfo> LoadedAssemblies { get; init; } = []; | ||
|
|
||
| /// <summary> | ||
| /// Gets a short, language-agnostic remediation hint suitable for surfacing to AppHost | ||
| /// authors. | ||
| /// </summary> | ||
| public string? RemediationHint { get; init; } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Identity information for a single loaded assembly captured at the time of a code-generation | ||
| /// failure. | ||
| /// </summary> | ||
| internal sealed class AppHostLoadedAssemblyInfo | ||
| { | ||
| /// <summary> | ||
| /// Gets the simple name of the assembly (e.g. <c>Aspire.Hosting.JavaScript</c>). | ||
| /// </summary> | ||
| public string Name { get; init; } = ""; | ||
|
|
||
| /// <summary> | ||
| /// Gets the informational version of the assembly, when present, otherwise the assembly | ||
| /// version. | ||
| /// </summary> | ||
| public string? InformationalVersion { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the on-disk location of the assembly when available. | ||
| /// </summary> | ||
| public string? Location { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Cli.Projects; | ||
|
|
||
| /// <summary> | ||
| /// Thrown by <see cref="AppHostRpcClient"/> when the AppHost server reports a reflection-based | ||
| /// code-generation failure. Carries a structured <see cref="AppHostCodeGenerationDiagnostic"/> | ||
| /// payload supplied by the server so the CLI can render an actionable, tiered diagnostic. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The <see cref="Exception.Message"/> always contains the short, language-agnostic message the | ||
| /// server produced; the full structured payload — including .NET-specific identifiers such as | ||
| /// type names and assembly identities — is exposed via <see cref="Diagnostic"/> and is only | ||
| /// rendered to the user when <c>--debug</c> is supplied. | ||
| /// </remarks> | ||
| internal sealed class AppHostCodeGenerationException : Exception | ||
| { | ||
| public AppHostCodeGenerationException(string message, AppHostCodeGenerationDiagnostic diagnostic, Exception? innerException = null) | ||
| : base(message, innerException) | ||
| { | ||
| Diagnostic = diagnostic; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the structured diagnostic payload that accompanied the RPC failure. | ||
| /// </summary> | ||
| public AppHostCodeGenerationDiagnostic Diagnostic { get; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.