Skip to content

Commit 9d73fba

Browse files
authored
Housekeeping: Update Obsolete notation to fix warnings (#3561)
1 parent c5742c8 commit 9d73fba

28 files changed

+166
-144
lines changed

src/Directory.build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545

4646
<ItemGroup Condition="$(IsTestProject)">
4747
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
48-
<PackageReference Include="xunit" Version="2.4.2" />
49-
<PackageReference Include="xunit.runner.console" Version="2.4.2" />
50-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
48+
<PackageReference Include="xunit" Version="2.5.0" />
49+
<PackageReference Include="xunit.runner.console" Version="2.5.0" />
50+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0" />
5151
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
5252
<PackageReference Include="FluentAssertions" Version="6.11.0" />
5353
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0" />

src/Directory.build.targets

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,9 @@
1010
<PropertyGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
1111
<DefineConstants>$(DefineConstants);NETSTANDARD;PORTABLE</DefineConstants>
1212
</PropertyGroup>
13-
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))">
14-
<DefineConstants>$(DefineConstants);NETCOREAPP</DefineConstants>
15-
</PropertyGroup>
16-
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp2'))">
17-
<DefineConstants>$(DefineConstants);NETCOREAPP2</DefineConstants>
18-
</PropertyGroup>
19-
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp3'))">
20-
<DefineConstants>$(DefineConstants);NETCOREAPP3</DefineConstants>
21-
</PropertyGroup>
2213
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
2314
<DefineConstants>$(DefineConstants);NET_461;XAML</DefineConstants>
2415
</PropertyGroup>
25-
<PropertyGroup Condition="$(TargetFramework.StartsWith('uap'))">
26-
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
27-
<DefineConstants>$(DefineConstants);NETFX_CORE;XAML;WINDOWS_UWP</DefineConstants>
28-
</PropertyGroup>
2916
<PropertyGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS'))">
3017
<DefineConstants>$(DefineConstants);MONO;UIKIT;COCOA;IOS</DefineConstants>
3118
</PropertyGroup>

src/ReactiveUI.Blend/ReactiveUI.Blend.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
</ItemGroup>
1717

1818
<ItemGroup Condition=" $(TargetFramework.StartsWith('net4')) ">
19-
<Compile Include="Platforms\net4\**\*.cs" />
2019
<Reference Include="PresentationFramework.Aero" />
21-
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
2220
</ItemGroup>
2321

24-
<ItemGroup Condition="$(TargetFramework.EndsWith('-windows10.0.17763.0'))">
22+
<ItemGroup>
2523
<Compile Include="Platforms\net4\**\*.cs" />
2624
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
2725
</ItemGroup>

src/ReactiveUI.Fody.Analyzer/ReactiveUI.Fody.Analyzer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<PackageDescription>Rosyln extension that checks correct usage of the Fody extension.</PackageDescription>
77
<PackageTags>mvvm;reactiveui;rx;reactive extensions;observable;LINQ;events;frp;xamarin;android;ios;mac;forms;monodroid;monotouch;xamarin.android;xamarin.ios;xamarin.forms;xamarin.mac;xamarin.tvos;wpf;net;netstandard;net472;uwp;tizen;unoplatform;fody;</PackageTags>
88
<IsPackable>False</IsPackable>
9+
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void Execute()
9999
targetType.Fields.Add(field);
100100

101101
// It's an auto-property, so remove the generated field
102-
if (property.SetMethod is not null && property.SetMethod.HasBody)
102+
if (property.SetMethod?.HasBody == true)
103103
{
104104
// Remove old field (the generated backing field for the auto property)
105105
var oldField = (FieldReference)property.GetMethod.Body.Instructions.Single(x => x.Operand is FieldReference).Operand;
@@ -188,4 +188,4 @@ public void EmitDefaultValue(MethodBody methodBody, ILProcessor il, TypeReferenc
188188
}
189189
}
190190
}
191-
}
191+
}

src/ReactiveUI.Fody/ReactiveDependencyPropertyWeaver.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,9 @@ public void Execute()
7777
var reactiveObject = new TypeReference("ReactiveUI", "IReactiveObject", ModuleDefinition, reactiveUI);
7878

7979
var targetTypes = ModuleDefinition.GetAllTypes().Where(x => x.BaseType is not null && reactiveObject.IsAssignableFrom(x.BaseType)).ToArray();
80-
var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve();
81-
if (reactiveObjectExtensions is null)
82-
{
83-
throw new Exception("reactiveObjectExtensions is null");
84-
}
85-
86-
var raisePropertyChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaisePropertyChanged"));
87-
if (raisePropertyChangedMethod is null)
88-
{
89-
throw new Exception("raisePropertyChangedMethod is null");
90-
}
91-
92-
var reactiveDependencyAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveDependencyAttribute", helpers);
93-
if (reactiveDependencyAttribute is null)
94-
{
95-
throw new Exception("reactiveDecoratorAttribute is null");
96-
}
97-
80+
var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve() ?? throw new Exception("reactiveObjectExtensions is null");
81+
var raisePropertyChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaisePropertyChanged")) ?? throw new Exception("raisePropertyChangedMethod is null");
82+
var reactiveDependencyAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveDependencyAttribute", helpers) ?? throw new Exception("reactiveDecoratorAttribute is null");
9883
foreach (var targetType in targetTypes.Where(x => x.Properties.Any(y => y.IsDefined(reactiveDependencyAttribute))).ToArray())
9984
{
10085
foreach (var facadeProperty in targetType.Properties.Where(x => x.IsDefined(reactiveDependencyAttribute)).ToArray())
@@ -240,4 +225,4 @@ public void Execute()
240225
}
241226
}
242227
}
243-
}
228+
}

src/ReactiveUI.Fody/ReactiveUIPropertyWeaver.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,9 @@ public void Execute()
7979
LogInfo?.Invoke($"{helpers.Name} {helpers.Version}");
8080
var reactiveObject = new TypeReference("ReactiveUI", "IReactiveObject", ModuleDefinition, reactiveUI);
8181
var targetTypes = ModuleDefinition.GetAllTypes().Where(x => x.BaseType is not null && reactiveObject.IsAssignableFrom(x.BaseType)).ToArray();
82-
var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve();
83-
if (reactiveObjectExtensions is null)
84-
{
85-
throw new Exception("reactiveObjectExtensions is null");
86-
}
87-
88-
var raiseAndSetIfChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaiseAndSetIfChanged"));
89-
if (raiseAndSetIfChangedMethod is null)
90-
{
91-
throw new Exception("raiseAndSetIfChangedMethod is null");
92-
}
93-
94-
var reactiveAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveAttribute", helpers);
95-
if (reactiveAttribute is null)
96-
{
97-
throw new Exception("reactiveAttribute is null");
98-
}
99-
82+
var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve() ?? throw new Exception("reactiveObjectExtensions is null");
83+
var raiseAndSetIfChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaiseAndSetIfChanged")) ?? throw new Exception("raiseAndSetIfChangedMethod is null");
84+
var reactiveAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveAttribute", helpers) ?? throw new Exception("reactiveAttribute is null");
10085
foreach (var targetType in targetTypes)
10186
{
10287
foreach (var property in targetType.Properties.Where(x => x.IsDefined(reactiveAttribute)).ToArray())
@@ -174,4 +159,4 @@ public void Execute()
174159
}
175160
}
176161
}
177-
}
162+
}

src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// See the LICENSE file in the project root for full license information.
55

66
using System;
7+
using System.Collections.Generic;
78
using System.Globalization;
89
using System.Linq.Expressions;
910
using System.Reactive.Concurrency;
@@ -183,5 +184,20 @@ public void SmokeTestWinformControls()
183184

184185
disp.Dispose();
185186
}
187+
188+
[Fact]
189+
public void PanelSetMethodBindingConverter_GetAffinityForObjects()
190+
{
191+
var fixture = new PanelSetMethodBindingConverter();
192+
var test1 = fixture.GetAffinityForObjects(typeof(List<Control>), typeof(Control.ControlCollection));
193+
var test2 = fixture.GetAffinityForObjects(typeof(List<TextBox>), typeof(Control.ControlCollection));
194+
var test3 = fixture.GetAffinityForObjects(typeof(List<Label>), typeof(Control.ControlCollection));
195+
var test4 = fixture.GetAffinityForObjects(typeof(Control.ControlCollection), typeof(IEnumerable<GridItem>));
196+
197+
Assert.Equal(0, test1);
198+
Assert.Equal(10, test2);
199+
Assert.Equal(10, test3);
200+
Assert.Equal(0, test4);
201+
}
186202
}
187203
}

src/ReactiveUI.Tests/Platforms/wpf/Mocks/WpfActiveContentApp.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ namespace ReactiveUI.Tests.Wpf
1010
{
1111
public class WpfActiveContentApp : Application
1212
{
13-
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
14-
1513
/// <summary>
1614
/// Gets the mock window factory.
1715
/// </summary>
@@ -35,7 +33,5 @@ public class WpfActiveContentApp : Application
3533
/// The WPF test window factory.
3634
/// </value>
3735
public Func<WpfTestWindow> WpfTestWindowFactory { get; } = () => new();
38-
39-
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
4036
}
4137
}

src/ReactiveUI.Tests/Platforms/wpf/Mocks/WpfActiveContentFixture.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ namespace ReactiveUI.Tests.Wpf
1616
/// <seealso cref="System.IDisposable" />
1717
public class WpfActiveContentFixture : IDisposable
1818
{
19-
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
19+
private readonly Thread? _uiThread;
2020
private bool _loadComplete;
21-
private Thread _uiThread;
2221
private bool _disposedValue;
2322

2423
/// <summary>
@@ -69,11 +68,9 @@ protected virtual void Dispose(bool disposing)
6968
() => App.Shutdown(),
7069
DispatcherPriority.Normal);
7170
Thread.Sleep(500);
72-
_uiThread.Join();
71+
_uiThread?.Join();
7372
_disposedValue = true;
7473
}
7574
}
76-
77-
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
7875
}
7976
}

0 commit comments

Comments
 (0)