Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Feb 28, 2018
1 parent 1075771 commit 16bc187
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Gu.Reactive.Analyzers/ConstructorAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private static bool TryGetObservableAndCriteriaMismatch(ArgumentListSyntax argum
{
if (context.SemanticModel.GetSymbolSafe(name, context.CancellationToken) is IPropertySymbol property)
{
observed.Item.Add(property);
observed.Item.Add(property).IgnoreReturnValue();
}
}

Expand All @@ -174,7 +174,7 @@ private static bool TryGetObservableAndCriteriaMismatch(ArgumentListSyntax argum
!property.IsGetOnly() &&
!property.IsPrivateSetAssignedInCtorOnly(context.SemanticModel, context.CancellationToken))
{
usedInCriteria.Item.Add(property);
usedInCriteria.Item.Add(property).IgnoreReturnValue();
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Gu.Reactive.Analyzers/Helpers/Walkers/MutationWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public override void VisitArgument(ArgumentSyntax node)
internal static MutationWalker Borrow(SyntaxNode node, ISymbol symbol, SemanticModel semanticModel, CancellationToken cancellationToken)
{
var walker = BorrowAndVisit(node, () => new MutationWalker());
walker.mutations.RemoveAll(x => !IsForSymbol(x, symbol, semanticModel, cancellationToken));
walker.mutations.RemoveAll(x => !IsForSymbol(x, symbol, semanticModel, cancellationToken))
.IgnoreReturnValue();
return walker;
}

Expand Down
5 changes: 3 additions & 2 deletions Gu.Reactive.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma warning disable 162
#pragma warning disable 162
namespace Gu.Reactive.Benchmarks
{
using System;
Expand All @@ -8,6 +8,7 @@ namespace Gu.Reactive.Benchmarks
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using Gu.Reactive.Analyzers;
using Gu.Reactive.Internals;
using Gu.Roslyn.Asserts;

public class Program
Expand All @@ -25,7 +26,7 @@ public static void Main()
// Warmup
benchmark.Run();
Console.WriteLine("Attach profiler and press any key to continue...");
Console.ReadKey();
Console.ReadKey().IgnoreReturnValue();
benchmark.Run();
}
else if (true)
Expand Down
34 changes: 28 additions & 6 deletions Gu.Reactive.Demo/DataGridAndEventsView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
namespace Gu.Reactive.Demo
namespace Gu.Reactive.Demo
{
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows;
using System.Windows.Controls;

/// <summary>
/// Interaction logic for DataGridAndEventsView.xaml
/// </summary>
public partial class DataGridAndEventsView : UserControl
public partial class DataGridAndEventsView : UserControl, IDisposable
{
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
nameof(Source),
Expand All @@ -34,6 +35,9 @@ public partial class DataGridAndEventsView : UserControl
typeof(DataGridAndEventsView),
new PropertyMetadata(default(string)));

private readonly SerialDisposable disposable = new SerialDisposable();
private bool disposed;

public DataGridAndEventsView()
{
this.InitializeComponent();
Expand All @@ -58,6 +62,17 @@ public string Header
set => this.SetValue(HeaderProperty, value);
}

public void Dispose()
{
if (this.disposed)
{
return;
}

this.disposed = true;
this.disposable.Dispose();
}

private static object CoerceSource(DependencyObject d, object basevalue)
{
((DataGridAndEventsView)d).Changes?.Clear();
Expand All @@ -67,10 +82,17 @@ private static object CoerceSource(DependencyObject d, object basevalue)
private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var dataGridAndEventsView = (DataGridAndEventsView)d;
var notifyCollectionChanged = e.NewValue as INotifyCollectionChanged;
notifyCollectionChanged.ObserveCollectionChangedSlim(signalInitial: false)
.ObserveOnDispatcher()
.Subscribe(x => dataGridAndEventsView.Changes.Add(x));
if (e.NewValue is INotifyCollectionChanged notifyCollectionChanged)
{
dataGridAndEventsView.disposable.Disposable = notifyCollectionChanged
.ObserveCollectionChangedSlim(signalInitial: false)
.ObserveOnDispatcher()
.Subscribe(x => dataGridAndEventsView.Changes.Add(x));
}
else
{
dataGridAndEventsView.disposable.Disposable = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public async Task AddToSourceAwait()
using (var actual = view.SubscribeAll())
{
source.Add(4);
await Task.Delay(TimeSpan.FromMilliseconds(20))
.ConfigureAwait(false);
await Task.Delay(TimeSpan.FromMilliseconds(40)).ConfigureAwait(false);
CollectionAssert.AreEqual(source, view);
CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default);
}
Expand Down Expand Up @@ -237,4 +236,4 @@ public async Task WhenManyAddsToSourceWithBufferTime()
}
}
}
}
}
10 changes: 10 additions & 0 deletions Gu.Wpf.Reactive.UiTests/Helpers/Ignore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Gu.Wpf.Reactive.UiTests
{
internal static class Ignore
{
// ReSharper disable once UnusedParameter.Global
internal static void IgnoreReturnValue<T>(this T returnValue)
{
}
}
}
1 change: 1 addition & 0 deletions Gu.Wpf.Reactive.UiTests/MainWindowTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma warning disable GU0011 // Don't ignore the return value.
namespace Gu.Wpf.Reactive.UiTests
{
using Gu.Wpf.UiAutomation;
Expand Down

0 comments on commit 16bc187

Please sign in to comment.