Skip to content

Commit 44a1af6

Browse files
authored
Merge pull request #360 from microsoft/release/update/03132023
Release Resync from Main Branch
2 parents b483aee + cf41e9a commit 44a1af6

35 files changed

+635
-176
lines changed

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.202",
3+
"version": "6.0.406",
44
"rollForward": "latestFeature",
55
"allowPrerelease": false
66
}

src/Build.Common.core.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<PropertyGroup Condition="'$(ProjectSpecificFx)' == ''">
8-
<TargetFrameworks>net462;net472;net48;netcoreapp3.1;netstandard2.0</TargetFrameworks>
8+
<TargetFrameworks>net462;net472;net48;netcoreapp3.1;netstandard2.0;net6.0</TargetFrameworks>
99
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1010
</PropertyGroup>
1111

src/Build.Shared.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
99
<PackageVersion_Adal>3.19.8</PackageVersion_Adal>
1010
<PackageVersion_MSAL>4.35.1</PackageVersion_MSAL>
11-
<PackageVersion_CdsSdk>4.7.11043-v9.0-weekly-2209.2</PackageVersion_CdsSdk>
12-
<PackageVersion_CrmProxy>4.7.11043-v9.0-weekly-2209.2</PackageVersion_CrmProxy>
11+
<PackageVersion_CdsSdk>4.9.665-v9.0-master</PackageVersion_CdsSdk>
12+
<PackageVersion_CrmProxy>4.9.665-v9.0-master</PackageVersion_CrmProxy>
1313
<PackageVersion_CDSServerNuget>4.6.6061-weekly-2108.5</PackageVersion_CDSServerNuget>
1414
<PackageVersion_Newtonsoft>13.0.1</PackageVersion_Newtonsoft>
1515
<PackageVersion_RestClientRuntime>2.3.20</PackageVersion_RestClientRuntime>
@@ -21,10 +21,10 @@
2121
<PackageVersion_Microsoft_Extensions>3.1.8</PackageVersion_Microsoft_Extensions>
2222

2323
<!-- Test: -->
24-
<PackageVersion_MicrosoftNETTestSdk>17.2.0</PackageVersion_MicrosoftNETTestSdk>
24+
<PackageVersion_MicrosoftNETTestSdk>17.5.0</PackageVersion_MicrosoftNETTestSdk>
2525
<PackageVersion_MSTest>2.2.10</PackageVersion_MSTest>
2626
<PackageVersion_Moq>4.16.0</PackageVersion_Moq>
27-
<PackageVersion_XUnit>2.4.1</PackageVersion_XUnit>
27+
<PackageVersion_XUnit>2.4.2</PackageVersion_XUnit>
2828
<PackageVersion_XUnitRunnerVS>2.4.5</PackageVersion_XUnitRunnerVS>
2929
<PackageVersion_FluentAssertions>5.10.3</PackageVersion_FluentAssertions>
3030

src/GeneralTools/DataverseClient/Client/ConnectionService.cs

Lines changed: 220 additions & 77 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ public void EnableProxyTypes(Assembly assembly)
106106
/// For Sdk clients called via the OrganizationServiceProxy this is the version of the local Microsoft.Xrm.Sdk dll used by the Client App.
107107
/// </summary>
108108
/// <returns></returns>
109-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2143:TransparentMethodsShouldNotDemandFxCopRule")]
110-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2141:TransparentMethodsMustNotSatisfyLinkDemandsFxCopRule")]
111-
[PermissionSet(SecurityAction.Demand, Unrestricted = true)]
112109
internal static string GetXrmSdkAssemblyFileVersion()
113110
{
114111
if (string.IsNullOrEmpty(_xrmSdkAssemblyFileVersion))

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
namespace Microsoft.PowerPlatform.Dataverse.Client.Connector.OnPremises
1717
{
18-
[SecurityPermission(SecurityAction.Demand, Unrestricted = true)]
1918
[SecuritySafeCritical]
2019
internal sealed partial class ServiceConfiguration<TService>
2120
{

src/GeneralTools/DataverseClient/Client/Connector/OrganizationWebProxyClientAsync.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace Microsoft.PowerPlatform.Dataverse.Client.Connector
44
using System.Diagnostics.CodeAnalysis;
55
using System.Net;
66
using System.Reflection;
7+
using System.ServiceModel;
78
using System.ServiceModel.Description;
89
using System.Threading.Tasks;
910
using Microsoft.PowerPlatform.Dataverse.Client;
@@ -62,7 +63,8 @@ public void Associate(string entityName, Guid entityId, Relationship relationshi
6263
public Task AssociateAsync(string entityName, Guid entityId, Relationship relationship,
6364
EntityReferenceCollection relatedEntities)
6465
{
65-
return AssociateAsyncCore(entityName, entityId, relationship, relatedEntities);
66+
AssociateAsyncCore(entityName, entityId, relationship, relatedEntities);
67+
return Task.CompletedTask;
6668
}
6769

6870
public Guid Create(Entity entity)
@@ -73,6 +75,7 @@ public Guid Create(Entity entity)
7375
public Task<Guid> CreateAsync(Entity entity)
7476
{
7577
return CreateAsyncCore(entity);
78+
7679
}
7780

7881
public void Delete(string entityName, Guid id)
@@ -82,7 +85,8 @@ public void Delete(string entityName, Guid id)
8285

8386
public Task DeleteAsync(string entityName, Guid id)
8487
{
85-
return DeleteAsyncCore(entityName, id);
88+
DeleteAsyncCore(entityName, id);
89+
return Task.CompletedTask;
8690
}
8791

8892
public void Disassociate(string entityName, Guid entityId, Relationship relationship,
@@ -94,7 +98,8 @@ public void Disassociate(string entityName, Guid entityId, Relationship relation
9498
public Task DisassociateAsync(string entityName, Guid entityId, Relationship relationship,
9599
EntityReferenceCollection relatedEntities)
96100
{
97-
return DisassociateAsyncCore(entityName, entityId, relationship, relatedEntities);
101+
DisassociateAsyncCore(entityName, entityId, relationship, relatedEntities);
102+
return Task.CompletedTask;
98103
}
99104

100105
public OrganizationResponse Execute(OrganizationRequest request)
@@ -134,7 +139,8 @@ public void Update(Entity entity)
134139

135140
public Task UpdateAsync(Entity entity)
136141
{
137-
return UpdateAsyncCore(entity);
142+
UpdateAsyncCore(entity);
143+
return Task.CompletedTask;
138144
}
139145

140146
#endregion
@@ -148,7 +154,7 @@ protected internal virtual Guid CreateCore(Entity entity)
148154

149155
protected Task<Guid> CreateAsyncCore(Entity entity)
150156
{
151-
return ExecuteAction(() => Channel.CreateAsync(entity));
157+
return ExecuteOperation(() => Channel.CreateAsync(entity));
152158
}
153159

154160
protected internal virtual Entity RetrieveCore(string entityName, Guid id, ColumnSet columnSet)
@@ -158,7 +164,7 @@ protected internal virtual Entity RetrieveCore(string entityName, Guid id, Colum
158164

159165
protected internal virtual Task<Entity> RetrieveAsyncCore(string entityName, Guid id, ColumnSet columnSet)
160166
{
161-
return ExecuteAction(() => Channel.RetrieveAsync(entityName, id, columnSet));
167+
return ExecuteOperation(() => Channel.RetrieveAsync(entityName, id, columnSet));
162168
}
163169

164170
protected internal virtual void UpdateCore(Entity entity)
@@ -168,7 +174,7 @@ protected internal virtual void UpdateCore(Entity entity)
168174

169175
protected internal virtual Task UpdateAsyncCore(Entity entity)
170176
{
171-
return ExecuteAction(() => Channel.UpdateAsync(entity));
177+
return ExecuteOperation(() => {Channel.UpdateAsync(entity); return (Task<Task>)Task.CompletedTask;});
172178
}
173179

174180
protected internal virtual void DeleteCore(string entityName, Guid id)
@@ -178,7 +184,7 @@ protected internal virtual void DeleteCore(string entityName, Guid id)
178184

179185
protected internal virtual Task DeleteAsyncCore(string entityName, Guid id)
180186
{
181-
return ExecuteAction(() => Channel.DeleteAsync(entityName, id));
187+
return ExecuteOperation(() => { Channel.DeleteAsync(entityName, id); return (Task<Task>)Task.CompletedTask; });
182188
}
183189

184190
protected internal virtual OrganizationResponse ExecuteCore(OrganizationRequest request)
@@ -188,7 +194,7 @@ protected internal virtual OrganizationResponse ExecuteCore(OrganizationRequest
188194

189195
protected internal virtual Task<OrganizationResponse> ExecuteAsyncCore(OrganizationRequest request)
190196
{
191-
return ExecuteAction(() => Channel.ExecuteAsync(request));
197+
return ExecuteOperation(() => Channel.ExecuteAsync(request));
192198
}
193199

194200
protected internal virtual void AssociateCore(string entityName, Guid entityId, Relationship relationship,
@@ -200,7 +206,7 @@ protected internal virtual void AssociateCore(string entityName, Guid entityId,
200206
protected internal virtual Task AssociateAsyncCore(string entityName, Guid entityId, Relationship relationship,
201207
EntityReferenceCollection relatedEntities)
202208
{
203-
return ExecuteAction(() => Channel.AssociateAsync(entityName, entityId, relationship, relatedEntities));
209+
return ExecuteOperation(() => { Channel.AssociateAsync(entityName, entityId, relationship, relatedEntities); return (Task<Task>)Task.CompletedTask; });
204210
}
205211

206212
protected internal virtual void DisassociateCore(string entityName, Guid entityId, Relationship relationship,
@@ -212,7 +218,7 @@ protected internal virtual void DisassociateCore(string entityName, Guid entityI
212218
protected internal virtual Task DisassociateAsyncCore(string entityName, Guid entityId, Relationship relationship,
213219
EntityReferenceCollection relatedEntities)
214220
{
215-
return ExecuteAction(() => Channel.DisassociateAsync(entityName, entityId, relationship, relatedEntities));
221+
return ExecuteOperation(() => { Channel.DisassociateAsync(entityName, entityId, relationship, relatedEntities); return (Task<Task>)Task.CompletedTask; });
216222
}
217223

218224
protected internal virtual EntityCollection RetrieveMultipleCore(QueryBase query)
@@ -222,7 +228,7 @@ protected internal virtual EntityCollection RetrieveMultipleCore(QueryBase query
222228

223229
protected internal virtual Task<EntityCollection> RetrieveMultipleAsyncCore(QueryBase query)
224230
{
225-
return ExecuteAction(() => Channel.RetrieveMultipleAsync(query));
231+
return ExecuteOperation(() => Channel.RetrieveMultipleAsync(query));
226232
}
227233

228234
#endregion Protected Members

src/GeneralTools/DataverseClient/Client/Connector/WebProxyClient.cs

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Reflection;
43
using System.Security.Permissions;
54
using System.ServiceModel;
65
using System.ServiceModel.Channels;
76
using System.ServiceModel.Description;
7+
using System.Threading.Tasks;
88
using Microsoft.Xrm.Sdk.Client;
99

1010
namespace Microsoft.PowerPlatform.Dataverse.Client.Connector
1111
{
12-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.CodeQuality.Analyzers", "CA1063: Implement IDisposable correctly", Justification = "FxCop Bankruptcy")]
1312
internal abstract class WebProxyClientAsync<TService> : ClientBase<TService>, IDisposable
1413
where TService : class
1514
{
@@ -83,6 +82,33 @@ internal TResult ExecuteAction<TResult>(Func<TResult> action)
8382
}
8483
}
8584

85+
#if NETCOREAPP
86+
protected async internal Task<T> ExecuteOperation<T>(Func<Task<T>> asyncAction)
87+
{
88+
if (asyncAction == null)
89+
{
90+
throw new ArgumentNullException(nameof(asyncAction));
91+
}
92+
93+
using (CreateNewInitializer())
94+
{
95+
return await asyncAction().ConfigureAwait(continueOnCapturedContext: true);
96+
}
97+
}
98+
#else
99+
protected internal Task<T> ExecuteOperation<T>(Func<Task<T>> asyncAction)
100+
{
101+
if (asyncAction == null)
102+
{
103+
throw new ArgumentNullException(nameof(asyncAction));
104+
}
105+
106+
using (CreateNewInitializer())
107+
{
108+
return asyncAction();
109+
}
110+
}
111+
#endif
86112
protected static ServiceEndpoint CreateServiceEndpoint(Uri serviceUrl, bool useStrongTypes, TimeSpan timeout,
87113
Assembly strongTypeAssembly)
88114
{
@@ -162,9 +188,6 @@ protected static Binding GetBinding(Uri serviceUrl, TimeSpan timeout)
162188
/// by the Client App.
163189
/// </summary>
164190
/// <returns></returns>
165-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2143:TransparentMethodsShouldNotDemandFxCopRule")]
166-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2141:TransparentMethodsMustNotSatisfyLinkDemandsFxCopRule")]
167-
[PermissionSet(SecurityAction.Demand, Unrestricted = true)]
168191
internal string GetXrmSdkAssemblyFileVersion()
169192
{
170193
if (string.IsNullOrEmpty(_xrmSdkAssemblyFileVersion))
@@ -181,27 +204,27 @@ internal string GetXrmSdkAssemblyFileVersion()
181204
return _xrmSdkAssemblyFileVersion;
182205
}
183206

184-
#region IDisposable implementation
207+
#region IDisposable implementation
185208

186209
public void Dispose()
187210
{
188211
Dispose(true);
189212
GC.SuppressFinalize(this);
190213
}
191214

192-
#region Protected Methods
215+
#region Protected Methods
193216

194217
protected virtual void Dispose(bool disposing)
195218
{
196219
}
197220

198-
#endregion
221+
#endregion
199222

200223
~WebProxyClientAsync()
201224
{
202225
Dispose(false);
203226
}
204227

205-
#endregion
228+
#endregion
206229
}
207230
}

src/GeneralTools/DataverseClient/Client/DataverseTraceLogger.cs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ public override void Log(string message, TraceEventType eventType, Exception exc
169169
// check and or alter the exception is its and HTTPOperationExecption.
170170
if (exception is HttpOperationException httpOperationException)
171171
{
172-
JObject contentBody = JObject.Parse(httpOperationException.Response.Content);
173-
Utils.DataverseOperationException webApiExcept = new Utils.DataverseOperationException(string.IsNullOrEmpty(contentBody["error"]["message"]?.ToString()) ? "Not Provided" : GetFirstLineFromString(contentBody["error"]["message"]?.ToString()).Trim(), httpOperationException);
172+
string errorMessage = "Not Provided";
173+
if (!string.IsNullOrWhiteSpace(httpOperationException.Response.Content))
174+
{
175+
JObject contentBody = JObject.Parse(httpOperationException.Response.Content);
176+
errorMessage = string.IsNullOrEmpty(contentBody["error"]["message"]?.ToString()) ? "Not Provided" : GetFirstLineFromString(contentBody["error"]["message"]?.ToString()).Trim();
177+
}
178+
179+
Utils.DataverseOperationException webApiExcept = new Utils.DataverseOperationException(errorMessage, httpOperationException);
174180
LastException = webApiExcept;
175181
}
176182
else
@@ -249,9 +255,19 @@ public void LogException(OrganizationRequest req, Exception ex, string errorStri
249255
}
250256
else if (ex is HttpOperationException httpOperationException)
251257
{
252-
JObject contentBody = JObject.Parse(httpOperationException.Response.Content);
258+
string errorMessage;
259+
if (!string.IsNullOrWhiteSpace(httpOperationException.Response.Content))
260+
{
261+
JObject contentBody = JObject.Parse(httpOperationException.Response.Content);
262+
errorMessage = DataverseTraceLogger.GetFirstLineFromString(contentBody["error"]["message"].ToString()).Trim();
263+
}
264+
else
265+
{
266+
errorMessage = httpOperationException.Response.StatusCode.ToString();
267+
}
268+
253269
DataverseOperationException ex01 = DataverseOperationException.GenerateClientOperationException(httpOperationException);
254-
Log(string.Format(CultureInfo.InvariantCulture, "************ {3} - {2} : {0} |=> {1}", errorStringCheck, DataverseTraceLogger.GetFirstLineFromString(contentBody["error"]["message"].ToString()).Trim(), webUriMessageReq, ex.GetType().Name), TraceEventType.Error, ex01);
270+
Log(string.Format(CultureInfo.InvariantCulture, "************ {3} - {2} : {0} |=> {1}", errorStringCheck, errorMessage, webUriMessageReq, ex.GetType().Name), TraceEventType.Error, ex01);
255271
}
256272
else
257273
{
@@ -294,8 +310,15 @@ public void LogFailure(OrganizationRequest req, Guid requestTrackingId, Guid? se
294310
DataverseOperationException ex01 = DataverseOperationException.GenerateClientOperationException(httpOperationException);
295311
try
296312
{
297-
JObject contentBody = JObject.Parse(httpOperationException.Response.Content);
298-
errorMessage = DataverseTraceLogger.GetFirstLineFromString(contentBody["error"]["message"].ToString()).Trim();
313+
if (!string.IsNullOrWhiteSpace(httpOperationException.Response.Content))
314+
{
315+
JObject contentBody = JObject.Parse(httpOperationException.Response.Content);
316+
errorMessage = DataverseTraceLogger.GetFirstLineFromString(contentBody["error"]["message"].ToString()).Trim();
317+
}
318+
else
319+
{
320+
errorMessage = httpOperationException.Response.StatusCode.ToString();
321+
}
299322
}
300323
catch (Exception)
301324
{

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<RootNamespace>Microsoft.PowerPlatform.Dataverse.Client</RootNamespace>
@@ -11,6 +11,7 @@
1111
<PropertyGroup>
1212
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
1313
<DocumentationFile>$(OutDir)\Microsoft.PowerPlatform.Dataverse.Client.xml</DocumentationFile>
14+
<AnalysisLevel>6.0</AnalysisLevel>
1415
</PropertyGroup>
1516

1617

@@ -38,12 +39,12 @@
3839
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
3940
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />
4041
<PackageReference Include="System.Security.Permissions" Version="5.0.0" />
41-
<PackageReference Include="System.ServiceModel.Http" Version="4.8.1" />
42-
<PackageReference Include="System.Text.Json" Version="6.0.2" />
42+
<PackageReference Include="System.ServiceModel.Http" Version="4.10.0" />
43+
<PackageReference Include="System.Text.Json" Version="6.0.7" />
4344
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.18.9" />
4445
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="$(PackageVersion_Microsoft_Extensions)" />
4546
<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 -->
47+
<PackageReference Include="System.Security.Cryptography.Xml" Version="6.0.1" /> <!-- explict add to deal with CVE-2022-34716 -->
4748
</ItemGroup>
4849

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

src/GeneralTools/DataverseClient/Client/Model/ConfigurationOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public bool UseWebApi
7171
set => _useWebApi = value;
7272
}
7373

74-
private bool _useWebApiLoginFlow = Utils.AppSettingsHelper.GetAppSetting<bool>("UseWebApiLoginFlow", false);
74+
private bool _useWebApiLoginFlow = Utils.AppSettingsHelper.GetAppSetting<bool>("UseWebApiLoginFlow", true);
7575
/// <summary>
7676
/// Use Web API instead of org service for logging into and getting boot up data.
7777
/// </summary>

0 commit comments

Comments
 (0)