CustomAPI Request and Response class generation#68
Open
mkholt wants to merge 8 commits into
Open
Conversation
…t is environment specific - instead fetch base on the customapi table Fix: Generated Request / Response classes should use the unique name, not the name (naming is weird in Dataverse, but unique is actually only unique per-API)
…e generation logic - that's what Scriban was pushing towards Fix: Single-line comment should be preceded by blank line
There was a problem hiding this comment.
Pull request overview
This PR updates Custom API metadata fetching and code generation so that Custom API Request/Response classes are generated using environment-agnostic metadata queries and the Custom API unique name (instead of display/name fields). It also migrates the generator pipeline to IAsyncEnumerable and updates template loading/rendering to async APIs (Scriban 7.x).
Changes:
- Fetch Custom APIs by querying the
customapitable (solution-scoped) rather than relying on environment-specific component ObjectTypeCode assumptions. - Generate Custom API Request/Response code using
UniqueNamefor class naming and parameter/result keys, and add richer response constructors. - Convert code generation + output writing pipeline to async (
IAsyncEnumerable) and update templates/tests accordingly.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/DataverseProxyGenerator.Tests/SingleFileTemplateTests.cs | Updates tests to use async code generation APIs. |
| tests/DataverseProxyGenerator.Tests/RetrieveMethodTests.cs | Migrates generator usage to GenerateCodeAsync + async LINQ enumeration. |
| tests/DataverseProxyGenerator.Tests/EnumGeneratorDuplicateTests.cs | Migrates enum generator tests to async generator API. |
| tests/DataverseProxyGenerator.Tests/DataverseProxyGenerator.Tests.csproj | Adds async-enumerable LINQ package dependency for async test enumeration. |
| tests/DataverseProxyGenerator.Tests/CustomApiMapperTests.cs | Adds unit coverage for Custom API type mapping + XML doc mapping. |
| tests/DataverseProxyGenerator.Tests/CustomApiGeneratorTests.Generates_Request_And_Response_For_All_Parameter_Types.verified.txt | Adds verified snapshot for generated Custom API request/response output. |
| tests/DataverseProxyGenerator.Tests/CustomApiGeneratorTests.cs | Adds/updates Custom API generator tests for naming, ctor behavior, nullability behavior. |
| tests/DataverseProxyGenerator.Tests/AttributeTypeCodeGenTests.cs | Updates attribute codegen test to async codegen enumeration. |
| src/DataverseProxyGenerator.Tool/Program.cs | Switches tool workflow to async generation + async file writing. |
| src/DataverseProxyGenerator.Core/Templates/EmbeddedTemplateProvider.cs | Converts template loading to async, implements Scriban loader async support. |
| src/DataverseProxyGenerator.Core/Templates/Body/CustomApiRequest.scriban-cs | Updates request template to use unique parameter names and new access patterns. |
| src/DataverseProxyGenerator.Core/Templates/Body/CustomApiResponse.scriban-cs | Updates response template to use unique property names and adds a convenience ctor. |
| src/DataverseProxyGenerator.Core/OutputWriter/IOutputWriter.cs | Changes output writer contract to async (WriteFilesAsync(IAsyncEnumerable<GeneratedFile>, ...)). |
| src/DataverseProxyGenerator.Core/OutputWriter/FileSystemOutputWriter.cs | Implements async file writing and async enumeration of generated files. |
| src/DataverseProxyGenerator.Core/Metadata/DataverseMetadataFetcher.cs | Refactors Custom API fetching to query customapi records linked to a solution and then load params/properties. |
| src/DataverseProxyGenerator.Core/Generation/Utilities/TypeSignatureHelper.cs | Formatting-only change. |
| src/DataverseProxyGenerator.Core/Generation/Mappers/ProxyClassMapper.cs | Formatting-only change. |
| src/DataverseProxyGenerator.Core/Generation/Mappers/CustomApiMapper.cs | Switches mapping to UniqueName-based identifiers and adds nullability-aware C# type mapping. |
| src/DataverseProxyGenerator.Core/Generation/IFileGenerator.cs | Changes generator contract to GenerateAsync returning IAsyncEnumerable<GeneratedFile>. |
| src/DataverseProxyGenerator.Core/Generation/ICodeGenerator.cs | Changes top-level generator contract to async (GenerateCodeAsync). |
| src/DataverseProxyGenerator.Core/Generation/Generators/XrmContextGenerator.cs | Updates generator to async template loading + RenderAsync. |
| src/DataverseProxyGenerator.Core/Generation/Generators/SingleFileGenerator.cs | Updates generator to async template loading + RenderAsync. |
| src/DataverseProxyGenerator.Core/Generation/Generators/ProxyClassGenerator.cs | Updates generator to async template loading + RenderAsync. |
| src/DataverseProxyGenerator.Core/Generation/Generators/IntersectionInterfaceGenerator.cs | Updates generator to async template loading + RenderAsync. |
| src/DataverseProxyGenerator.Core/Generation/Generators/HelperFileGenerator.cs | Updates generator to async template loading + RenderAsync. |
| src/DataverseProxyGenerator.Core/Generation/Generators/EnumGenerator.cs | Updates generator to async template loading + RenderAsync. |
| src/DataverseProxyGenerator.Core/Generation/Generators/CustomApiGenerator.cs | Adds async generation of 2 files per Custom API (request + response). |
| src/DataverseProxyGenerator.Core/Generation/CSharpProxyGenerator.cs | Converts multi-file generation orchestration to IAsyncEnumerable pipeline. |
| src/DataverseProxyGenerator.Core/Domain/CustomApiModel.cs | Adds Id and modernizes list initialization. |
| src/DataverseProxyGenerator.Core/DataverseProxyGenerator.Core.csproj | Upgrades Scriban and adds async-enumerable LINQ package dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…r (that we sohuld never hit)
skovlund
reviewed
Jul 13, 2026
skovlund
reviewed
Jul 13, 2026
skovlund
approved these changes
Jul 13, 2026
…ptive. Make the function more resilient (handle single-char names)
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.
Fix: CustomAPI fetch logic assumed a specific ObjectTypeCode, but that is environment specific - instead fetch base on the customapi table
Fix: Generated Request / Response classes should use the unique name, not the name (naming is weird in Dataverse, but unique is actually only unique per-API)
Chore: Update Scriban to newest stable without vulnerabilities and moving to an async-end-to-end logic when generating files