Skip to content

Commit

Permalink
general code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Carpenter committed Feb 29, 2024
1 parent 4faa55a commit 6881534
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ public async Task<DevCenterErrorDetails> InvokeHdcService(
HttpMethod method, string uri, object input, Action<string> processContent)
{
DevCenterErrorReturn returnError = null;
string RequestId = Guid.NewGuid().ToString();
string requestId = Guid.NewGuid().ToString();
string json = JsonSerializer.Serialize(input ?? new object());

using HttpClient client = new(_authHandler, false);
client.DefaultRequestHeaders.Add("MS-CorrelationId", _correlationId.ToString());
client.DefaultRequestHeaders.Add("MS-RequestId", RequestId);
client.DefaultRequestHeaders.Add("MS-RequestId", requestId);

_trace = new DevCenterTrace()
{
CorrelationId = _correlationId.ToString(),
RequestId = RequestId,
RequestId = requestId,
Method = method.ToString(),
Url = uri,
Content = json
Expand Down Expand Up @@ -301,8 +301,7 @@ public async Task<DevCenterResponse<Submission>> GetSubmission(string productId,
return await HdcGet<Submission>(getProductSubmissionUrl, isMany);
}

private const string _devCenterPartnerSubmissionUrl =
"/hardware/products/relationships/sourcepubliherid/{0}/sourceproductid/{1}/sourcesubmissionid/{2}";
private const string _devCenterPartnerSubmissionUrl = "/hardware/products/relationships/sourcepubliherid/{0}/sourceproductid/{1}/sourcesubmissionid/{2}";

/// <summary>
/// Gets shared submission info from a partner-shared Submission with partner ids
Expand Down
50 changes: 25 additions & 25 deletions src/Microsoft.Devices.HardwareDevCenterManager/Models/HardwareId.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT license. See LICENSE file in the project root for full license information.
--*/

using System.Text.Json.Serialization;

namespace Microsoft.Devices.HardwareDevCenterManager.DevCenterApi;

public class HardwareId
{
[JsonPropertyName("bundleId")]
public string BundleId { get; set; }

[JsonPropertyName("infId")]
public string InfId { get; set; }

[JsonPropertyName("operatingSystemCode")]
public string OperatingSystemCode { get; set; }

[JsonPropertyName("pnpString")]
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT license. See LICENSE file in the project root for full license information.
--*/

using System.Text.Json.Serialization;

namespace Microsoft.Devices.HardwareDevCenterManager.DevCenterApi;

public class HardwareId
{
[JsonPropertyName("bundleId")]
public string BundleId { get; set; }

[JsonPropertyName("infId")]
public string InfId { get; set; }

[JsonPropertyName("operatingSystemCode")]
public string OperatingSystemCode { get; set; }

[JsonPropertyName("pnpString")]
public string PnpString { get; set; }

[JsonPropertyName("distributionState")]
public string DistributionState { get; set; }
}
[JsonPropertyName("distributionState")]
public string DistributionState { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task Dump()
if (ErrorReport != null)
{
Console.WriteLine("> Error Report:");
Utility.BlobStorageHandler bsh = new Utility.BlobStorageHandler(ErrorReport);
Utility.BlobStorageHandler bsh = new(ErrorReport);
string errorContent = await bsh.DownloadToString();
Console.WriteLine(errorContent);
Console.WriteLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private async Task<bool> ObtainAccessToken()
client.Timeout = _httpTimeout;
Uri restApi = new(DevCenterTokenUrl);

ClientSecretCredential credential = new ClientSecretCredential(_authCredentials.TenantId, _authCredentials.ClientId, _authCredentials.Key);
ClientSecretCredential credential = new(_authCredentials.TenantId, _authCredentials.ClientId, _authCredentials.Key);
AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(scopes: new string[] { "https://manage.devcenter.microsoft.com/.default" }));

if (string.IsNullOrEmpty(token.Token) == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task Upload(string filePath)
{
try
{
using System.IO.FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
using System.IO.FileStream fileStream = new(filePath, FileMode.Open, FileAccess.Read);
await _blockBlobClient.UploadAsync(fileStream, null, default);
}
catch (RequestFailedException rfe)
Expand All @@ -61,8 +61,6 @@ private void ReportProgress()
// todo: see if we can find a way to write progress using the Azure.Storage namespace
}

private long _fileSize;

/// <summary>
/// Downloads to specified file from HDC Azure Storage
/// </summary>
Expand Down

0 comments on commit 6881534

Please sign in to comment.