steering_docs/dotnet-tech/hello.md
šØ CRITICAL - Must be completed BEFORE any code generation
# Step 1: List available knowledge bases
ListKnowledgeBases()
# Step 2: Query coding standards (REQUIRED)
QueryKnowledgeBases("coding-standards-KB", "DotNet-code-example-standards")
# Step 3: Query implementation patterns (REQUIRED)
QueryKnowledgeBases("DotNet-premium-KB", ".NET implementation patterns")
# Step 4: AWS service research (REQUIRED)
search_documentation("What is [AWS Service] and what are its key API operations?")
read_documentation("https://docs.aws.amazon.com/[service]/latest/[relevant-page]")
FAILURE TO COMPLETE KNOWLEDGE BASE CONSULTATION WILL RESULT IN INCORRECT CODE STRUCTURE
Generate simple "Hello" examples that demonstrate basic service connectivity and the most fundamental operation using direct AWS SDK for .NET client calls.
dotnetv4/{Service}/Actions/
āāā Hello{Service}.cs # Hello example file (with Main method)
āāā {Service}Wrapper.cs # Service wrapper class
āāā {Service}Actions.csproj # Actions project file (OutputType=Exe)
CRITICAL:
<OutputType>Exe</OutputType> to support Main methodRequired NuGet Packages for Actions Project:
<ItemGroup>
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.301" />
<PackageReference Include="AWSSDK.{Service}" Version="3.7.500" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
</ItemGroup>
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Amazon.{Service};
using Amazon.{Service}.Model;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.Logging.Debug;
namespace {Service}Actions;
/// <summary>
/// Hello Amazon {Service} example.
/// </summary>
public class Hello{Service}
{
private static ILogger logger = null!;
// snippet-start:[{Service}.dotnetv4.Hello]
/// <summary>
/// Main method to run the Hello Amazon {Service} example.
/// </summary>
/// <param name="args">Command line arguments (not used).</param>
public static async Task Main(string[] args)
{
// Set up dependency injection for Amazon {Service}.
using var host = Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
logging.AddFilter("System", LogLevel.Debug)
.AddFilter<DebugLoggerProvider>("Microsoft", LogLevel.Information)
.AddFilter<ConsoleLoggerProvider>("Microsoft", LogLevel.Trace))
.ConfigureServices((_, services) =>
services.AddAWSService<Amazon{Service}Client>())
.Build();
logger = LoggerFactory.Create(builder => { builder.AddConsole(); })
.CreateLogger<Hello{Service}>();
var {service}Client = host.Services.GetRequiredService<Amazon{Service}Client>();
Console.Clear();
Console.WriteLine("Hello, Amazon {Service}! Let's list available {resources}:");
Console.WriteLine();
var {resources} = new List<{Resource}>();
try
{
// Use pagination to retrieve all {resources}
var {resources}Paginator = {service}Client.Paginators.List{Resources}(new List{Resources}Request());
await foreach (var response in {resources}Paginator.Responses)
{
{resources}.AddRange(response.{Resources});
}
Console.WriteLine($"{{{resources}.Count}} {resource}(s) retrieved.");
foreach (var {resource} in {resources})
{
Console.WriteLine($"\t{{{resource}.Name}}");
}
}
catch (Amazon{Service}Exception ex)
{
logger.LogError("Error listing {resources}: {Message}", ex.Message);
Console.WriteLine($"Couldn't list {resources}. Error: {ex.Message}");
}
catch (Exception ex)
{
logger.LogError("An error occurred: {Message}", ex.Message);
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
// snippet-end:[{Service}.dotnetv4.Hello]
}
[{Service}.dotnetv4.Hello]CRITICAL: Use the correct snippet tag format:
// ā
CORRECT
// snippet-start:[{Service}.dotnetv4.HelloSteering]
public static async Task Main(string[] args)
{
// Implementation
}
// snippet-end:[{Service}.dotnetv4.HelloSteering]
// ā WRONG - Old format
// snippet-start:[dotnetv4.example_code.{Service}.HelloSteering]
// snippet-end:[dotnetv4.example_code.{Service}.HelloSteering]
Format: [{Service}.dotnetv4.Hello]
.dotnetv4.Hello for Hello examples