{"record":{"id":"83d09a3d4152c45b","repo":"microsoft/aspire","slug":"builder-gettype-fullname-is-missing-appendliteral-string","errorCode":null,"errorMessage":"'{builder.GetType().FullName}' is missing AppendLiteral(string).","messagePattern":"'(.+?)' is missing AppendLiteral\\(string\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.RemoteHost/Ats/ReferenceExpressionRef.cs","lineNumber":334,"sourceCode":"        return [.. parts];\n    }\n\n    private static object CreateReferenceExpressionBuilder()\n    {\n        var builderType = GetRequiredHostingType(HostingTypeNames.ReferenceExpressionBuilder);\n        return Activator.CreateInstance(builderType)\n            ?? throw new InvalidOperationException($\"Failed to create '{builderType.FullName}'.\");\n    }\n\n    private static void AppendLiteral(object builder, string value)\n    {\n        var appendLiteralMethod = builder.GetType().GetMethod(\n            \"AppendLiteral\",\n            BindingFlags.Instance | BindingFlags.Public,\n            binder: null,\n            [typeof(string)],\n            modifiers: null)\n            ?? throw new InvalidOperationException($\"'{builder.GetType().FullName}' is missing AppendLiteral(string).\");\n\n        appendLiteralMethod.Invoke(builder, [value]);\n    }\n\n    private static void AppendValueProvider(object builder, object valueProvider)\n    {\n        var appendValueProviderMethod = builder.GetType().GetMethod(\n            \"AppendValueProvider\",\n            BindingFlags.Instance | BindingFlags.Public,\n            binder: null,\n            [typeof(object), typeof(string)],\n            modifiers: null)\n            ?? throw new InvalidOperationException($\"'{builder.GetType().FullName}' is missing AppendValueProvider(object, string).\");\n\n        appendValueProviderMethod.Invoke(builder, [valueProvider, null]);\n    }\n\n    private static object BuildReferenceExpression(object builder)","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.RemoteHost/Ats/ReferenceExpressionRef.cs#L316-L352","documentation":"AppendLiteral reflectively locates a public instance AppendLiteral(string) method on the ReferenceExpression.Builder instance. If the method is not found (renamed, non-public, removed, or wrong object passed in), the code throws this InvalidOperationException naming the builder's type.","triggerScenarios":"ToValueReferenceExpression calls AppendLiteral(builder, value) and builder.GetType().GetMethod(\"AppendLiteral\", Public|Instance, types: [typeof(string)]) returns null.","commonSituations":"Passing a ReferenceExpression (built) instead of the Builder to AppendLiteral; Aspire.Hosting version where Builder.AppendLiteral signature changed; trimming removed the method.","solutions":["Ensure you pass the un-built ReferenceExpression.Builder object, not a built ReferenceExpression.","Align the Aspire.Hosting package version with the one RemoteHost expects.","If trimming/AOT, preserve Builder.AppendLiteral via [DynamicDependency].","Confirm the string argument is a string (the lookup targets exactly AppendLiteral(string))."],"exampleFix":"// before\nvar expression = ReferenceExpression.Create(...);\nAppendLiteral(expression, \"literal\"); // wrong object\n\n// after\nvar builder = CreateReferenceExpressionBuilder();\nAppendLiteral(builder, \"literal\");","handlingStrategy":"type-guard","validationCode":"var m = builder.GetType().GetMethod(\"AppendLiteral\", BindingFlags.Instance | BindingFlags.Public, null, [typeof(string)], null);\nif (m is null)\n    throw new NotSupportedException($\"{builder.GetType().FullName} lacks AppendLiteral(string); pass a ReferenceExpression.Builder, not a built expression.\");","typeGuard":"static bool SupportsAppendLiteral(object builder) =>\n    builder.GetType().GetMethod(\"AppendLiteral\", BindingFlags.Instance | BindingFlags.Public, null, [typeof(string)], null) is not null;","tryCatchPattern":"try\n{\n    AppendLiteral(builder, value);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"missing AppendLiteral\"))\n{\n    logger.LogError(ex, \"Builder surface mismatch on {Type}\", builder.GetType().FullName);\n}","preventionTips":["Only pass ReferenceExpression.Builder instances to Append* helpers — never built ReferenceExpression objects.","Version-align Aspire.Hosting with the RemoteHost code.","Add unit tests that exercise AppendLiteral via the real builder to catch API drift early.","Preserve Aspire.Hosting reflection targets when trimming."],"tags":["reflection","reference-expression","missing-method"],"backgroundTag":"method-not-implemented","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}