Skip to content

Declare server-consumed command response types - #2540

Merged
woksin merged 4 commits into
mainfrom
fix/command-handled-response-proxies-v2
Aug 13, 2026
Merged

Declare server-consumed command response types#2540
woksin merged 4 commits into
mainfrom
fix/command-handled-response-proxies-v2

Conversation

@woksin

@woksin woksin commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Command response value handlers can now declare the response type they consume, and the proxy generator uses these declarations to stop generating client response models for values that are handled on the server and never reach the client.

Added

Changed

Fixed

  • Generated TypeScript import statements for generic types now reference the correct proxy file name

@woksin woksin added the minor label Aug 13, 2026
/// <returns>True if the value is handled on the server and should not be exposed as a client response.</returns>
public static bool IsServerHandledCommandResponseValue(this Type type)
{
var isFromCurrentMetadataContext = _metadataLoadContext?.GetAssemblies().Contains(type.Assembly) == true;
var version = Path.GetFileName(root)!;
var framework = Directory.GetParent(root)!;
var shared = Directory.GetParent(framework.FullName)!;
var aspNetCoreAppPath = Path.Combine(shared.FullName, "Microsoft.AspNetCore.App", version);
Comment on lines +1284 to +1287
var nugetCachePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
".nuget",
"packages");
".nuget",
"packages");

var fullPath = Path.Combine(nugetCachePath, fundamentalsPackage.Path!, assetPaths[0]);

void Establish()
{
_invalidAssemblyFile = Path.Combine(Path.GetTempPath(), $"proxy-generator-invalid-{Guid.NewGuid():N}.dll");
void Establish()
{
_invalidAssemblyFile = Path.Combine(Path.GetTempPath(), $"proxy-generator-invalid-{Guid.NewGuid():N}.dll");
_outputPath = Path.Combine(Path.GetTempPath(), $"proxy-generator-output-{Guid.NewGuid():N}");

void Establish()
{
_invalidAssemblyFile = Path.Combine(Path.GetTempPath(), $"proxy-generator-invalid-{Guid.NewGuid():N}.dll");
@woksin
woksin merged commit 85fa7fa into main Aug 13, 2026
58 checks passed
@woksin
woksin deleted the fix/command-handled-response-proxies-v2 branch August 13, 2026 00:38
@woksin

woksin commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Reviewer context moved out of the description (release notes are generated from it):

Internal changes (no user-facing effect): metadata load-context ownership is bounded to each generator invocation; dynamically-registered handlers stay runtime-only so ordinary DTO responses are not suppressed; SSH.NET pinned past GHSA-q939-rpr3-3284 (transitive test-only dependency via Testcontainers); proxy generator test artifacts added to the solution graph.

Verification (from the original description):

  • Debug ProxyGenerator.Specs build: 0 warnings, 0 errors
  • Focused response/discovery/lifecycle filter: 37/37
  • Full Debug ProxyGenerator.Specs: 1141/1141 before the final counterfeit-contract negative
  • Release build (net8/net9/net10): 0 warnings, 0 errors
  • Final full Release net10 ProxyGenerator.Specs: 1143/1143
  • Independent code/compatibility and security reviews: approved
  • git diff --check: clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant