Skip to content

Update inject API reference samples to V4 #3878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2025
Merged

Conversation

normj
Copy link
Member

@normj normj commented Jun 12, 2025

Description

The custom samples that are injected into the API reference docs were not updated V4. In fact they were so out date they were referencing V2 of the SDK.

I went through and updated the samples project to target .NET 8, use async/await and add null checks.

Motivation and Context

#3869

Testing

Dry Run Success: DRY_RUN-e2890913-0dad-4fef-a554-b1ebd871104d

Download the API docs from Catapult and confirmed the updated samples made it into the docs. Here is the snippet that was called on in the GitHub issue for being out of date to now use async/await and have the null check.

<div class="sectionbody">
<example><p>
          This example shows how to list all objects in a bucket.
        </p><h4 class="csharp-code-sample-title">ListObjects sample</h4><pre class="brush: csharp">

// Create a client
AmazonS3Client client = new AmazonS3Client();

// List all objects
ListObjectsRequest listRequest = new ListObjectsRequest
{
    BucketName = &quot;amzn-s3-demo-bucket&quot;,
};

ListObjectsResponse listResponse;
do
{
    // Get a list of objects
    listResponse = await client.ListObjectsAsync(listRequest);

    if (listResponse.S3Objects != null)
    {
        foreach (S3Object obj in listResponse.S3Objects)
        {
            Console.WriteLine(&quot;Object - &quot; + obj.Key);
            Console.WriteLine(&quot; Size - &quot; + obj.Size);
            Console.WriteLine(&quot; LastModified - &quot; + obj.LastModified);
            Console.WriteLine(&quot; Storage class - &quot; + obj.StorageClass);
        }
    }

    // Set the marker property
    listRequest.Marker = listResponse.NextMarker;
} while (listResponse.IsTruncated.GetValueOrDefault());

                
</pre></example>

@philasmar philasmar requested a review from ashishdhingra June 13, 2025 17:26
Copy link
Contributor

@ashishdhingra ashishdhingra left a comment

Choose a reason for hiding this comment

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

Looks good

@normj normj merged commit 1f2cf07 into development Jun 13, 2025
1 check passed
@normj normj deleted the normj/fix-custom-samples branch June 13, 2025 20:20
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