Skip to content

CustomAPI Request and Response class generation#68

Open
mkholt wants to merge 8 commits into
rewritefrom
customapi-request-response-classes
Open

CustomAPI Request and Response class generation#68
mkholt wants to merge 8 commits into
rewritefrom
customapi-request-response-classes

Conversation

@mkholt

@mkholt mkholt commented Jul 10, 2026

Copy link
Copy Markdown
Member

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

mkholt added 4 commits July 10, 2026 11:44
…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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 customapi table (solution-scoped) rather than relying on environment-specific component ObjectTypeCode assumptions.
  • Generate Custom API Request/Response code using UniqueName for 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.

Comment thread tests/DataverseProxyGenerator.Tests/CustomApiGeneratorTests.cs
@mkholt mkholt requested a review from skovlund July 10, 2026 12:06
Comment thread src/DataverseProxyGenerator.Core/Generation/Mappers/CustomApiMapper.cs Outdated
Comment thread src/DataverseProxyGenerator.Core/Generation/Mappers/CustomApiMapper.cs Outdated
…ptive. Make the function more resilient (handle single-char names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants