Skip to content

Commit b483aee

Browse files
authored
Merge pull request #332 from microsoft/release/update/11042022
SyncUp to Main Build Branch
2 parents dd3a389 + 08b2313 commit b483aee

File tree

11 files changed

+105
-47
lines changed

11 files changed

+105
-47
lines changed

src/GeneralTools/DataverseClient/Client/Auth/AuthProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ internal async static Task<IAccount> TryGetAccountFromCache(IPublicClientApplica
402402
if (publicAppClient != null)
403403
{
404404
var accList = await publicAppClient.GetAccountsAsync().ConfigureAwait(false);
405-
if (accList != null && accList.Count() > 0)
405+
if (accList != null && accList.Any())
406406
{
407407
return accList.FirstOrDefault<IAccount>(w => w.Username.Equals(loginHint, StringComparison.OrdinalIgnoreCase));
408408
}

src/GeneralTools/DataverseClient/Client/ConnectionService.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Newtonsoft.Json;
2222
using Newtonsoft.Json.Linq;
2323
using System;
24+
using System.Collections.Concurrent;
2425
using System.Collections.Generic;
2526
using System.Collections.ObjectModel;
2627
using System.Diagnostics;
@@ -611,7 +612,7 @@ internal bool EnableCookieRelay
611612
/// <summary>
612613
/// Cookies that are being passed though clients, when cookies are used
613614
/// </summary>
614-
internal Dictionary<string, string> CurrentCookieCollection { get; set; } = null;
615+
internal ConcurrentDictionary<string, string> CurrentCookieCollection { get; set; } = null;
615616

616617
/// <summary>
617618
/// Server Hint for the number of concurrent threads that would provide optimal processing.
@@ -697,7 +698,7 @@ internal ConnectionService(
697698
Uri instanceToConnectToo = null)
698699
{
699700
if (authType != AuthenticationType.AD)
700-
throw new ArgumentOutOfRangeException("authType", "Invalid Authentication type");
701+
throw new ArgumentOutOfRangeException(nameof(authType), "Invalid Authentication type");
701702

702703
if (logSink == null)
703704
{
@@ -762,7 +763,7 @@ internal ConnectionService(
762763
)
763764
{
764765
if (authType != AuthenticationType.OAuth && authType != AuthenticationType.ClientSecret)
765-
throw new ArgumentOutOfRangeException("authType", "This constructor only supports the OAuth or Client Secret Auth types");
766+
throw new ArgumentOutOfRangeException(nameof(authType), "This constructor only supports the OAuth or Client Secret Auth types");
766767

767768
if (logSink == null)
768769
{
@@ -828,7 +829,7 @@ internal ConnectionService(
828829
string tokenCacheStorePath = null)
829830
{
830831
if (authType != AuthenticationType.Certificate && authType != AuthenticationType.ExternalTokenManagement)
831-
throw new ArgumentOutOfRangeException("authType", "This constructor only supports the Certificate Auth type");
832+
throw new ArgumentOutOfRangeException(nameof(authType), "This constructor only supports the Certificate Auth type");
832833

833834
if (logSink == null)
834835
{
@@ -1345,7 +1346,7 @@ private async Task<IOrganizationService> InitServiceAsync()
13451346
// Login to Live Failed.
13461347
logEntry.Log(string.Format(CultureInfo.InvariantCulture, "Invalid Login Information : {0}", ex.Message),
13471348
TraceEventType.Error, ex);
1348-
throw ex;
1349+
throw;
13491350

13501351
}
13511352
catch (WebException ex)
@@ -1362,23 +1363,23 @@ private async Task<IOrganizationService> InitServiceAsync()
13621363
logEntry.Log(string.Format(CultureInfo.InvariantCulture, "Unable to connect to Dataverse: {0}", ex.Message), TraceEventType.Error, ex);
13631364

13641365
}
1365-
throw ex;
1366+
throw;
13661367
}
13671368
catch (InvalidOperationException ex)
13681369
{
13691370
if (ex.InnerException == null)
13701371
logEntry.Log(string.Format(CultureInfo.InvariantCulture, "Unable to connect to Dataverse: {0}", ex.Message), TraceEventType.Error, ex);
13711372
else
13721373
logEntry.Log(string.Format(CultureInfo.InvariantCulture, "Unable to connect to Dataverse: {0}", ex.InnerException.Message), TraceEventType.Error, ex);
1373-
throw ex;
1374+
throw;
13741375
}
13751376
catch (Exception ex)
13761377
{
13771378
if (ex.InnerException == null)
13781379
logEntry.Log(string.Format(CultureInfo.InvariantCulture, "Unable to connect to Dataverse: {0}", ex.Message), TraceEventType.Error, ex);
13791380
else
13801381
logEntry.Log(string.Format(CultureInfo.InvariantCulture, "Unable to connect to Dataverse: {0}", ex.InnerException.Message), TraceEventType.Error, ex);
1381-
throw ex;
1382+
throw;
13821383
}
13831384
finally
13841385
{
@@ -1679,7 +1680,7 @@ internal async Task<WhoAmIResponse> GetWhoAmIDetails(IOrganizationService dvServ
16791680
internal void SetClonedProperties(ServiceClient sourceClient)
16801681
{
16811682
if (sourceClient is null)
1682-
throw new ArgumentNullException("sourceClient");
1683+
throw new ArgumentNullException(nameof(sourceClient));
16831684

16841685
if (sourceClient._connectionSvc is null)
16851686
throw new NullReferenceException("Source Connection Service is Failed, Cannot create a clone.");
@@ -2097,7 +2098,7 @@ internal async Task<HttpResponseMessage> Command_WebExecuteAsync(string queryStr
20972098
if (CallerAADObjectId.HasValue)
20982099
{
20992100
// Value in Caller object ID.
2100-
if (CallerAADObjectId.Value != null && CallerAADObjectId.Value != Guid.Empty)
2101+
if (CallerAADObjectId.Value != Guid.Empty)
21012102
{
21022103
customHeaders.Add(Utilities.RequestHeaders.AAD_CALLER_OBJECT_ID_HTTP_HEADER, new List<string>() { CallerAADObjectId.ToString() });
21032104
}
@@ -2727,7 +2728,7 @@ private static async Task<DiscoverOrganizationsResult> DiscoverGlobalOrganizatio
27272728
}
27282729

27292730
if (discoveryServiceUri == null)
2730-
throw new ArgumentNullException("discoveryServiceUri", "Discovery service uri cannot be null.");
2731+
throw new ArgumentNullException(nameof(discoveryServiceUri), "Discovery service uri cannot be null.");
27312732

27322733
// if the discovery URL does not contain api/discovery , base it and use it in the commercial format base.
27332734
// Check needs to be in 2 places as there are 2 different ways Auth can occur.
@@ -2790,7 +2791,7 @@ private static async Task<OrganizationDetailCollection> QueryGlobalDiscoveryAsyn
27902791
}
27912792

27922793
if (discoveryServiceUri == null)
2793-
throw new ArgumentNullException("discoveryServiceUri", "Discovery service uri cannot be null.");
2794+
throw new ArgumentNullException(nameof(discoveryServiceUri), "Discovery service uri cannot be null.");
27942795

27952796
Stopwatch dtStartQuery = new Stopwatch();
27962797
dtStartQuery.Start();

src/GeneralTools/DataverseClient/Client/Connector/OnPremises/OrganizationServiceProxyAsync.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ protected internal virtual Guid CreateCore(Entity entity)
194194

195195
protected internal virtual async Task<Guid> CreateAsyncCore(Entity entity)
196196
{
197-
return await ExecuteOperation<Guid>(async () => { await ServiceChannel.Channel.CreateAsync(entity).ConfigureAwait(false); });
197+
return await ExecuteOperation<Guid>(async () => { await ServiceChannel.Channel.CreateAsync(entity).ConfigureAwait(false); }).ConfigureAwait(false);
198198
}
199199

200200
protected internal virtual Entity RetrieveCore(string entityName, Guid id, ColumnSet columnSet)
@@ -263,7 +263,7 @@ protected internal virtual Entity RetrieveCore(string entityName, Guid id, Colum
263263

264264
protected internal virtual async Task<Entity> RetrieveAsyncCore(string entityName, Guid id, ColumnSet columnSet)
265265
{
266-
return await ExecuteOperation<Entity>(async () => { await ServiceChannel.Channel.RetrieveAsync(entityName, id, columnSet).ConfigureAwait(false); });
266+
return await ExecuteOperation<Entity>(async () => { await ServiceChannel.Channel.RetrieveAsync(entityName, id, columnSet).ConfigureAwait(false); }).ConfigureAwait(false);
267267
}
268268

269269
protected internal virtual void UpdateCore(Entity entity)
@@ -333,7 +333,7 @@ protected internal virtual void UpdateCore(Entity entity)
333333

334334
protected internal virtual async Task UpdateAsyncCore(Entity entity)
335335
{
336-
_ = await ExecuteOperation<bool?>(async () => { await ServiceChannel.Channel.UpdateAsync(entity).ConfigureAwait(false); });
336+
_ = await ExecuteOperation<bool?>(async () => { await ServiceChannel.Channel.UpdateAsync(entity).ConfigureAwait(false); }).ConfigureAwait(false);
337337
}
338338

339339
protected internal virtual void DeleteCore(string entityName, Guid id)
@@ -403,7 +403,7 @@ protected internal virtual void DeleteCore(string entityName, Guid id)
403403

404404
protected internal virtual async Task DeleteAsyncCore(string entityName, Guid id)
405405
{
406-
_ = await ExecuteOperation<bool?>(async () => { await ServiceChannel.Channel.DeleteAsync(entityName, id).ConfigureAwait(false); });
406+
_ = await ExecuteOperation<bool?>(async () => { await ServiceChannel.Channel.DeleteAsync(entityName, id).ConfigureAwait(false); }).ConfigureAwait(false);
407407
}
408408

409409
protected internal virtual OrganizationResponse ExecuteCore(OrganizationRequest request)
@@ -472,7 +472,7 @@ protected internal virtual OrganizationResponse ExecuteCore(OrganizationRequest
472472

473473
protected internal virtual async Task<OrganizationResponse> ExecuteAsyncCore(OrganizationRequest request)
474474
{
475-
return await ExecuteOperation<OrganizationResponse>(async () => { await ServiceChannel.Channel.ExecuteAsync(request).ConfigureAwait(false); });
475+
return await ExecuteOperation<OrganizationResponse>(async () => { await ServiceChannel.Channel.ExecuteAsync(request).ConfigureAwait(false); }).ConfigureAwait(false);
476476
}
477477

478478
protected internal virtual void AssociateCore(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
@@ -542,7 +542,7 @@ protected internal virtual void AssociateCore(string entityName, Guid entityId,
542542

543543
protected internal virtual async Task AssociateAsyncCore(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
544544
{
545-
await ExecuteOperation<OrganizationResponse>(async () => { await ServiceChannel.Channel.AssociateAsync(entityName, entityId, relationship, relatedEntities).ConfigureAwait(false); });
545+
await ExecuteOperation<OrganizationResponse>(async () => { await ServiceChannel.Channel.AssociateAsync(entityName, entityId, relationship, relatedEntities).ConfigureAwait(false); }).ConfigureAwait(false);
546546
}
547547

548548
protected internal virtual void DisassociateCore(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
@@ -612,7 +612,7 @@ protected internal virtual void DisassociateCore(string entityName, Guid entityI
612612

613613
protected internal virtual async Task DisassociateAsyncCore(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
614614
{
615-
await ExecuteOperation<OrganizationResponse>(async () => { await ServiceChannel.Channel.DisassociateAsync(entityName, entityId, relationship, relatedEntities).ConfigureAwait(false); });
615+
await ExecuteOperation<OrganizationResponse>(async () => { await ServiceChannel.Channel.DisassociateAsync(entityName, entityId, relationship, relatedEntities).ConfigureAwait(false); }).ConfigureAwait(false);
616616
}
617617

618618
protected internal virtual EntityCollection RetrieveMultipleCore(QueryBase query)
@@ -681,7 +681,7 @@ protected internal virtual EntityCollection RetrieveMultipleCore(QueryBase query
681681

682682
protected internal virtual async Task<EntityCollection> RetrieveMultipleAsyncCore(QueryBase query)
683683
{
684-
return await ExecuteOperation<EntityCollection>(async () => { await ServiceChannel.Channel.RetrieveMultipleAsync(query).ConfigureAwait(false); });
684+
return await ExecuteOperation<EntityCollection>(async () => { await ServiceChannel.Channel.RetrieveMultipleAsync(query).ConfigureAwait(false); }).ConfigureAwait(false);
685685
}
686686

687687
protected async internal Task<T> ExecuteOperation<T>(Func<Task> asyncAction)
@@ -759,7 +759,7 @@ public Guid Create(Entity entity)
759759

760760
public async Task<Guid> CreateAsync(Entity entity)
761761
{
762-
return await CreateAsyncCore(entity);
762+
return await CreateAsyncCore(entity).ConfigureAwait(false);
763763
}
764764

765765
public Entity Retrieve(string entityName, Guid id, ColumnSet columnSet)
@@ -768,7 +768,7 @@ public Entity Retrieve(string entityName, Guid id, ColumnSet columnSet)
768768
}
769769
public async Task<Entity> RetrieveAsync(string entityName, Guid id, ColumnSet columnSet)
770770
{
771-
return await RetrieveAsyncCore(entityName, id, columnSet);
771+
return await RetrieveAsyncCore(entityName, id, columnSet).ConfigureAwait(false);
772772
}
773773

774774
public void Update(Entity entity)
@@ -777,7 +777,7 @@ public void Update(Entity entity)
777777
}
778778
public async Task UpdateAsync(Entity entity)
779779
{
780-
await UpdateAsyncCore(entity);
780+
await UpdateAsyncCore(entity).ConfigureAwait(false);
781781
}
782782

783783
public void Delete(string entityName, Guid id)
@@ -787,7 +787,7 @@ public void Delete(string entityName, Guid id)
787787

788788
public async Task DeleteAsync(string entityName, Guid id)
789789
{
790-
await DeleteAsyncCore(entityName, id);
790+
await DeleteAsyncCore(entityName, id).ConfigureAwait(false);
791791
}
792792

793793

@@ -798,7 +798,7 @@ public OrganizationResponse Execute(OrganizationRequest request)
798798

799799
public async Task<OrganizationResponse> ExecuteAsync(OrganizationRequest request)
800800
{
801-
return await ExecuteAsyncCore(request);
801+
return await ExecuteAsyncCore(request).ConfigureAwait(false);
802802
}
803803

804804
public void Associate(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
@@ -808,7 +808,7 @@ public void Associate(string entityName, Guid entityId, Relationship relationshi
808808

809809
public async Task AssociateAsync(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
810810
{
811-
await AssociateAsyncCore(entityName, entityId, relationship, relatedEntities);
811+
await AssociateAsyncCore(entityName, entityId, relationship, relatedEntities).ConfigureAwait(false);
812812
}
813813

814814
public void Disassociate(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
@@ -818,7 +818,7 @@ public void Disassociate(string entityName, Guid entityId, Relationship relation
818818

819819
public async Task DisassociateAsync(string entityName, Guid entityId, Relationship relationship, EntityReferenceCollection relatedEntities)
820820
{
821-
await DisassociateAsyncCore(entityName, entityId, relationship, relatedEntities);
821+
await DisassociateAsyncCore(entityName, entityId, relationship, relatedEntities).ConfigureAwait(false);
822822
}
823823

824824
public EntityCollection RetrieveMultiple(QueryBase query)
@@ -828,7 +828,7 @@ public EntityCollection RetrieveMultiple(QueryBase query)
828828

829829
public async Task<EntityCollection> RetrieveMultipleAsync(QueryBase query)
830830
{
831-
return await RetrieveMultipleAsyncCore(query);
831+
return await RetrieveMultipleAsyncCore(query).ConfigureAwait(false);
832832
}
833833

834834
#endregion

src/GeneralTools/DataverseClient/Client/DataverseTraceLogger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ private void GetExceptionDetail(object objException, StringBuilder sw, int level
393393
FormatExceptionMessage(
394394
OrgFault.Source != null ? OrgFault.Source.ToString().Trim() : "Not Provided",
395395
OrgFault.TargetSite != null ? OrgFault.TargetSite.Name.ToString() : "Not Provided",
396-
OrgFault.Detail != null ? string.Format(CultureInfo.InvariantCulture, "Message: {0}\nErrorCode: {1}{4}\nTrace: {2}{3}", OrgFault.Detail.Message, OrgFault.Detail.ErrorCode, OrgFault.Detail.TraceText, string.IsNullOrEmpty(ErrorDetail) ? "" : $"\n{ErrorDetail}", OrgFault.Detail.ActivityId == null ? "" : $"\nActivityId: {OrgFault.Detail.ActivityId}") :
396+
OrgFault.Detail != null ? string.Format(CultureInfo.InvariantCulture, "Message: {0}\nErrorCode: {1}{4}\nTrace: {2}{3}", OrgFault.Detail.Message, OrgFault.Detail.ErrorCode, OrgFault.Detail.TraceText, string.IsNullOrEmpty(ErrorDetail) ? "" : $"\n{ErrorDetail}", OrgFault.Detail.ActivityId != Guid.Empty ? "" : $"\nActivityId: {OrgFault.Detail.ActivityId}") :
397397
string.IsNullOrEmpty(OrgFault.Message) ? "Not Provided" : OrgFault.Message.ToString().Trim(),
398398
string.IsNullOrEmpty(OrgFault.HelpLink) ? "Not Provided" : OrgFault.HelpLink.ToString().Trim(),
399399
string.IsNullOrEmpty(OrgFault.StackTrace) ? "Not Provided" : OrgFault.StackTrace.ToString().Trim()
@@ -420,7 +420,7 @@ private void GetExceptionDetail(object objException, StringBuilder sw, int level
420420
OrganizationServiceFault oFault = (OrganizationServiceFault)objException;
421421
string ErrorDetail = GenerateOrgErrorDetailsInfo(oFault.ErrorDetails);
422422
FormatOrgFaultMessage(
423-
string.Format(CultureInfo.InvariantCulture, "Message: {0}\nErrorCode: {1}{4}\nTrace: {2}{3}", oFault.Message, oFault.ErrorCode, oFault.TraceText, string.IsNullOrEmpty(ErrorDetail) ? "" : $"\n{ErrorDetail}", oFault.ActivityId == null ? "" : $"\nActivityId: {oFault.ActivityId}"),
423+
string.Format(CultureInfo.InvariantCulture, "Message: {0}\nErrorCode: {1}{4}\nTrace: {2}{3}", oFault.Message, oFault.ErrorCode, oFault.TraceText, string.IsNullOrEmpty(ErrorDetail) ? "" : $"\n{ErrorDetail}", oFault.ActivityId != Guid.Empty ? "" : $"\nActivityId: {oFault.ActivityId}"),
424424
oFault.Timestamp.ToString(),
425425
oFault.ErrorCode.ToString(),
426426
string.IsNullOrEmpty(oFault.HelpLink) ? "Not Provided" : oFault.HelpLink.ToString().Trim(),

src/GeneralTools/DataverseClient/Client/Microsoft.PowerPlatform.Dataverse.Client.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<PackageReference Include="System.Text.Json" Version="6.0.2" />
4343
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.18.9" />
4444
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(PackageVersion_Microsoft_Extensions)" />
45+
<PackageReference Include="System.Drawing.Common" Version="5.0.3" /> <!-- explict add to deal with CVE-2021-24112 -->
46+
<PackageReference Include="System.Security.Cryptography.Xml" Version="4.7.1" /> <!-- explict add to deal with CVE-2022-34716 -->
4547
</ItemGroup>
4648

4749
<ItemGroup Condition="'$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'net472' or '$(TargetFramework)' == 'net48'">

0 commit comments

Comments
 (0)