Skip to content

Commit 7c048b4

Browse files
authored
Port changes from VS where we stopped using custom tracing event arguments class based on BinaryFormatter (#40849)
2 parents 1b6d660 + 87a0c57 commit 7c048b4

File tree

1 file changed

+14
-55
lines changed

1 file changed

+14
-55
lines changed

src/WebSdk/Publish/Tasks/Tasks/MsDeploy/VsMsdeploy.cs

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -450,76 +450,29 @@ protected override void BeforeSync()
450450

451451

452452
// Utility function to log all public instance property to CustomerBuildEventArgs
453-
private static void AddAllPropertiesToCustomBuildWithPropertyEventArgs(CustomBuildWithPropertiesEventArgs cbpEventArg, object obj)
453+
private static void AddAllPropertiesToCustomBuildWithPropertyEventArgs(ExtendedCustomBuildEventArgs cbpEventArg, object obj)
454454
{
455455
#if NET472
456456
if (obj != null)
457457
{
458458
System.Type thisType = obj.GetType();
459-
cbpEventArg.Add("ArgumentType", thisType.ToString());
459+
cbpEventArg.ExtendedMetadata["ArgumentType"] = thisType.ToString();
460460
System.Reflection.MemberInfo[] arrayMemberInfo = thisType.FindMembers(System.Reflection.MemberTypes.Property, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, null);
461461
if (arrayMemberInfo != null)
462462
{
463463
foreach (System.Reflection.MemberInfo memberinfo in arrayMemberInfo)
464464
{
465465
object val = thisType.InvokeMember(memberinfo.Name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty, null, obj, null, System.Globalization.CultureInfo.InvariantCulture);
466466
if (val != null)
467-
cbpEventArg.Add(memberinfo.Name, val);
467+
{
468+
cbpEventArg.ExtendedMetadata[memberinfo.Name] = val.ToString();
469+
}
468470
}
469471
}
470472
}
471473
#endif
472474
}
473475

474-
475-
///// <summary>
476-
///// Log Trace ifnormation in the command line
477-
///// </summary>
478-
///// <param name="e"></param>
479-
//protected override void LogTrace(Microsoft.Web.Deployment.DeploymentTraceEventArgs args)
480-
//{
481-
// string strMsg = args.Message;
482-
// string strEventType = "Trace";
483-
// Framework.MessageImportance messageImportance = Microsoft.Build.Framework.MessageImportance.Low;
484-
485-
// if (args is Deployment.DeploymentFileSerializationEventArgs ||
486-
// args is Deployment.DeploymentPackageSerializationEventArgs ||
487-
// args is Deployment.DeploymentObjectChangedEventArgs ||
488-
// args is Deployment.DeploymentSyncParameterEventArgs )
489-
// {
490-
// //promote those message only for those event
491-
// strEventType = "Action";
492-
// messageImportance = Microsoft.Build.Framework.MessageImportance.High;
493-
// }
494-
495-
// if (!string.IsNullOrEmpty(strMsg))
496-
// {
497-
// switch (args.EventLevel)
498-
// {
499-
// case System.Diagnostics.TraceLevel.Off:
500-
// break;
501-
// case System.Diagnostics.TraceLevel.Error:
502-
// _host.Log.LogError(strMsg);
503-
// break;
504-
// case System.Diagnostics.TraceLevel.Warning:
505-
// _host.Log.LogWarning(strMsg);
506-
// break;
507-
// default: // Is Warning is a Normal message
508-
// _host.Log.LogMessageFromText(strMsg, messageImportance);
509-
// break;
510-
511-
// }
512-
// }
513-
// // additionally we fire the Custom event for the detail information
514-
// CustomBuildWithPropertiesEventArgs customBuildWithPropertiesEventArg = new CustomBuildWithPropertiesEventArgs(args.Message, null, TaskName);
515-
516-
// customBuildWithPropertiesEventArg.Add("TaskName", TaskName);
517-
// customBuildWithPropertiesEventArg.Add("EventType", strEventType);
518-
// AddAllPropertiesToCustomBuildWithPropertyEventArgs(customBuildWithPropertiesEventArg, args);
519-
// _host.BuildEngine.LogCustomEvent(customBuildWithPropertiesEventArg);
520-
//}
521-
522-
523476
protected override void LogTrace(dynamic args, System.Collections.Generic.IDictionary<string, Microsoft.Build.Framework.MessageImportance> customTypeLoging)
524477
{
525478
string strMsg = args.Message;
@@ -561,11 +514,17 @@ protected override void LogTrace(dynamic args, System.Collections.Generic.IDicti
561514

562515
}
563516
}
517+
564518
// additionally we fire the Custom event for the detail information
565-
CustomBuildWithPropertiesEventArgs customBuildWithPropertiesEventArg = new(args.Message, null, TaskName);
519+
var customBuildWithPropertiesEventArg = new ExtendedCustomBuildEventArgs(args.GetType().ToString(), args.Message, null, TaskName)
520+
{
521+
ExtendedMetadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
522+
{
523+
{ "TaskName", TaskName },
524+
{ "EventType", strEventType }
525+
}
526+
};
566527

567-
customBuildWithPropertiesEventArg.Add("TaskName", TaskName);
568-
customBuildWithPropertiesEventArg.Add("EventType", strEventType);
569528
AddAllPropertiesToCustomBuildWithPropertyEventArgs(customBuildWithPropertiesEventArg, args);
570529
_host.BuildEngine.LogCustomEvent(customBuildWithPropertiesEventArg);
571530
}

0 commit comments

Comments
 (0)