From b6fde1a42bda177288737cbc726a62af43f6a1f1 Mon Sep 17 00:00:00 2001 From: Timothy Miller Date: Mon, 2 Dec 2024 16:00:35 +0900 Subject: [PATCH] Fix GetBlob to return byte[] --- .../Lexicon/Com/Atproto/Sync/ATProtoSync.g.cs | 2 +- .../Lexicon/Com/Atproto/Sync/SyncEndpoints.g.cs | 6 +++--- tools/FFSourceGen/Program.cs | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/FishyFlip/Lexicon/Com/Atproto/Sync/ATProtoSync.g.cs b/src/FishyFlip/Lexicon/Com/Atproto/Sync/ATProtoSync.g.cs index 6202b238..919e3bac 100644 --- a/src/FishyFlip/Lexicon/Com/Atproto/Sync/ATProtoSync.g.cs +++ b/src/FishyFlip/Lexicon/Com/Atproto/Sync/ATProtoSync.g.cs @@ -42,7 +42,7 @@ internal ATProtoSync(ATProtocol atp) /// /// /// - public Task> GetBlobAsync (FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default) + public Task> GetBlobAsync (FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default) { return atp.GetBlobAsync(did, cid, cancellationToken); } diff --git a/src/FishyFlip/Lexicon/Com/Atproto/Sync/SyncEndpoints.g.cs b/src/FishyFlip/Lexicon/Com/Atproto/Sync/SyncEndpoints.g.cs index 290c6df9..d24cf242 100644 --- a/src/FishyFlip/Lexicon/Com/Atproto/Sync/SyncEndpoints.g.cs +++ b/src/FishyFlip/Lexicon/Com/Atproto/Sync/SyncEndpoints.g.cs @@ -47,8 +47,8 @@ public static class SyncEndpoints /// /// /// - /// Result of - public static Task> GetBlobAsync (this FishyFlip.ATProtocol atp, FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default) + /// Result of + public static Task> GetBlobAsync (this FishyFlip.ATProtocol atp, FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default) { var endpointUrl = GetBlob.ToString(); endpointUrl += "?"; @@ -58,7 +58,7 @@ public static class SyncEndpoints queryStrings.Add("cid=" + cid); endpointUrl += string.Join("&", queryStrings); - return atp.Client.Get(endpointUrl, atp.Options.SourceGenerationContext.Success!, atp.Options.JsonSerializerOptions, cancellationToken, atp.Options.Logger); + return atp.Client.GetBlob(endpointUrl, SourceGenerationContext.Default.Options, cancellationToken, atp.Options.Logger); } diff --git a/tools/FFSourceGen/Program.cs b/tools/FFSourceGen/Program.cs index b28dace0..a14ebaf8 100644 --- a/tools/FFSourceGen/Program.cs +++ b/tools/FFSourceGen/Program.cs @@ -1201,6 +1201,11 @@ private async Task GenerateEndpointGroupAsync(IGrouping sb.AppendLine( $" return atp.Client.GetCarAsync(endpointUrl, atp.Options.JsonSerializerOptions, cancellationToken, atp.Options.Logger, onDecoded);"); } + else if (outputProperty == "byte[]") + { + sb.AppendLine( + $" return atp.Client.GetBlob(endpointUrl, SourceGenerationContext.Default.Options, cancellationToken, atp.Options.Logger);"); + } else { sb.AppendLine( @@ -1371,6 +1376,11 @@ private string PropertyNameToCSharpSafeValue(string propertyName) private string FetchOutputProperties(ClassGeneration classGeneration) { + if (classGeneration.Definition.Output?.Encoding == "*/*") + { + return "byte[]"; + } + if (classGeneration.Definition.Output?.Schema is null) { return "Success";