11# .NET Technology Stack & Build System
22
3- ## .NET 3.5 + Development Environment
3+ ## .NET 8 + Development Environment
44
55### Build Tools & Dependencies
66- ** Build System** : dotnet CLI
77- ** Package Manager** : NuGet
88- ** Testing Framework** : xUnit
99- ** Code Formatting** : dotnet-format
10- - ** SDK Version** : AWS SDK for .NET
11- - ** .NET Version** : .NET 3.5+ (recommended .NET 6+)
10+ - ** SDK Version** : AWS SDK for .NET v4
11+ - ** .NET Version** : .NET 8+
1212
1313### Common Build Commands
1414
@@ -52,6 +52,35 @@ dotnet format # Format code
5252- ** Constants** : Use PascalCase for constants
5353- ** Async methods** : Suffix with ` Async ` (e.g., ` ListBucketsAsync ` )
5454
55+ #### Dependency Injection Patterns
56+ ``` csharp
57+ /// <summary >
58+ /// Main entry point for the AWS Control Tower basics scenario.
59+ /// </summary >
60+ /// <param name =" args" >Command line arguments.</param >
61+ public static async Task Main (string [] args )
62+ {
63+ using var host = Host .CreateDefaultBuilder (args )
64+ .ConfigureServices ((_ , services ) =>
65+ services .AddAWSService <IAmazonControlTower >()
66+ .AddAWSService <IAmazonControlCatalog >()
67+ .AddAWSService <IAmazonOrganizations >()
68+ .AddAWSService <IAmazonSecurityTokenService >()
69+ .AddTransient <ControlTowerWrapper >()
70+ )
71+ .Build ();
72+
73+ logger = LoggerFactory .Create (builder => { builder .AddConsole (); })
74+ .CreateLogger <ControlTowerBasics >();
75+
76+ wrapper = host .Services .GetRequiredService <ControlTowerWrapper >();
77+ orgClient = host .Services .GetRequiredService <IAmazonOrganizations >();
78+ stsClient = host .Services .GetRequiredService <IAmazonSecurityTokenService >();
79+
80+ await RunScenario ();
81+ }
82+ ```
83+
5584#### Error Handling Patterns
5685``` csharp
5786using Amazon .S3 ;
@@ -127,17 +156,6 @@ src/
127156- If credentials test passes but .NET SDK fails, investigate SDK-specific credential chain issues
128157- Common .NET SDK credential issues: EC2 instance metadata service conflicts, credential provider chain order
129158
130- #### Credential Chain Configuration
131- ``` csharp
132- // Explicit credential chain setup
133- var chain = new CredentialProfileStoreChain ();
134- if (chain .TryGetAWSCredentials (" default" , out var credentials ))
135- {
136- var config = new AmazonS3Config ();
137- var client = new AmazonS3Client (credentials , config );
138- }
139- ```
140-
141159### Build Troubleshooting
142160
143161#### DotNetV4 Build Troubleshooting
@@ -152,15 +170,21 @@ if (chain.TryGetAWSCredentials("default", out var credentials))
152170- ❌ ** NEVER ignore proper exception handling for AWS operations**
153171- ❌ ** NEVER skip NuGet package management**
154172- ❌ ** NEVER assume credentials without testing first**
173+ - ❌ ** NEVER use other language folders for patterns**
155174
156175### Best Practices
176+ - ✅ ** ALWAYS create examples in the dotnetv4 directory unless instructed otherwise**
157177- ✅ ** ALWAYS follow the established .NET project structure**
158178- ✅ ** ALWAYS use PascalCase for .NET identifiers**
159179- ✅ ** ALWAYS use using statements for AWS client management**
160180- ✅ ** ALWAYS include proper exception handling for AWS service calls**
161181- ✅ ** ALWAYS test AWS credentials before assuming credential issues**
162182- ✅ ** ALWAYS include comprehensive XML documentation**
163183- ✅ ** ALWAYS use async/await patterns for AWS operations**
184+ - ✅ ** ALWAYS use dependency injection for AWS services**
185+ - ✅ ** ALWAYS create a separate class in the Actions project for the Hello example**
186+ - ✅ ** ALWAYS add project files to the main solution file DotNetV4Examples.sln**
187+ - ✅ ** ALWAYS put print statements in the action methods if possible**
164188
165189### Project Configuration Requirements
166190- ** Target Framework** : Specify appropriate .NET version in .csproj
0 commit comments