1
0
Steven Kirk 9 жил өмнө
parent
commit
3bf4182007

+ 12 - 7
samples/BindingTest/App.xaml.cs

@@ -2,6 +2,7 @@
 using Perspex;
 using Perspex;
 using Perspex.Controls;
 using Perspex.Controls;
 using Perspex.Diagnostics;
 using Perspex.Diagnostics;
+using Perspex.Logging.Serilog;
 using Perspex.Markup.Xaml;
 using Perspex.Markup.Xaml;
 using Serilog;
 using Serilog;
 using Serilog.Filters;
 using Serilog.Filters;
@@ -15,13 +16,7 @@ namespace BindingTest
             RegisterServices();
             RegisterServices();
             InitializeSubsystems((int)Environment.OSVersion.Platform);
             InitializeSubsystems((int)Environment.OSVersion.Platform);
             InitializeComponent();
             InitializeComponent();
-
-            Log.Logger = new LoggerConfiguration()
-                .Filter.ByIncludingOnly(Matching.WithProperty("Area", "Property"))
-                .Filter.ByIncludingOnly(Matching.WithProperty("Property", "Text"))
-                .MinimumLevel.Verbose()
-                .WriteTo.Trace(outputTemplate: "[{Id:X8}] [{SourceContext}] {Message}")
-                .CreateLogger();
+            InitializeLogging();
         }
         }
 
 
         public static void AttachDevTools(Window window)
         public static void AttachDevTools(Window window)
@@ -41,5 +36,15 @@ namespace BindingTest
         {
         {
             PerspexXamlLoader.Load(this);
             PerspexXamlLoader.Load(this);
         }
         }
+
+        private void InitializeLogging()
+        {
+#if DEBUG
+            SerilogLogger.Initialize(new LoggerConfiguration()
+                .MinimumLevel.Warning()
+                .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
+                .CreateLogger());
+#endif
+        }
     }
     }
 }
 }

+ 4 - 0
samples/BindingTest/BindingTest.csproj

@@ -139,6 +139,10 @@
       <Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project>
       <Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project>
       <Name>Perspex.Layout</Name>
       <Name>Perspex.Layout</Name>
     </ProjectReference>
     </ProjectReference>
+    <ProjectReference Include="..\..\src\Perspex.Logging.Serilog\Perspex.Logging.Serilog.csproj">
+      <Project>{b61b66a3-b82d-4875-8001-89d3394fe0c9}</Project>
+      <Name>Perspex.Logging.Serilog</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\src\Perspex.ReactiveUI\Perspex.ReactiveUI.csproj">
     <ProjectReference Include="..\..\src\Perspex.ReactiveUI\Perspex.ReactiveUI.csproj">
       <Project>{6417b24e-49c2-4985-8db2-3ab9d898ec91}</Project>
       <Project>{6417b24e-49c2-4985-8db2-3ab9d898ec91}</Project>
       <Name>Perspex.ReactiveUI</Name>
       <Name>Perspex.ReactiveUI</Name>

+ 18 - 0
src/Markup/Perspex.Markup/Data/Plugins/InpcPropertyAccessorPlugin.cs

@@ -7,6 +7,7 @@ using System.Linq;
 using System.Reactive.Linq;
 using System.Reactive.Linq;
 using System.Reflection;
 using System.Reflection;
 using Perspex.Data;
 using Perspex.Data;
+using Perspex.Logging;
 using Perspex.Utilities;
 using Perspex.Utilities;
 
 
 namespace Perspex.Markup.Data.Plugins
 namespace Perspex.Markup.Data.Plugins
@@ -57,6 +58,13 @@ namespace Perspex.Markup.Data.Plugins
             }
             }
             else
             else
             {
             {
+                Logger.Error(
+                    LogArea.Binding,
+                    this,
+                    "Could not find CLR property {Property} on {Source}",
+                    propertyName,
+                    instance);
+
                 return null;
                 return null;
             }
             }
         }
         }
@@ -88,6 +96,16 @@ namespace Perspex.Markup.Data.Plugins
                         nameof(inpc.PropertyChanged),
                         nameof(inpc.PropertyChanged),
                         this);
                         this);
                 }
                 }
+                else
+                {
+                    Logger.Warning(
+                        LogArea.Binding,
+                        this,
+                        "Bound to property {Property} on {Source} which does not implement INotifyPropertyChanged",
+                        property.Name,
+                        reference.Target,
+                        reference.Target.GetType());
+                }
             }
             }
 
 
             public Type PropertyType => _property.PropertyType;
             public Type PropertyType => _property.PropertyType;

+ 7 - 0
src/Markup/Perspex.Markup/Data/Plugins/PerspexPropertyAccessorPlugin.cs

@@ -4,6 +4,7 @@
 using System;
 using System;
 using System.Reactive.Linq;
 using System.Reactive.Linq;
 using Perspex.Data;
 using Perspex.Data;
+using Perspex.Logging;
 
 
 namespace Perspex.Markup.Data.Plugins
 namespace Perspex.Markup.Data.Plugins
 {
 {
@@ -53,6 +54,12 @@ namespace Perspex.Markup.Data.Plugins
             }
             }
             else
             else
             {
             {
+                Logger.Error(
+                    LogArea.Binding,
+                    this,
+                    "Could not find PerspexProperty {Property} on {Source}",
+                    propertyName,
+                    instance);
                 return null;
                 return null;
             }
             }
         }
         }

+ 11 - 2
src/Markup/Perspex.Markup/DefaultValueConverter.cs

@@ -5,6 +5,7 @@ using System;
 using System.Globalization;
 using System.Globalization;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
+using Perspex.Logging;
 using Perspex.Utilities;
 using Perspex.Utilities;
 
 
 namespace Perspex.Markup
 namespace Perspex.Markup
@@ -38,10 +39,18 @@ namespace Perspex.Markup
             {
             {
                 return result;
                 return result;
             }
             }
-            else
+
+            if (value != null)
             {
             {
-                return PerspexProperty.UnsetValue;
+                Logger.Error(
+                    LogArea.Binding,
+                    this,
+                    "Could not convert {Value} to {Type}",
+                    value,
+                    targetType);
             }
             }
+
+            return PerspexProperty.UnsetValue;
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 6 - 1
src/Perspex.Base/Logging/LogArea.cs

@@ -9,10 +9,15 @@ namespace Perspex.Logging
     public static class LogArea
     public static class LogArea
     {
     {
         /// <summary>
         /// <summary>
-        /// The log event comes from the property and binding system.
+        /// The log event comes from the property system.
         /// </summary>
         /// </summary>
         public const string Property = "Property";
         public const string Property = "Property";
 
 
+        /// <summary>
+        /// The log event comes from the binding system.
+        /// </summary>
+        public const string Binding = "Binding";
+
         /// <summary>
         /// <summary>
         /// The log event comes from the visual system.
         /// The log event comes from the visual system.
         /// </summary>
         /// </summary>

+ 1 - 1
src/Perspex.Base/Utilities/WeakSubscriptionManager.cs

@@ -114,7 +114,7 @@ namespace Perspex.Utilities
 
 
             void Destroy()
             void Destroy()
             {
             {
-                _info.RemoveEventHandler(_target, _delegate);
+                _info.RemoveMethod.Invoke(_target, new[] { _delegate });
                 _sdic.Remove(_eventName);
                 _sdic.Remove(_eventName);
             }
             }
 
 

+ 1 - 1
src/Perspex.SceneGraph/Media/DrawingContext.cs

@@ -178,7 +178,7 @@ namespace Perspex.Media
         /// <param name="opacity">The opacity.</param>
         /// <param name="opacity">The opacity.</param>
         /// <returns>A disposable used to undo the opacity.</returns>
         /// <returns>A disposable used to undo the opacity.</returns>
         public PushedState PushOpacity(double opacity)
         public PushedState PushOpacity(double opacity)
-            //TODO: Elimintate platform-specific push opacity call
+            //TODO: Eliminate platform-specific push opacity call
         {
         {
             _impl.PushOpacity(opacity);
             _impl.PushOpacity(opacity);
             return new PushedState(this, PushedState.PushedStateType.Opacity);
             return new PushedState(this, PushedState.PushedStateType.Opacity);