Skip to content

Commit 9f25d39

Browse files
authored
Merge pull request #109 from microsoft/release/update/210325091713
Exposing Ilogger support on constructors and clone.
2 parents 1fe9bf8 + e3d6df3 commit 9f25d39

12 files changed

+913
-854
lines changed

src/Build.Common.StandardAndLegacy.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<Project>
2+
<PropertyGroup>
3+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
4+
</PropertyGroup>
5+
26
<PropertyGroup Condition="'$(TargetFrameworks)' == ''">
37
<TargetFrameworks Condition="'$(OutputType)' == 'Exe'">netcoreapp3.1;net462</TargetFrameworks>
48
<TargetFrameworks Condition="'$(OutputType)' != 'Exe'">netstandard2.0;net462</TargetFrameworks>

src/Build.Common.core.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<Project>
22
<!-- dotnetCore specific msbuild properties: -->
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
</PropertyGroup>
6+
37
<PropertyGroup Condition="'$(ProjectSpecificFx)' == ''">
48
<TargetFrameworks>net462;net472;net48;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
59
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

src/Build.Common.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project>
22
<!-- .NET Classic (v5.62) specific msbuild properties: -->
33
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
45
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
56
</PropertyGroup>
67

src/Build.Shared.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project>
22
<!-- msbuild properties shared for dotnetCore and .NET classic projects: -->
33
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
45
<PackageVersion_AppInsights>2.9.1</PackageVersion_AppInsights>
56
<PackageVersion_Adal>3.19.8</PackageVersion_Adal>
67
<PackageVersion_MSAL>4.25.0</PackageVersion_MSAL>
@@ -17,7 +18,7 @@
1718

1819
<PropertyGroup>
1920
<!-- this property must be re-defined in individual .csprojs or a .props file per component area -->
20-
<ComponentAreaName Condition="'$(ComponentAreaName)' == ''">FORGOT-To-Set-ComponentAreaName</ComponentAreaName>
21+
<ComponentAreaName Condition="'$(ComponentAreaName)' == ''">FORGOT-To-Set-ComponentAreaName</ComponentAreaName>
2122
</PropertyGroup>
2223

2324
<PropertyGroup>
@@ -44,7 +45,6 @@
4445
<FileAlignment>512</FileAlignment>
4546
<Deterministic>true</Deterministic>
4647
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
47-
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
4848
<ErrorReport>prompt</ErrorReport>
4949
<WarningLevel>4</WarningLevel>
5050
</PropertyGroup>

src/GeneralTools/DataverseClient/Client/ConnectionService.cs

Lines changed: 210 additions & 206 deletions
Large diffs are not rendered by default.

src/GeneralTools/DataverseClient/Client/ServiceClient.cs

Lines changed: 461 additions & 439 deletions
Large diffs are not rendered by default.

src/GeneralTools/DataverseClient/Client/TraceLoggerBase.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Microsoft.PowerPlatform.Dataverse.Client
1010
{
1111
/// <summary>
12-
/// TraceLoggerBase Class.
12+
/// TraceLoggerBase Class.
1313
/// </summary>
1414
[LocalizableAttribute(false)]
1515
#pragma warning disable CA1063 // Implement IDisposable Correctly
@@ -35,7 +35,7 @@ public abstract class TraceLoggerBase : IDisposable
3535
private Exception _lastException = null;
3636

3737
private TraceSource _source;
38-
38+
3939
#endregion
4040

4141
#region Protected fields
@@ -62,7 +62,7 @@ protected TraceSource Source
6262
System.Diagnostics.EventLog.WriteEntry("application", errMsg, System.Diagnostics.EventLogEntryType.Error);
6363
#endif
6464
}
65-
catch
65+
catch
6666
{
6767
//error in writing to event log
6868
string log = string.Format("UNABLE TO WRITE TO EVENT LOG FOR: {0}", errMsg);
@@ -109,7 +109,7 @@ public string LastError
109109
set { _lastError = value; }
110110
}
111111
/// <summary>
112-
/// Last Exception from CRM
112+
/// Last Exception from CRM
113113
/// </summary>
114114
public Exception LastException
115115
{
@@ -118,7 +118,7 @@ public Exception LastException
118118
}
119119

120120
/// <summary>
121-
/// Current Trace level
121+
/// Current Trace level
122122
/// </summary>
123123
public SourceLevels CurrentTraceLevel
124124
{
@@ -137,7 +137,7 @@ protected TraceLoggerBase()
137137
}
138138

139139
/// <summary>
140-
/// Initialize Trace Source
140+
/// Initialize Trace Source
141141
/// </summary>
142142
protected void Initialize()
143143
{
@@ -148,20 +148,20 @@ protected void Initialize()
148148
RefreshListeners(TraceSourceSettingStore.TraceSourceSettingsCollection);
149149
}
150150
}
151-
151+
152152
/// <summary>
153153
/// Reset the last Stored Error
154154
/// </summary>
155155
public abstract void ResetLastError();
156156

157157
/// <summary>
158-
/// Log a Message as an Information event.
158+
/// Log a Message as an Information event.
159159
/// </summary>
160160
/// <param name="message"></param>
161161
public abstract void Log(string message);
162162

163163
/// <summary>
164-
/// Log a Trace event
164+
/// Log a Trace event
165165
/// </summary>
166166
/// <param name="message"></param>
167167
/// <param name="eventType"></param>
@@ -203,13 +203,13 @@ public void RefreshListeners(List<TraceSourceSetting> traceSourceSettingCollecti
203203
#region IDisposable Support
204204

205205
/// <summary>
206-
///
206+
///
207207
/// </summary>
208208
#pragma warning disable CA1063 // Implement IDisposable Correctly
209209
public void Dispose()
210210
#pragma warning restore CA1063 // Implement IDisposable Correctly
211211
{
212-
// Always need this to be called.
212+
// Always need this to be called.
213213
TraceListenerBroker.UnRegisterTraceLogger(this);
214214
}
215215
#endregion

src/GeneralTools/DataverseClient/Client/Utils/DataverseConnectionStringProcessor.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
using System.ServiceModel.Description;
1010
using Microsoft.PowerPlatform.Dataverse.Client.Model;
1111
using Microsoft.PowerPlatform.Dataverse.Client.Auth;
12+
using Microsoft.Extensions.Logging;
1213

1314
namespace Microsoft.PowerPlatform.Dataverse.Client
1415
{
1516
/// <summary>
16-
/// Stores Parsed connection info from the use of a CDS connection string.
17-
/// This is only populated when the CDS Connection string object is used, this is read only.
17+
/// Stores Parsed connection info from the use of a CDS connection string.
18+
/// This is only populated when the CDS Connection string object is used, this is read only.
1819
/// </summary>
1920
internal class DataverseConnectionStringProcessor
2021
{
@@ -120,7 +121,7 @@ internal string Password
120121
internal string CertThumbprint { get; set; }
121122

122123
/// <summary>
123-
/// if set to true, then the org URI should be used directly.
124+
/// if set to true, then the org URI should be used directly.
124125
/// </summary>
125126
internal bool SkipDiscovery { get; set; }
126127

@@ -188,20 +189,20 @@ public string TokenCacheStorePath
188189
}
189190

190191
/// <summary>
191-
/// When true, specifies a unique instance of the connection should be created.
192+
/// When true, specifies a unique instance of the connection should be created.
192193
/// </summary>
193194
public bool UseUniqueConnectionInstance { get; internal set; }
194195

195196
/// <summary>
196-
/// When set to true and oAuth Mode ( not Cert ) attempts to run the login using the current user identity.
197+
/// When set to true and oAuth Mode ( not Cert ) attempts to run the login using the current user identity.
197198
/// </summary>
198199
public bool UseCurrentUser { get; set; }
199200

200201
public DataverseConnectionStringProcessor()
201202
{
202203
}
203204

204-
private DataverseConnectionStringProcessor(IDictionary<string, string> connection)
205+
private DataverseConnectionStringProcessor(IDictionary<string, string> connection , ILogger logger)
205206
: this(
206207
connection.FirstNotNullOrEmpty(ConnectionStringConstants.ServiceUri),
207208
connection.FirstNotNullOrEmpty(ConnectionStringConstants.UserName),
@@ -218,12 +219,13 @@ private DataverseConnectionStringProcessor(IDictionary<string, string> connectio
218219
connection.FirstNotNullOrEmpty(ConnectionStringConstants.CertThumbprint),
219220
connection.FirstNotNullOrEmpty(ConnectionStringConstants.SkipDiscovery),
220221
connection.FirstNotNullOrEmpty(ConnectionStringConstants.IntegratedSecurity),
221-
connection.FirstNotNullOrEmpty(ConnectionStringConstants.ClientSecret)
222+
connection.FirstNotNullOrEmpty(ConnectionStringConstants.ClientSecret),
223+
logger
222224
)
223225
{
224226
}
225227
private DataverseConnectionStringProcessor(string serviceUri, string userName, string password, string domain, string homeRealmUri, string authType, string requireNewInstance, string clientId, string redirectUri,
226-
string tokenCacheStorePath, string loginPrompt, string certStoreName, string certThumbprint, string skipDiscovery, string IntegratedSecurity , string clientSecret)
228+
string tokenCacheStorePath, string loginPrompt, string certStoreName, string certThumbprint, string skipDiscovery, string IntegratedSecurity , string clientSecret , ILogger logger)
227229
{
228230
DataverseTraceLogger logEntry = new DataverseTraceLogger();
229231
Uri _serviceuriName, _realmUri;
@@ -232,7 +234,7 @@ private DataverseConnectionStringProcessor(string serviceUri, string userName, s
232234
if (bool.TryParse(skipDiscovery, out tempbool))
233235
SkipDiscovery = tempbool;
234236
else
235-
SkipDiscovery = true; // changed to change defaulting behavior of skip discovery.
237+
SkipDiscovery = true; // changed to change defaulting behavior of skip discovery.
236238

237239

238240
ServiceUri = GetValidUri(serviceUri, out _serviceuriName) ? _serviceuriName : null;
@@ -247,16 +249,16 @@ private DataverseConnectionStringProcessor(string serviceUri, string userName, s
247249
CertStoreName = certStoreName;
248250
CertThumbprint = certThumbprint;
249251

250-
// Check to see if use current user is configured.
252+
// Check to see if use current user is configured.
251253
bool _IntegratedSecurity = false;
252254
if (!string.IsNullOrEmpty(IntegratedSecurity))
253255
bool.TryParse(IntegratedSecurity, out _IntegratedSecurity);
254256

255-
bool useUniqueConnection = true; // Set default to true to follow the old behavior.
257+
bool useUniqueConnection = true; // Set default to true to follow the old behavior.
256258
if (!string.IsNullOrEmpty(requireNewInstance))
257259
bool.TryParse(requireNewInstance, out useUniqueConnection);
258260
UseUniqueConnectionInstance = useUniqueConnection;
259-
261+
260262
//UserIdentifier = !string.IsNullOrWhiteSpace(UserId) ? new UserIdentifier(UserId, UserIdentifierType.OptionalDisplayableId) : null;
261263

262264
AuthenticationType authenticationType;
@@ -322,7 +324,7 @@ private bool GetValidUri(string uriSource, out Uri validUriResult)
322324
/// <param name="serviceUri"></param>
323325
private void SetOrgnameAndOnlineRegion(Uri serviceUri)
324326
{
325-
// uses publicaly exposed connection parser to parse
327+
// uses publicaly exposed connection parser to parse
326328
string orgRegion = string.Empty;
327329
string orgName = string.Empty;
328330
bool isOnPrem = false;
@@ -334,13 +336,14 @@ private void SetOrgnameAndOnlineRegion(Uri serviceUri)
334336

335337

336338
/// <summary>
337-
/// Parse the connection sting
339+
/// Parse the connection sting
338340
/// </summary>
339341
/// <param name="connectionString"></param>
342+
/// <param name="logger">Logging provider <see cref="ILogger"/></param>
340343
/// <returns></returns>
341-
public static DataverseConnectionStringProcessor Parse(string connectionString )
344+
public static DataverseConnectionStringProcessor Parse(string connectionString , ILogger logger = null)
342345
{
343-
return new DataverseConnectionStringProcessor(connectionString.ToDictionary());
346+
return new DataverseConnectionStringProcessor(connectionString.ToDictionary(), logger);
344347
}
345348

346349
}

0 commit comments

Comments
 (0)