Skip to content

Commit 57e8385

Browse files
committed
Fix formatting and warnings
1 parent c606dfe commit 57e8385

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

dotnetv4/IoT/Actions/HelloIoT.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static async Task Main(string[] args)
4242
Console.WriteLine($" Thing ARN: {thing.ThingArn}");
4343
Console.WriteLine($" Thing Type: {thing.ThingTypeName ?? "No type specified"}");
4444
Console.WriteLine($" Version: {thing.Version}");
45-
45+
4646
if (thing.Attributes?.Count > 0)
4747
{
4848
Console.WriteLine(" Attributes:");
@@ -72,4 +72,4 @@ public static async Task Main(string[] args)
7272
}
7373
}
7474
}
75-
// snippet-end:[iot.dotnetv4.Hello]
75+
// snippet-end:[iot.dotnetv4.Hello]

dotnetv4/IoT/Actions/IoTWrapper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public async Task<List<Certificate>> ListCertificatesAsync()
209209
{
210210
var request = new ListCertificatesRequest();
211211
var response = await _amazonIoT.ListCertificatesAsync(request);
212-
212+
213213
_logger.LogInformation($"Retrieved {response.Certificates.Count} certificates");
214214
return response.Certificates;
215215
}
@@ -278,7 +278,7 @@ public async Task<bool> UpdateThingShadowAsync(string thingName, string shadowPa
278278
var response = await _amazonIotData.GetThingShadowAsync(request);
279279
using var reader = new StreamReader(response.Payload);
280280
var shadowData = await reader.ReadToEndAsync();
281-
281+
282282
_logger.LogInformation($"Retrieved shadow for Thing {thingName}");
283283
return shadowData;
284284
}
@@ -357,7 +357,7 @@ public async Task<List<TopicRuleListItem>> ListTopicRulesAsync()
357357
{
358358
var request = new ListTopicRulesRequest();
359359
var response = await _amazonIoT.ListTopicRulesAsync(request);
360-
360+
361361
_logger.LogInformation($"Retrieved {response.Rules.Count} IoT rules");
362362
return response.Rules;
363363
}
@@ -607,7 +607,7 @@ public async Task<List<ThingAttribute>> ListThingsAsync()
607607
{
608608
var request = new ListThingsRequest();
609609
var response = await _amazonIoT.ListThingsAsync(request);
610-
610+
611611
_logger.LogInformation($"Retrieved {response.Things.Count} Things");
612612
return response.Things;
613613
}
@@ -625,4 +625,4 @@ public async Task<List<ThingAttribute>> ListThingsAsync()
625625
// snippet-end:[iot.dotnetv4.ListThings]
626626

627627
}
628-
// snippet-end:[iot.dotnetv4.IoTWrapper]
628+
// snippet-end:[iot.dotnetv4.IoTWrapper]

dotnetv4/IoT/Scenarios/IoTBasics.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public static async Task Main(string[] args)
4343
// Set up dependency injection for the Amazon service.
4444
using var host = Host.CreateDefaultBuilder(args)
4545
.ConfigureServices((_, services) =>
46-
services.AddAWSService<IAmazonIoT>(new AWSOptions(){Region = RegionEndpoint.USEast1})
46+
services.AddAWSService<IAmazonIoT>(new AWSOptions() { Region = RegionEndpoint.USEast1 })
4747
.AddAWSService<IAmazonCloudFormation>()
4848
.AddTransient<IoTWrapper>()
4949
.AddLogging(builder => builder.AddConsole())
5050
.AddSingleton<IAmazonIotData>(sp =>
5151
{
52-
var iotService = sp.GetService<IAmazonIoT>();
52+
var iotService = sp.GetRequiredService<IAmazonIoT>();
5353
var request = new DescribeEndpointRequest
5454
{
5555
EndpointType = "iot:Data-ATS"
@@ -133,7 +133,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
133133
Console.WriteLine("1. Create an AWS IoT Thing.");
134134
Console.WriteLine("An AWS IoT Thing represents a virtual entity in the AWS IoT service that can be associated with a physical device.");
135135
Console.WriteLine();
136-
136+
137137
if (IsInteractive)
138138
{
139139
Console.Write("Enter Thing name: ");
@@ -145,7 +145,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
145145
{
146146
Console.WriteLine($"Using default Thing name: {thingName}");
147147
}
148-
148+
149149
var thingArn = await iotWrapper.CreateThingAsync(thingName);
150150
Console.WriteLine($"{thingName} was successfully created. The ARN value is {thingArn}");
151151
Console.WriteLine(new string('-', 80));
@@ -155,7 +155,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
155155
Console.WriteLine("2. Generate a device certificate.");
156156
Console.WriteLine("A device certificate performs a role in securing the communication between devices (Things) and the AWS IoT platform.");
157157
Console.WriteLine();
158-
158+
159159
var createCert = "y";
160160
if (IsInteractive)
161161
{
@@ -327,7 +327,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
327327
Console.WriteLine("Creates a rule that is an administrator-level action.");
328328
Console.WriteLine("Any user who has permission to create rules will be able to access data processed by the rule.");
329329
Console.WriteLine();
330-
330+
331331
if (IsInteractive)
332332
{
333333
Console.Write("Enter Rule name: ");
@@ -342,7 +342,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
342342

343343
// Deploy CloudFormation stack to create SNS topic and IAM role
344344
Console.WriteLine("Deploying CloudFormation stack to create SNS topic and IAM role...");
345-
345+
346346
var deployStack = !IsInteractive || GetYesNoResponse("Would you like to deploy the CloudFormation stack? (y/n) ");
347347
if (deployStack)
348348
{
@@ -358,10 +358,10 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
358358
{
359359
snsTopicArn = stackOutputs["SNSTopicArn"];
360360
string roleArn = stackOutputs["RoleArn"];
361-
361+
362362
Console.WriteLine($"Successfully deployed stack. SNS topic: {snsTopicArn}");
363363
Console.WriteLine($"Successfully deployed stack. IAM role: {roleArn}");
364-
364+
365365
// Now create the IoT rule with the CloudFormation outputs
366366
var ruleResult = await iotWrapper.CreateTopicRuleAsync(ruleName, snsTopicArn, roleArn);
367367
if (ruleResult)
@@ -489,7 +489,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
489489
Console.WriteLine(new string('-', 80));
490490
Console.WriteLine("13. Clean up CloudFormation stack.");
491491
Console.WriteLine("Deleting the CloudFormation stack and all resources...");
492-
492+
493493
var cleanup = !IsInteractive || GetYesNoResponse("Do you want to delete the CloudFormation stack and all resources? (y/n) ");
494494
if (cleanup)
495495
{
@@ -513,7 +513,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
513513
catch (Exception ex)
514514
{
515515
scenarioLogger.LogError(ex, "Error occurred during scenario execution.");
516-
516+
517517
// Cleanup on error
518518
if (!string.IsNullOrEmpty(certificateArn) && !string.IsNullOrEmpty(thingName))
519519
{
@@ -527,7 +527,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
527527
scenarioLogger.LogError(cleanupEx, "Error during cleanup.");
528528
}
529529
}
530-
530+
531531
if (!string.IsNullOrEmpty(thingName))
532532
{
533533
try
@@ -552,7 +552,7 @@ private static async Task RunScenarioInternalAsync(IoTWrapper iotWrapper, IAmazo
552552
scenarioLogger.LogError(cleanupEx, "Error during CloudFormation stack cleanup.");
553553
}
554554
}
555-
555+
556556
throw;
557557
}
558558
}
@@ -574,7 +574,7 @@ private static async Task<bool> DeployCloudFormationStack(string stackName, IAma
574574
{
575575
StackName = stackName,
576576
TemplateBody = await File.ReadAllTextAsync(_stackResourcePath),
577-
Capabilities = new List<string>{ Capability.CAPABILITY_NAMED_IAM }
577+
Capabilities = new List<string> { Capability.CAPABILITY_NAMED_IAM }
578578
};
579579

580580
var response = await cloudFormationClient.CreateStackAsync(request);
@@ -676,7 +676,7 @@ private static async Task<bool> WaitForStackCompletion(string stackId, IAmazonCl
676676
};
677677

678678
var response = await cloudFormationClient.DescribeStacksAsync(describeStacksRequest);
679-
679+
680680
if (response.Stacks.Count > 0)
681681
{
682682
var outputs = new Dictionary<string, string>();
@@ -686,7 +686,7 @@ private static async Task<bool> WaitForStackCompletion(string stackId, IAmazonCl
686686
}
687687
return outputs;
688688
}
689-
689+
690690
return null;
691691
}
692692
catch (Exception ex)
@@ -813,4 +813,4 @@ private static string PromptUserForStackName()
813813
return _stackName;
814814
}
815815
}
816-
// snippet-end:[iot.dotnetv4.IoTScenario]
816+
// snippet-end:[iot.dotnetv4.IoTScenario]

dotnetv4/IoT/Scenarios/IoTBasics.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageReference Include="AWSSDK.IotData" Version="4.0.2.7" />
1313
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="4.0.2.7" />
1414
<PackageReference Include="AWSSDK.IdentityManagement" Version="4.0.3.7" />
15-
<PackageReference Include="AWSSDK.CloudFormation" Version="4.0.3.7" />
15+
<PackageReference Include="AWSSDK.CloudFormation" Version="4.0.4" />
1616
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="4.0.3.14" />
1717
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
1818
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />

dotnetv4/IoT/Tests/IoTIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ public async Task TestScenarioIntegration()
6161
It.IsAny<Func<It.IsAnyType, Exception?, string>>()),
6262
Times.Never);
6363
}
64-
}
64+
}

dotnetv4/IoT/Tests/IoTTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ItemGroup>
1212
<PackageReference Include="AWSSDK.IoT" Version="4.0.3.7" />
1313
<PackageReference Include="AWSSDK.IotData" Version="4.0.2.7" />
14-
<PackageReference Include="AWSSDK.CloudFormation" Version="4.0.3.7" />
14+
<PackageReference Include="AWSSDK.CloudFormation" Version="4.0.4" />
1515
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="4.0.3.14" />
1616
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
1717
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />

0 commit comments

Comments
 (0)