Skip to content

Commit cb4ac0a

Browse files
committed
Made repo models internal only and added a corresponding results record for public consumption in an attempt to avoid enums for trimming.
1 parent 564e8ff commit cb4ac0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+906
-210
lines changed

docs/docs/posting.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
Let's start off by creating a simple post with the `CreatePost()` method.
66

77
```c#
8-
AtProtoHttpResult<CreateRecordResponse> postResult =
9-
await agent.Post("Hello world!");
8+
var postResult = await agent.Post("Hello world!");
109

1110
if (postResult.Succeeded)
1211
{
@@ -63,7 +62,7 @@ If its false, the `StatusCode` property will contain the HTTP status code return
6362
error information the API returned.
6463

6564
```c#
66-
AtProtoHttpResult<CreateRecordResponse> postResult = await agent.Post("Hello world!");
65+
var postResult = await agent.Post("Hello world!");
6766

6867
if (postResult.Succeeded)
6968
{
@@ -88,7 +87,7 @@ For example, to delete the post you just made using the first code snippet above
8887
you got from creating the post, or the strong reference itself.
8988

9089
```c#
91-
HttpResult<Commit> deleteResult = await agent.DeletePost(postResult.Result.StrongReference.Uri);
90+
var deleteResult = await agent.DeletePost(postResult.Result.StrongReference.Uri);
9291
if (!deleteResult.Succeeded)
9392
{
9493
Console.ForegroundColor = ConsoleColor.Red;
@@ -128,23 +127,22 @@ var likeResult = await agent.Like(postStrongReference);
128127
Liking a post will return a `StrongReference` to the record for your like. You can use this strong reference to delete your like with `UndoLike()`.
129128

130129
```c#
131-
HttpResult<bool> undoResult = await agent.UndoLike(likeResult.Result);
130+
var undoResult = await agent.UndoLike(likeResult.Result);
132131
```
133132

134133
Reposting works in just the same way.
135134

136135
```c#
137-
HttpResult<StrongReference> repostResult = await agent.Repost(postReference);
138-
HttpResult<bool> undoRepostResult = await agent.UndoRepost(repostResult.Result);
136+
var repostResult = await agent.Repost(postReference);
137+
var undoRepostResult = await agent.UndoRepost(repostResult.Result);
139138
```
140139

141140
Quoting a post requires both the post strong reference, and the text you the quote post to contain.
142141
Deleting a post quoting another post is like deleting a regular post, you call `DeletePost`;
143142

144143
```c#
145-
HttpResult<StrongReference> quoteResult =
146-
await agent.Quote(postReference, "This is a quote of a post.");
147-
HttpResult<bool> deleteResult = await agent.DeleteQuote(quoteResult.Result!);
144+
var quoteResult = await agent.Quote(postReference, "This is a quote of a post.");
145+
var deleteResult = await agent.DeleteQuote(quoteResult.Result!);
148146
```
149147

150148
## <a name="postRelationships">Getting your relationships with a post</a>
@@ -168,8 +166,7 @@ The majority of the `Post()` APIs will try to detect links, mentions and hashtag
168166
`extractFacets` parameter to `false`. For example:
169167

170168
```c#
171-
var postResult =
172-
await agent.Post("Hello #beans");
169+
var postResult = await agent.Post("Hello #beans");
173170
```
174171

175172
This will result in a hashtag of beans being added to the post. Detection works for hashtags, @ mentions and for uris which begin with either
@@ -275,7 +272,7 @@ postBuilder.Append('.');
275272
var hashTag = new HashTag("beans");
276273
postBuilder.Append(hashTag);
277274

278-
AtProtoHttpResult<CreateRecordResponse> facetedCreatePostResponse =
275+
var facetedCreatePostResponse =
279276
await agent.Post(postBuilder, cancellationToken: cancellationToken);
280277
```
281278

@@ -311,7 +308,7 @@ using (MemoryStream ms = new())
311308
Once you have your byte array upload it using `UploadImage`:
312309

313310
```c#
314-
AtProtoHttpResult<EmbeddedImage> imageUploadResult = await agent.UploadImage(
311+
var imageUploadResult = await agent.UploadImage(
315312
imageAsBytes,
316313
"image/jpg",
317314
"The Bluesky Logo",
@@ -343,7 +340,7 @@ You can, of course, add images to a `PostBuilder`:
343340
```c#
344341
PostBuilder postBuilder = new("A reply with an image.");
345342

346-
AtProtoHttpResult<EmbeddedImage> imageUploadResult = await agent.UploadImage(
343+
var imageUploadResult = await agent.UploadImage(
347344
imageAsBytes,
348345
"image/jpg",
349346
"The Bluesky Logo",

samples/Samples.Posting/Program.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
107107

108108
{
109109
// Simple post creation and deletion.
110-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Hello world", cancellationToken: cancellationToken);
110+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Hello world", cancellationToken: cancellationToken);
111111
if (!createPostResult.Succeeded)
112112
{
113113
Console.ForegroundColor = ConsoleColor.Red;
@@ -133,7 +133,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
133133
// In the past post creation and deletion.
134134
DateTimeOffset past = DateTimeOffset.UtcNow.AddDays(-1);
135135

136-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Hello world from the past", createdAt: past, cancellationToken: cancellationToken);
136+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Hello world from the past", createdAt: past, cancellationToken: cancellationToken);
137137
if (!createPostResult.Succeeded)
138138
{
139139
Console.ForegroundColor = ConsoleColor.Red;
@@ -157,7 +157,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
157157

158158
{
159159
// Simple post creation with a detected hashtag.
160-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Hello world #helloWorld", cancellationToken: cancellationToken);
160+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Hello world #helloWorld", cancellationToken: cancellationToken);
161161
if (!createPostResult.Succeeded)
162162
{
163163
Console.ForegroundColor = ConsoleColor.Red;
@@ -181,21 +181,21 @@ static async Task PerformOperations(string? handle, string? password, string? au
181181

182182
{
183183
// Simple post creation and reply post creation.
184-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Another test post, this time to check replying.", cancellationToken: cancellationToken);
184+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Another test post, this time to check replying.", cancellationToken: cancellationToken);
185185
if (createPostResult.Succeeded)
186186
{
187187
// Let's pretend we didn't just create the post, and we just have the strong reference of the post we want to reply to.
188188
StrongReference postToReplyTo = createPostResult.Result.StrongReference;
189189

190-
AtProtoHttpResult<CreateRecordResponse> replyToHttpResult = await agent.ReplyTo(postToReplyTo, "This is a reply.", cancellationToken: cancellationToken);
190+
AtProtoHttpResult<CreateRecordResult> replyToHttpResult = await agent.ReplyTo(postToReplyTo, "This is a reply.", cancellationToken: cancellationToken);
191191
if (!replyToHttpResult.Succeeded)
192192
{
193193
Console.ForegroundColor = ConsoleColor.Red;
194194
Console.WriteLine($"{replyToHttpResult.StatusCode} occurred when creating the post.");
195195
return;
196196
}
197197

198-
AtProtoHttpResult<CreateRecordResponse> replyToReplyHttpResult = await agent.ReplyTo(replyToHttpResult.Result!.StrongReference, "This is a reply to the reply.", cancellationToken: cancellationToken);
198+
AtProtoHttpResult<CreateRecordResult> replyToReplyHttpResult = await agent.ReplyTo(replyToHttpResult.Result!.StrongReference, "This is a reply to the reply.", cancellationToken: cancellationToken);
199199
Debugger.Break();
200200

201201
if (!replyToReplyHttpResult.Succeeded)
@@ -247,7 +247,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
247247
return;
248248
}
249249

250-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Hello world with an image.", imageUploadResult.Result, cancellationToken: cancellationToken);
250+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Hello world with an image.", imageUploadResult.Result, cancellationToken: cancellationToken);
251251
Debugger.Break();
252252

253253
if (!createPostResult.Succeeded)
@@ -337,7 +337,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
337337
cancellationToken: cancellationToken);
338338

339339

340-
AtProtoHttpResult<CreateRecordResponse> multipleImagePostResult = await agent.Post(
340+
AtProtoHttpResult<CreateRecordResult> multipleImagePostResult = await agent.Post(
341341
"Hello world with multiple images",
342342
[
343343
imageUploadResult.Result!,
@@ -367,10 +367,10 @@ static async Task PerformOperations(string? handle, string? password, string? au
367367

368368
{
369369
// Repost
370-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Another test post, for reposting.", cancellationToken: cancellationToken);
370+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Another test post, for reposting.", cancellationToken: cancellationToken);
371371
if (createPostResult.Succeeded)
372372
{
373-
AtProtoHttpResult<CreateRecordResponse> repostResult = await agent.Repost(createPostResult.Result.StrongReference, cancellationToken: cancellationToken);
373+
AtProtoHttpResult<CreateRecordResult> repostResult = await agent.Repost(createPostResult.Result.StrongReference, cancellationToken: cancellationToken);
374374
Debugger.Break();
375375

376376
if (!repostResult.Succeeded)
@@ -398,10 +398,10 @@ static async Task PerformOperations(string? handle, string? password, string? au
398398

399399
{
400400
// Like
401-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Another test post, for liking.", cancellationToken: cancellationToken);
401+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Another test post, for liking.", cancellationToken: cancellationToken);
402402
if (createPostResult.Succeeded)
403403
{
404-
AtProtoHttpResult<CreateRecordResponse> likeResult = await agent.Like(createPostResult.Result.StrongReference, cancellationToken: cancellationToken);
404+
AtProtoHttpResult<CreateRecordResult> likeResult = await agent.Like(createPostResult.Result.StrongReference, cancellationToken: cancellationToken);
405405
Debugger.Break();
406406

407407
if (!likeResult.Succeeded)
@@ -429,7 +429,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
429429

430430
{
431431
// Quote
432-
AtProtoHttpResult<CreateRecordResponse> createPostResult = await agent.Post("Another test post, for quoting.", cancellationToken: cancellationToken);
432+
AtProtoHttpResult<CreateRecordResult> createPostResult = await agent.Post("Another test post, for quoting.", cancellationToken: cancellationToken);
433433
if (createPostResult.Succeeded)
434434
{
435435
var quoteResponse = await agent.Quote(createPostResult.Result.StrongReference, "Quote Dunk!", cancellationToken: cancellationToken);
@@ -451,7 +451,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
451451
new AspectRatio(1000, 1000),
452452
cancellationToken: cancellationToken);
453453

454-
AtProtoHttpResult<CreateRecordResponse> imageDunkQuoteResponse = await agent.Quote(
454+
AtProtoHttpResult<CreateRecordResult> imageDunkQuoteResponse = await agent.Quote(
455455
createPostResult.Result.StrongReference,
456456
"Dunk with an image",
457457
imageUploadResult.Result!,
@@ -523,7 +523,7 @@ static async Task PerformOperations(string? handle, string? password, string? au
523523

524524
postBuilder += imageUploadResult.Result!;
525525

526-
AtProtoHttpResult<CreateRecordResponse> facetedCreatePostResponse = await agent.Post(postBuilder, cancellationToken: cancellationToken);
526+
AtProtoHttpResult<CreateRecordResult> facetedCreatePostResponse = await agent.Post(postBuilder, cancellationToken: cancellationToken);
527527
Debugger.Break();
528528

529529
if (facetedCreatePostResponse.Succeeded)

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<!-- Always treat "S1135 Complete the task associated to this 'TODO'" as a warning -->
1717
<WarningsNotAsErrors>S1133,S1135</WarningsNotAsErrors>
1818
<!-- Remove until https://github.com/dotnet/runtime/issues/114307 -->
19-
<!--<IsAotCompatible>true</IsAotCompatible>-->
19+
<IsAotCompatible>true</IsAotCompatible>
2020
</PropertyGroup>
2121

2222
<Choose>

0 commit comments

Comments
 (0)