Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

housekeeping: Update to Splat v7 #1976

Merged
merged 4 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ReactiveUI.Fody.Tests/FodyWeavers.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ReactiveUI.Fody.deps" minOccurs="0" maxOccurs="1" type="xs:anyType" />
<xs:element name="ReactiveUI" minOccurs="0" maxOccurs="1" type="xs:anyType" />
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ReactiveUI.Tests.Xaml
/// </summary>
public sealed class XamlViewDependencyResolverTests : IDisposable
{
private readonly IMutableDependencyResolver _resolver;
private readonly IDependencyResolver _resolver;

public XamlViewDependencyResolverTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ReactiveUI.Tests.Winforms
{
public sealed class WinFormsViewDependencyResolverTests : IDisposable
{
private readonly IMutableDependencyResolver _resolver;
private readonly IDependencyResolver _resolver;

public WinFormsViewDependencyResolverTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,4 @@ namespace ReactiveUI.Wpf
public Registrations() { }
public void Register(System.Action<System.Func<object>, System.Type> registerFunction) { }
}
}
namespace XamlGeneratedNamespace
{
public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper
{
public GeneratedInternalTypeHelper() { }
protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) { }
protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) { }
protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) { }
protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) { }
protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ReactiveUI.Tests.Wpf
{
public sealed class WpfViewDependencyResolverTests : IDisposable
{
private readonly IMutableDependencyResolver _resolver;
private readonly IDependencyResolver _resolver;

public WpfViewDependencyResolverTests()
{
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI.Tests/Resolvers/DependencyResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ReactiveUI.Tests
{
public sealed class DependencyResolverTests : IDisposable
{
private readonly IMutableDependencyResolver _resolver;
private readonly IDependencyResolver _resolver;

public DependencyResolverTests()
{
Expand Down
12 changes: 11 additions & 1 deletion src/ReactiveUI.Tests/Resolvers/PocoObservableForPropertyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,23 @@ private class TestLogger : ILogger
{
public List<string> LastMessages { get; } = new List<string>();

public LogLevel Level { get; set; }
public LogLevel Level => LogLevel.Debug;

public void Write(Exception exception, string message, Type type, LogLevel logLevel)
{
LastMessages.Add(message);
}

public void Write(string message, LogLevel logLevel)
{
LastMessages.Add(message);
}

public void Write(Exception exception, string message, LogLevel logLevel)
{
LastMessages.Add(message);
}

public void Write([Localizable(false)] string message, [Localizable(false)] Type type, LogLevel logLevel)
{
LastMessages.Add(message);
Expand Down
10 changes: 10 additions & 0 deletions src/ReactiveUI.Tests/Utilities/TestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ public TestLogger()

public LogLevel Level { get; set; }

public void Write(Exception exception, string message, Type type, LogLevel logLevel)
{
Messages.Add(Tuple.Create(message, typeof(TestLogger), logLevel));
}

public void Write(string message, LogLevel logLevel)
{
Messages.Add(Tuple.Create(message, typeof(TestLogger), logLevel));
}

public void Write(Exception exception, string message, LogLevel logLevel)
{
Messages.Add(Tuple.Create(message, typeof(TestLogger), logLevel));
}

public void Write([Localizable(false)] string message, [Localizable(false)] Type type, LogLevel logLevel)
{
Messages.Add(Tuple.Create(message, type, logLevel));
Expand Down
13 changes: 6 additions & 7 deletions src/ReactiveUI.Winforms/ActivationForViewFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.ComponentModel;
using System.Globalization;
using System.Reactive.Linq;
using System.Reflection;
using System.Windows.Forms;
Expand Down Expand Up @@ -58,19 +59,17 @@ public IObservable<bool> GetActivationForView(IActivatable view)
}

// Show a friendly warning in the log that this view will never be activated
this.Log().Warn("Expected a view of type System.Windows.Forms.Control but it is {0}.\r\nYou need to implement your own IActivationForViewFetcher for {0}.", view.GetType());
this.Log().Warn(
CultureInfo.InvariantCulture,
"Expected a view of type System.Windows.Forms.Control but it is {0}.\r\nYou need to implement your own IActivationForViewFetcher for {0}.",
view.GetType());

return Observable<bool>.Empty;
}

private static bool GetIsDesignMode(Control control)
{
var isDesignMode = false;

if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
{
isDesignMode = true;
}
bool isDesignMode = LicenseManager.UsageMode == LicenseUsageMode.Designtime;

if (control.Site?.DesignMode == true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI/Bindings/Converter/EqualityTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public bool TryConvert(object from, Type toType, object conversionHint, out obje
}
catch (Exception ex)
{
this.Log().WarnException("Couldn't convert object to type: " + toType, ex);
this.Log().Warn(ex, "Couldn't convert object to type: " + toType);
RLittlesII marked this conversation as resolved.
Show resolved Hide resolved
result = null;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Reactive.Disposables;
Expand Down Expand Up @@ -488,7 +489,7 @@ object SetThenGet(object paramTarget, object paramValue, object[] paramParams)
.Select(x => (TValue)SetThenGet(x.host, x.val, viewExpression.GetArgumentsArray()));
}

return (setObservable.Subscribe(_ => { }, ex => this.Log().ErrorException($"{viewExpression} Binding received an Exception!", ex)), setObservable);
return (setObservable.Subscribe(_ => { }, ex => this.Log().Error(ex, $"{viewExpression} Binding received an Exception!")), setObservable);
}

private bool EvalBindingHooks<TViewModel, TView>(TViewModel viewModel, TView view, Expression vmExpression, Expression viewExpression, BindingDirection direction)
Expand Down Expand Up @@ -526,7 +527,7 @@ private bool EvalBindingHooks<TViewModel, TView>(TViewModel viewModel, TView vie
{
var vmString = $"{typeof(TViewModel).Name}.{string.Join(".", vmExpression)}";
var vString = $"{typeof(TView).Name}.{string.Join(".", viewExpression)}";
this.Log().Warn("Binding hook asked to disable binding {0} => {1}", vmString, vString);
this.Log().Warn(CultureInfo.InvariantCulture, "Binding hook asked to disable binding {0} => {1}", vmString, vString);
}

return shouldBind;
Expand Down
5 changes: 3 additions & 2 deletions src/ReactiveUI/Legacy/ReactiveDerivedCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurrency;
Expand Down Expand Up @@ -111,8 +112,8 @@ private void WireUpChangeNotifications()
if (!hasWarned.ContainsKey(type))
{
this.Log().Warn(
"{0} doesn't implement INotifyCollectionChanged, derived collection will only update " +
"when the Reset() method is invoked manually or the reset observable is signalled.",
CultureInfo.InvariantCulture,
"{0} doesn't implement INotifyCollectionChanged, derived collection will only update when the Reset() method is invoked manually or the reset observable is signalled.",
type.FullName);
hasWarned.Add(type, true);
}
Expand Down
3 changes: 2 additions & 1 deletion src/ReactiveUI/Legacy/ReactiveList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurrency;
Expand Down Expand Up @@ -878,7 +879,7 @@ private void AddItemToPropertyTracking(T toTrack)
goto isSetup;
}

this.Log().Warn("Property change notifications are enabled and type {0} isn't INotifyPropertyChanged or IReactiveObject", typeof(T));
this.Log().Warn(CultureInfo.InvariantCulture, "Property change notifications are enabled and type {0} isn't INotifyPropertyChanged or IReactiveObject", typeof(T));

isSetup:
var toDispose = new[]
Expand Down
17 changes: 9 additions & 8 deletions src/ReactiveUI/Mixins/ObservableLoggingMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// See the LICENSE file in the project root for full license information.

using System;
using System.Globalization;
using System.Reactive.Linq;
using Splat;

Expand Down Expand Up @@ -36,15 +37,15 @@ public static IObservable<T> Log<T, TObj>(
if (stringifier != null)
{
return @this.Do(
x => klass.Log().Info("{0} OnNext: {1}", message, stringifier(x)),
ex => klass.Log().WarnException(message + " " + "OnError", ex),
() => klass.Log().Info("{0} OnCompleted", message));
x => klass.Log().Info(CultureInfo.InvariantCulture, "{0} OnNext: {1}", message, stringifier(x)),
ex => klass.Log().Warn(ex, message + " " + "OnError"),
RLittlesII marked this conversation as resolved.
Show resolved Hide resolved
() => klass.Log().Info(CultureInfo.InvariantCulture, "{0} OnCompleted", message));
}

return @this.Do(
x => klass.Log().Info("{0} OnNext: {1}", message, x),
ex => klass.Log().WarnException(message + " " + "OnError", ex),
() => klass.Log().Info("{0} OnCompleted", message));
x => klass.Log().Info(CultureInfo.InvariantCulture, "{0} OnNext: {1}", message, x),
ex => klass.Log().Warn(ex, message + " " + "OnError"),
() => klass.Log().Info(CultureInfo.InvariantCulture, "{0} OnCompleted", message));
}

/// <summary>
Expand All @@ -63,7 +64,7 @@ public static IObservable<T> LoggedCatch<T, TObj>(this IObservable<T> @this, TOb
next = next ?? Observable<T>.Default;
return @this.Catch<T, Exception>(ex =>
{
klass.Log().WarnException(message ?? string.Empty, ex);
klass.Log().Warn(ex, message ?? string.Empty);
return next;
});
}
Expand All @@ -86,7 +87,7 @@ public static IObservable<T> LoggedCatch<T, TObj, TException>(this IObservable<T
{
return @this.Catch<T, TException>(ex =>
{
klass.Log().WarnException(message ?? string.Empty, ex);
klass.Log().Warn(ex, message ?? string.Empty);
return next(ex);
});
}
Expand Down
8 changes: 5 additions & 3 deletions src/ReactiveUI/Platforms/apple-common/ReactiveControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ public event PropertyChangedEventHandler PropertyChanged
/// <summary>
/// Gets a observable when the control is activated.
/// </summary>
[SuppressMessage("Design", "CS0108: member hides inherited member", Justification = "Different type.")]
#pragma warning disable CS0108 // member hides inherited member
public IObservable<Unit> Activated => _activated.AsObservable();
#pragma warning restore CS0108

/// <summary>
/// Gets a observable that occurrs when the control is deactivated.
/// Gets a observable that occurs when the control is deactivated.
/// </summary>
[SuppressMessage("Design", "CS0108: member hides inherited member", Justification = "Different type.")]
#pragma warning disable CS0108 // member hides inherited member
public IObservable<Unit> Deactivated => _deactivated.AsObservable();
#pragma warning restore CS0108

#if UIKIT
/// <inheritdoc/>
Expand Down
6 changes: 4 additions & 2 deletions src/ReactiveUI/Platforms/apple-common/ReactiveImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ public event PropertyChangedEventHandler PropertyChanged
public IObservable<Exception> ThrownExceptions => this.GetThrownExceptionsObservable();

/// <inheritdoc/>
[SuppressMessage("Design", "CS0108: member hides inherited member", Justification = "Different type.")]
#pragma warning disable CS0108 // member hides inherited member
public IObservable<Unit> Activated => _activated.AsObservable();
#pragma warning restore CS0108

/// <inheritdoc/>
[SuppressMessage("Design", "CS0108: member hides inherited member", Justification = "Different type.")]
#pragma warning disable CS0108 // member hides inherited member
public IObservable<Unit> Deactivated => _deactivated.AsObservable();
#pragma warning restore CS0108

/// <inheritdoc />
public IObservable<IReactivePropertyChangedEventArgs<ReactiveImageView>> Changing => this.GetChangingObservable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reflection;
using System.Windows;
using Splat;
using Windows.UI.Xaml;

Expand Down Expand Up @@ -44,6 +46,7 @@ public IObservable<IObservedChange<object, object>> GetNotificationForProperty(o
if (depSender == null)
{
this.Log().Warn(
CultureInfo.InvariantCulture,
"Tried to bind DP on a non-DependencyObject. Binding as POCO object",
type.FullName,
propertyName);
Expand All @@ -55,6 +58,7 @@ public IObservable<IObservedChange<object, object>> GetNotificationForProperty(o
if (beforeChanged == true)
{
this.Log().Warn(
CultureInfo.InvariantCulture,
"Tried to bind DO {0}.{1}, but DPs can't do beforeChanged. Binding as POCO object",
type.FullName,
propertyName);
Expand All @@ -67,6 +71,7 @@ public IObservable<IObservedChange<object, object>> GetNotificationForProperty(o
if (dpFetcher == null)
{
this.Log().Warn(
CultureInfo.InvariantCulture,
"Tried to bind DO {0}.{1}, but DP doesn't exist. Binding as POCO object",
type.FullName,
propertyName);
Expand Down
14 changes: 7 additions & 7 deletions src/ReactiveUI/Platforms/uikit-common/CommonReactiveSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public CommonReactiveSource(IUICollViewAdapter<TUIView, TUIViewCell> adapter)
skipInitial: true)
.Subscribe(
_ => SectionInfoChanging(),
ex => this.Log().ErrorException("Error occurred whilst SectionInfo changing.", ex)));
ex => this.Log().Error(ex, "Error occurred whilst SectionInfo changing.")));

_mainDisposables.Add(
this
.WhenAnyValue(x => x.SectionInfo)
.Subscribe(
SectionInfoChanged,
ex => this.Log().ErrorException("Error occurred when SectionInfo changed.", ex)));
ex => this.Log().Error(ex, "Error occurred when SectionInfo changed.")));
}

public IReadOnlyList<TSectionInfo> SectionInfo
Expand Down Expand Up @@ -295,7 +295,7 @@ private void SubscribeToSectionInfoChanges(int sectionInfoId, IReadOnlyList<TSec
// this ensures that if application code itself calls BeginUpdates/EndUpdates on the view before the changes have been applied, those inconsistencies
// between what's in the data source versus what the view believes is in the data source won't trigger any errors because of the outstanding
// BeginUpdates call (calls to BeginUpdates/EndUpdates can be nested)
this.Log().Debug("[#{0}] BeginUpdates", sectionInfoId);
this.Log().Debug(CultureInfo.InvariantCulture, "[#{0}] BeginUpdates", sectionInfoId);
_adapter.BeginUpdates();

applyPendingChangesDisposable.Disposable = RxApp.MainThreadScheduler.Schedule(
Expand All @@ -311,7 +311,7 @@ private void SubscribeToSectionInfoChanges(int sectionInfoId, IReadOnlyList<TSec

_pendingChanges.Add(Tuple.Create(y.Section, new PendingChange(y.Change.EventArgs)));
},
ex => this.Log().Error("[#{0}] Error while watching section collection: {1}", sectionInfoId, ex)));
ex => this.Log().Error(CultureInfo.InvariantCulture, "[#{0}] Error while watching section collection: {1}", sectionInfoId, ex)));

sectionDisposables.Add(isReloading.Connect());
sectionDisposables.Add(anySectionChanged.Connect());
Expand All @@ -322,7 +322,7 @@ private void ApplyPendingChanges(int sectionInfoId)
{
Debug.Assert(Thread.CurrentThread.ManagedThreadId == _mainThreadId, "The thread is not the main thread.");
Debug.Assert(_isCollectingChanges, "Currently there are no changes to collect");
this.Log().Debug("[#{0}] Applying pending changes", sectionInfoId);
this.Log().Debug(CultureInfo.InvariantCulture, "[#{0}] Applying pending changes", sectionInfoId);

try
{
Expand All @@ -331,7 +331,7 @@ private void ApplyPendingChanges(int sectionInfoId)
{
if (IsDebugEnabled)
{
this.Log().Debug("[#{0}] The pending changes (in order received) are:", sectionInfoId);
this.Log().Debug(CultureInfo.InvariantCulture, "[#{0}] The pending changes (in order received) are:", sectionInfoId);

foreach (var pendingChange in _pendingChanges)
{
Expand Down Expand Up @@ -360,7 +360,7 @@ private void ApplyPendingChanges(int sectionInfoId)

if (allSectionChanges.Any(x => x.Action == NotifyCollectionChangedAction.Reset))
{
this.Log().Debug("[#{0}] Section {1} included a reset notification, so reloading that section.", sectionInfoId, section);
this.Log().Debug(CultureInfo.InvariantCulture, "[#{0}] Section {1} included a reset notification, so reloading that section.", sectionInfoId, section);
_adapter.ReloadSections(new NSIndexSet((nuint)section));
continue;
}
Expand Down
Loading