Conversation
|
|
Co-authored-by: ejsmith <282584+ejsmith@users.noreply.github.com>
Co-authored-by: ejsmith <282584+ejsmith@users.noreply.github.com>
Comment on lines
+253
to
+295
| foreach (var syntaxRef in symbol.DeclaringSyntaxReferences) | ||
| { | ||
| if (syntaxRef.GetSyntax() is not CSharpSyntaxNode syntaxNode) | ||
| continue; | ||
|
|
||
| var docTrivia = syntaxNode.GetLeadingTrivia() | ||
| .Select(t => t.GetStructure()) | ||
| .OfType<DocumentationCommentTriviaSyntax>() | ||
| .FirstOrDefault(); | ||
|
|
||
| if (docTrivia == null) | ||
| { | ||
| var summaryFromSourceText = ParseSummaryFromSourceText(syntaxRef); | ||
| if (!String.IsNullOrWhiteSpace(summaryFromSourceText)) | ||
| return summaryFromSourceText; | ||
|
|
||
| continue; | ||
| } | ||
|
|
||
| var summaryElement = docTrivia.Content | ||
| .OfType<XmlElementSyntax>() | ||
| .FirstOrDefault(e => String.Equals(e.StartTag?.Name.ToString(), "summary", StringComparison.Ordinal)); | ||
|
|
||
| if (summaryElement != null) | ||
| { | ||
| var summaryText = String.Join(" ", summaryElement.Content | ||
| .OfType<XmlTextSyntax>() | ||
| .SelectMany(t => t.TextTokens) | ||
| .Select(tt => tt.Text.Trim()) | ||
| .Where(t => t.Length > 0)); | ||
|
|
||
| if (!String.IsNullOrWhiteSpace(summaryText)) | ||
| return summaryText; | ||
| } | ||
|
|
||
| var summaryFromRaw = ParseSummaryFromRaw(docTrivia.ToFullString()); | ||
| if (!String.IsNullOrWhiteSpace(summaryFromRaw)) | ||
| return summaryFromRaw; | ||
|
|
||
| var summaryFromSource = ParseSummaryFromSourceText(syntaxRef); | ||
| if (!String.IsNullOrWhiteSpace(summaryFromSource)) | ||
| return summaryFromSource; | ||
| } |
Comment on lines
+305
to
+330
| foreach (var attribute in symbol.GetAttributes()) | ||
| { | ||
| if (attribute.AttributeClass is not { } attributeClass) | ||
| continue; | ||
|
|
||
| if (!IsCategoryAttribute(attributeClass)) | ||
| continue; | ||
|
|
||
| if (attribute.ConstructorArguments.Length > 0) | ||
| { | ||
| foreach (var arg in attribute.ConstructorArguments) | ||
| { | ||
| if (arg.Value is string category && !String.IsNullOrWhiteSpace(category)) | ||
| return category; | ||
| } | ||
| } | ||
|
|
||
| if (attribute.NamedArguments.Length > 0) | ||
| { | ||
| foreach (var arg in attribute.NamedArguments) | ||
| { | ||
| if (arg.Value.Value is string namedCategory && !String.IsNullOrWhiteSpace(namedCategory)) | ||
| return namedCategory; | ||
| } | ||
| } | ||
| } |
Comment on lines
+315
to
+319
| foreach (var arg in attribute.ConstructorArguments) | ||
| { | ||
| if (arg.Value is string category && !String.IsNullOrWhiteSpace(category)) | ||
| return category; | ||
| } |
Comment on lines
+324
to
+328
| foreach (var arg in attribute.NamedArguments) | ||
| { | ||
| if (arg.Value.Value is string namedCategory && !String.IsNullOrWhiteSpace(namedCategory)) | ||
| return namedCategory; | ||
| } |
Comment on lines
+398
to
+406
| foreach (var line in lines) | ||
| { | ||
| var trimmed = line.Trim(); | ||
| if (!trimmed.StartsWith("///", StringComparison.Ordinal)) | ||
| continue; | ||
|
|
||
| var content = trimmed.Length > 3 ? trimmed.Substring(3).TrimStart() : String.Empty; | ||
| builder.AppendLine(content); | ||
| } |
Comment on lines
+439
to
+442
| catch | ||
| { | ||
| return null; | ||
| } |
Comment on lines
+396
to
+405
| if (needsAsync) | ||
| { | ||
| methodReturnType = returnsValue | ||
| ? $"System.Threading.Tasks.ValueTask<{defaultReturnType}>" | ||
| : "System.Threading.Tasks.ValueTask"; | ||
| } | ||
| else | ||
| { | ||
| methodReturnType = returnsValue ? defaultReturnType : "void"; | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces significant enhancements to the
ConsoleSampleproject, adding first-class support for Minimal APIs and OpenAPI documentation, as well as improving the codebase for better maintainability and extensibility. The changes include the addition of a new endpoint generator, improved message documentation, and updates to dependencies to enable web API features.Minimal API and OpenAPI integration:
Microsoft.AspNetCore.OpenApi,Scalar.AspNetCore) and a framework reference toMicrosoft.AspNetCore.AppinConsoleSample.csprojto enable Minimal API and OpenAPI support. Removed now-unnecessaryMicrosoft.Extensions.*packages.Program.csto detect a--webargument and launch a Minimal API host with OpenAPI and Scalar API reference endpoints. Added endpoint registration viaMapMediatorEndpoints. [1] [2]Endpoint generation and handler analysis:
EndpointGeneratorinsrc/Foundatio.Mediator/EndpointGenerator.csthat generates Minimal API endpoints for mediator messages following CRUD naming conventions. Endpoints are grouped by category, support OpenAPI, and map mediator results to HTTP responses.HandlerAnalyzer.csto extract category information and pass it to the endpoint generator, enabling logical grouping of endpoints. [1] [2] [3]Message documentation improvements:
Messages.cs, improving generated API documentation and endpoint summaries. [1] [2]Other improvements:
These changes collectively modernize the sample project, providing a robust foundation for building web APIs with mediator-based message handling, complete with discoverable and well-documented endpoints.