diff --git a/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb b/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb index 061c6aebde0..ef58e4c9003 100644 --- a/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb +++ b/src/Microsoft.VisualStudio.AppDesigner/Common/Utils.vb @@ -4,6 +4,7 @@ Imports System.ComponentModel.Design Imports System.Drawing Imports System.IO Imports System.Reflection +Imports System.Runtime.CompilerServices Imports System.Runtime.InteropServices Imports System.Text.RegularExpressions Imports System.Windows.Forms @@ -626,6 +627,12 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon Private Const UNKNOWN_PAGE As Byte = &HFF Private Const DEFAULT_PAGE As Byte = 0 + Private Const ProjectSystemEventNamePrefix As String = "vs/projectsystem/" + Private Const AppDesignerEventNamePrefix As String = ProjectSystemEventNamePrefix + "appdesigner/" + + Private Const ProjectSystemPropertyNamePrefix As String = "vs.projectsystem." + Private Const AppDesignerPropertyNamePrefix As String = ProjectSystemPropertyNamePrefix + "appdesigner." + ''' ''' Map a known property page or designer id to telemetry display name to log. ''' @@ -648,33 +655,53 @@ Namespace Microsoft.VisualStudio.Editors.AppDesCommon LogAppDesignerPageOpened(pageId, pageGuid, tabTitle, alreadyOpened) End Sub + Private Const PageOpenedEventName As String = AppDesignerEventNamePrefix + "page-opened" + Private Const PageOpenedPropertyName As String = AppDesignerPropertyNamePrefix + "page-opened" + Private Const PageOpenedPropertyNamePrefix As String = PageOpenedPropertyName + "." + Private Shared Sub LogAppDesignerPageOpened(pageId As Byte, Optional pageGuid As Guid? = Nothing, Optional tabTitle As String = Nothing, Optional alreadyOpened As Boolean = False) - Dim userTask = New UserTaskEvent("vs/projectsystem/appdesigner/page-opened", TelemetryResult.Success) - userTask.Properties("vs.projectsystem.appdesigner.page-opened") = pageId + Dim userTask = New UserTaskEvent(PageOpenedEventName, TelemetryResult.Success) + userTask.Properties(PageOpenedPropertyName) = pageId If pageGuid IsNot Nothing Then - userTask.Properties("vs.projectsystem.appdesigner.page-opened.pageguid") = pageGuid.Value.ToString() + userTask.Properties(PageOpenedPropertyNamePrefix + "pageguid") = pageGuid.Value.ToString() End If If tabTitle IsNot Nothing Then - userTask.Properties("vs.projectsystem.appdesigner.page-opened.tabtitle") = tabTitle + userTask.Properties(PageOpenedPropertyNamePrefix + "tabtitle") = tabTitle End If - userTask.Properties("vs.projectsystem.appdesigner.page-opened.alreadyopened") = alreadyOpened + userTask.Properties(PageOpenedPropertyNamePrefix + "alreadyopened") = alreadyOpened TelemetryService.DefaultSession.PostEvent(userTask) End Sub - Public Shared Sub LogEditorCreation(useNewEditor As Boolean, fileName As String, physicalView As String) - Dim telemetryEventRootPath As String = "vs/projectsystem/propertiespages/" - Dim telemetryPropertyPrefix As String = "vs.projectsystem.propertiespages." + Private Const EditorCreationEventName As String = ProjectSystemEventNamePrefix + "propertiespages/createEditor" + Private Const EditorCreationPropertyNamePrefix As String = ProjectSystemPropertyNamePrefix + "propertiespages.createEditor." - Dim telemetryEvent As TelemetryEvent = New TelemetryEvent(telemetryEventRootPath + "createEditor") - telemetryEvent.Properties(telemetryPropertyPrefix + "createEditor.UseNewEditor") = useNewEditor - telemetryEvent.Properties(telemetryPropertyPrefix + "createEditor.FileName") = New TelemetryPiiProperty(fileName) - telemetryEvent.Properties(telemetryPropertyPrefix + "createEditor.PhysicalView") = physicalView + Public Shared Sub LogEditorCreation(useNewEditor As Boolean, fileName As String, physicalView As String) + Dim telemetryEvent As TelemetryEvent = New TelemetryEvent(EditorCreationEventName) + telemetryEvent.Properties(EditorCreationPropertyNamePrefix + "UseNewEditor") = useNewEditor + telemetryEvent.Properties(EditorCreationPropertyNamePrefix + "FileName") = New TelemetryPiiProperty(fileName) + telemetryEvent.Properties(EditorCreationPropertyNamePrefix + "PhysicalView") = physicalView TelemetryService.DefaultSession.PostEvent(telemetryEvent) End Sub + + Private Const BinaryFormatterEventName As String = AppDesignerEventNamePrefix + "binaryformatter" + Private Const BinaryFormatterPropertyNamePrefix As String = AppDesignerPropertyNamePrefix + "binaryformatter." + Public Enum BinaryFormatterOperation + Serialize = 0 + Deserialize = 1 + End Enum + + Public Shared Sub LogBinaryFormatterEvent(className As String, operation As BinaryFormatterOperation, Optional functionName As String = Nothing) + Dim userTask = New UserTaskEvent(BinaryFormatterEventName, TelemetryResult.Success) + userTask.Properties(BinaryFormatterPropertyNamePrefix + "functionname") = functionName + userTask.Properties(BinaryFormatterPropertyNamePrefix + "classname") = className + userTask.Properties(BinaryFormatterPropertyNamePrefix + "operation") = operation + TelemetryService.DefaultSession.PostEvent(userTask) + End Sub + End Class #End Region diff --git a/src/Microsoft.VisualStudio.AppDesigner/PropPageDesigner/PropertyPageSerializationService_Store.vb b/src/Microsoft.VisualStudio.AppDesigner/PropPageDesigner/PropertyPageSerializationService_Store.vb index a9604da3527..4ce9674a0fd 100644 --- a/src/Microsoft.VisualStudio.AppDesigner/PropPageDesigner/PropertyPageSerializationService_Store.vb +++ b/src/Microsoft.VisualStudio.AppDesigner/PropPageDesigner/PropertyPageSerializationService_Store.vb @@ -5,6 +5,7 @@ Imports System.ComponentModel.Design Imports System.IO Imports System.Runtime.Serialization Imports System.Runtime.Serialization.Formatters.Binary +Imports Microsoft.VisualStudio.Editors.AppDesCommon Namespace Microsoft.VisualStudio.Editors.PropPageDesigner @@ -130,8 +131,9 @@ Namespace Microsoft.VisualStudio.Editors.PropPageDesigner ''' ''' The stream to load from Public Shared Function Load(Stream As Stream) As PropertyPageSerializationStore - Dim f As New BinaryFormatter - Return DirectCast(f.Deserialize(Stream), PropertyPageSerializationStore) + TelemetryLogger.LogBinaryFormatterEvent(NameOf(PropertyPageSerializationStore), TelemetryLogger.BinaryFormatterOperation.Deserialize) + + Return DirectCast((New BinaryFormatter).Deserialize(Stream), PropertyPageSerializationStore) End Function ''' @@ -144,8 +146,9 @@ Namespace Microsoft.VisualStudio.Editors.PropPageDesigner Public Overrides Sub Save(Stream As Stream) Close() - Dim f As New BinaryFormatter - f.Serialize(Stream, Me) + TelemetryLogger.LogBinaryFormatterEvent(NameOf(PropertyPageSerializationStore), TelemetryLogger.BinaryFormatterOperation.Serialize) + + Call (New BinaryFormatter).Serialize(Stream, Me) End Sub #End Region @@ -507,6 +510,8 @@ Namespace Microsoft.VisualStudio.Editors.PropPageDesigner ''' The object to serialize ''' The binary serialized object. Private Shared Function SerializeObject([Object] As Object) As Byte() + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedProperty), TelemetryLogger.BinaryFormatterOperation.Serialize) + Dim MemoryStream As New MemoryStream Call (New BinaryFormatter).Serialize(MemoryStream, [Object]) Return MemoryStream.ToArray() @@ -521,6 +526,8 @@ Namespace Microsoft.VisualStudio.Editors.PropPageDesigner Throw New Package.InternalException End If + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedProperty), TelemetryLogger.BinaryFormatterOperation.Deserialize) + Dim MemoryStream As New MemoryStream(_serializedValue) Return DirectCast((New BinaryFormatter).Deserialize(MemoryStream), PropPageDesignerRootComponent) End Function @@ -538,6 +545,8 @@ Namespace Microsoft.VisualStudio.Editors.PropPageDesigner Return Nothing End If + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedProperty), TelemetryLogger.BinaryFormatterOperation.Deserialize) + Dim MemoryStream As New MemoryStream(_serializedValue) Return (New BinaryFormatter).Deserialize(MemoryStream) End Function diff --git a/src/Microsoft.VisualStudio.Editors/Common/Utils.vb b/src/Microsoft.VisualStudio.Editors/Common/Utils.vb index 365f4be4493..94a24d51055 100644 --- a/src/Microsoft.VisualStudio.Editors/Common/Utils.vb +++ b/src/Microsoft.VisualStudio.Editors/Common/Utils.vb @@ -4,6 +4,7 @@ Imports System.ComponentModel.Design Imports System.Drawing Imports System.Drawing.Imaging Imports System.IO +Imports System.Runtime.CompilerServices Imports System.Runtime.InteropServices Imports System.Runtime.Versioning Imports System.Text @@ -1611,7 +1612,13 @@ Namespace Microsoft.VisualStudio.Editors.Common #Region "Telemetry" Public Class TelemetryLogger - Private Const InputXmlFormEventName As String = "vs/projectsystem/editors/inputxmlform" + Private Const ProjectSystemEventNamePrefix As String = "vs/projectsystem/" + Private Const EditorsEventNamePrefix As String = ProjectSystemEventNamePrefix + "editors/" + + Private Const ProjectSystemPropertyNamePrefix As String = "vs.projectsystem." + Private Const EditorsPropertyNamePrefix As String = ProjectSystemPropertyNamePrefix + "editors." + + Private Const InputXmlFormEventName As String = EditorsEventNamePrefix + "inputxmlform" Public Enum InputXmlFormEvent FormOpened FromFileButtonClicked @@ -1621,7 +1628,7 @@ Namespace Microsoft.VisualStudio.Editors.Common Public Shared Sub LogInputXmlFormEvent(eventValue As InputXmlFormEvent) Dim userTask = New UserTaskEvent(InputXmlFormEventName, TelemetryResult.Success) - userTask.Properties("vs.projectsystem.editors.inputxmlform") = eventValue + userTask.Properties(EditorsPropertyNamePrefix + "inputxmlform") = eventValue TelemetryService.DefaultSession.PostEvent(userTask) End Sub @@ -1629,7 +1636,7 @@ Namespace Microsoft.VisualStudio.Editors.Common TelemetryService.DefaultSession.PostFault(InputXmlFormEventName, "Exception encountered during Xml Schema Inference", ex) End Sub - Private Const AdvBuildSettingsPropPageEventName As String = "vs/projectsystem/appdesigner/advbuildsettingsproppage" + Private Const AdvBuildSettingsPropPageEventName As String = ProjectSystemEventNamePrefix + "appdesigner/advbuildsettingsproppage" Public Enum AdvBuildSettingsPropPageEvent FormOpened = 0 LangVersionMoreInfoLinkClicked = 1 @@ -1637,7 +1644,22 @@ Namespace Microsoft.VisualStudio.Editors.Common Public Shared Sub LogAdvBuildSettingsPropPageEvent(eventValue As AdvBuildSettingsPropPageEvent) Dim userTask = New UserTaskEvent(AdvBuildSettingsPropPageEventName, TelemetryResult.Success) - userTask.Properties("vs.projectsystem.appdesigner.advbuildsettingsproppage") = eventValue + userTask.Properties(ProjectSystemPropertyNamePrefix + "appdesigner.advbuildsettingsproppage") = eventValue + TelemetryService.DefaultSession.PostEvent(userTask) + End Sub + + Private Const BinaryFormatterEventName As String = EditorsEventNamePrefix + "binaryformatter" + Private Const BinaryFormatterPropertyNamePrefix As String = EditorsPropertyNamePrefix + "binaryformatter." + Public Enum BinaryFormatterOperation + Serialize = 0 + Deserialize = 1 + End Enum + + Public Shared Sub LogBinaryFormatterEvent(className As String, operation As BinaryFormatterOperation, Optional functionName As String = Nothing) + Dim userTask = New UserTaskEvent(BinaryFormatterEventName, TelemetryResult.Success) + userTask.Properties(BinaryFormatterPropertyNamePrefix + "functionname") = functionName + userTask.Properties(BinaryFormatterPropertyNamePrefix + "classname") = className + userTask.Properties(BinaryFormatterPropertyNamePrefix + "operation") = operation TelemetryService.DefaultSession.PostEvent(userTask) End Sub diff --git a/src/Microsoft.VisualStudio.Editors/DesignerFramework/GenericComponentSerializationStore.vb b/src/Microsoft.VisualStudio.Editors/DesignerFramework/GenericComponentSerializationStore.vb index 7703acb035a..1285a1c93b2 100644 --- a/src/Microsoft.VisualStudio.Editors/DesignerFramework/GenericComponentSerializationStore.vb +++ b/src/Microsoft.VisualStudio.Editors/DesignerFramework/GenericComponentSerializationStore.vb @@ -5,6 +5,7 @@ Imports System.ComponentModel.Design.Serialization Imports System.IO Imports System.Runtime.Serialization Imports System.Runtime.Serialization.Formatters.Binary +Imports Microsoft.VisualStudio.Editors.Common Namespace Microsoft.VisualStudio.Editors.DesignerFramework @@ -110,8 +111,9 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework ''' ''' The stream to load from Public Shared Function Load(Stream As Stream) As GenericComponentSerializationStore - Dim f As New BinaryFormatter - Return DirectCast(f.Deserialize(Stream), GenericComponentSerializationStore) + TelemetryLogger.LogBinaryFormatterEvent(NameOf(GenericComponentSerializationStore), TelemetryLogger.BinaryFormatterOperation.Deserialize) + + Return DirectCast((New BinaryFormatter).Deserialize(Stream), GenericComponentSerializationStore) End Function ''' @@ -124,8 +126,9 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework Public Overrides Sub Save(Stream As Stream) Close() - Dim f As New BinaryFormatter - f.Serialize(Stream, Me) + TelemetryLogger.LogBinaryFormatterEvent(NameOf(GenericComponentSerializationStore), TelemetryLogger.BinaryFormatterOperation.Serialize) + + Call (New BinaryFormatter).Serialize(Stream, Me) End Sub #End Region @@ -468,8 +471,10 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework If [Object] Is Nothing Then Return Array.Empty(Of Byte) Else + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedObjectData), TelemetryLogger.BinaryFormatterOperation.Serialize) + Dim MemoryStream As New MemoryStream - Call New BinaryFormatter().Serialize(MemoryStream, [Object]) + Call (New BinaryFormatter).Serialize(MemoryStream, [Object]) Return MemoryStream.ToArray() End If End Function @@ -478,6 +483,8 @@ Namespace Microsoft.VisualStudio.Editors.DesignerFramework If _serializedValue.Length = 0 Then Return Nothing Else + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedObjectData), TelemetryLogger.BinaryFormatterOperation.Deserialize) + Dim MemoryStream As New MemoryStream(_serializedValue) Return (New BinaryFormatter).Deserialize(MemoryStream) End If diff --git a/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorView.vb b/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorView.vb index 59499189a57..ec1ebc8b25a 100644 --- a/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorView.vb +++ b/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceEditorView.vb @@ -10,6 +10,7 @@ Imports System.Globalization Imports System.IO Imports System.Reflection Imports System.Runtime.InteropServices +Imports System.Runtime.Serialization.Formatters.Binary Imports System.Text Imports System.Windows.Forms Imports System.Windows.Forms.Design @@ -2491,10 +2492,11 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor '1) Create a structure with our raw resources data (our preferred format) Dim ResourcesData As New ResourcesDataFormat(Resources) + TelemetryLogger.LogBinaryFormatterEvent(NameOf(ResourceEditorView), TelemetryLogger.BinaryFormatterOperation.Serialize) + '... then package it into a serialized blob - Dim Formatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter Dim Stream As New MemoryStream - Formatter.Serialize(Stream, ResourcesData) + Call (New BinaryFormatter).Serialize(Stream, ResourcesData) '... and stuff into a DataObject Stream.Seek(0, SeekOrigin.Begin) @@ -2989,11 +2991,12 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor Return End If + TelemetryLogger.LogBinaryFormatterEvent(NameOf(ResourceEditorView), TelemetryLogger.BinaryFormatterOperation.Deserialize) + 'Decode the data format Dim RawBytes() As Byte = DirectCast(Data.GetData(_CF_RESOURCES), Byte()) Dim MemoryStream As New MemoryStream(RawBytes) - Dim Formatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter - Dim ResourcesData As ResourcesDataFormat = DirectCast(Formatter.Deserialize(MemoryStream), ResourcesDataFormat) + Dim ResourcesData As ResourcesDataFormat = DirectCast((New BinaryFormatter).Deserialize(MemoryStream), ResourcesDataFormat) 'Okay, we have our copied resources, let's add them AddResources(ResourcesData.Resources, CopyFileIfExists, AddToProject:=True) diff --git a/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceSerializationService_Store.vb b/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceSerializationService_Store.vb index 4da03fd3c43..9df433c5a7a 100644 --- a/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceSerializationService_Store.vb +++ b/src/Microsoft.VisualStudio.Editors/ResourceEditor/ResourceSerializationService_Store.vb @@ -7,6 +7,7 @@ Imports System.ComponentModel Imports System.IO Imports System.Runtime.Serialization Imports System.Runtime.Serialization.Formatters.Binary +Imports Microsoft.VisualStudio.Editors.Common Namespace Microsoft.VisualStudio.Editors.ResourceEditor @@ -166,8 +167,9 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor ''' ''' The stream to load from Public Shared Function Load(Stream As Stream) As ResourceSerializationStore - Dim f As New BinaryFormatter - Return DirectCast(f.Deserialize(Stream), ResourceSerializationStore) + TelemetryLogger.LogBinaryFormatterEvent(NameOf(ResourceSerializationStore), TelemetryLogger.BinaryFormatterOperation.Deserialize) + + Return DirectCast((New BinaryFormatter).Deserialize(Stream), ResourceSerializationStore) End Function ''' @@ -180,8 +182,9 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor Public Overrides Sub Save(Stream As Stream) Close() - Dim f As New BinaryFormatter - f.Serialize(Stream, Me) + TelemetryLogger.LogBinaryFormatterEvent(NameOf(ResourceSerializationStore), TelemetryLogger.BinaryFormatterOperation.Serialize) + + Call (New BinaryFormatter).Serialize(Stream, Me) Trace("Saved store") End Sub @@ -579,6 +582,8 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor ''' The object to serialize ''' The binary serialized object. Private Shared Function SerializeObject([Object] As Object) As Byte() + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedResourceOrProperty), TelemetryLogger.BinaryFormatterOperation.Serialize) + Dim MemoryStream As New MemoryStream Call (New BinaryFormatter).Serialize(MemoryStream, [Object]) Return MemoryStream.ToArray() @@ -593,6 +598,8 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor Throw New Package.InternalException End If + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedResourceOrProperty), TelemetryLogger.BinaryFormatterOperation.Deserialize) + Dim MemoryStream As New MemoryStream(_serializedValue) Return DirectCast((New BinaryFormatter).Deserialize(MemoryStream), Resource) End Function @@ -610,6 +617,8 @@ Namespace Microsoft.VisualStudio.Editors.ResourceEditor Return Nothing End If + TelemetryLogger.LogBinaryFormatterEvent(NameOf(SerializedResourceOrProperty), TelemetryLogger.BinaryFormatterOperation.Deserialize) + Dim MemoryStream As New MemoryStream(_serializedValue) Return (New BinaryFormatter).Deserialize(MemoryStream) End Function