Skip to content

Commit e256995

Browse files
authored
Nullable reference types (#2160)
* Nullable reference types for Colors project * Null reference types for MahApps * WIP Nullable reference types in main project * Main library compiling * Moving to specifying nullable in build.props file Starting work on demo app * All warnings fixed * Clearing out paket * Centralized package management * Update azure-pipelines.yml for Azure Pipelines * Fixing unit test options * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * Update azure-pipelines.yml for Azure Pipelines * NuSpec TFM change * Adding net452 * Fixing NuGets net452 * Adding script to solution * Cleaning up nullability for dependency properties. * Add warnings as errors on the pipeline * Removing net5 * Trying with preview versions enabled * Just seeing what is installed * Installing NET 5 * Updating tests projects to net5 * Updating to net5 * Fixing screenshot path Adding longer retry
1 parent ace6d85 commit e256995

File tree

183 files changed

+1767
-4064
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+1767
-4064
lines changed

.paket/Paket.Restore.targets

Lines changed: 0 additions & 494 deletions
This file was deleted.

Directory.Build.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
<Company>Mulholland Software/James Willock</Company>
55

66
<Configurations>Debug;Release</Configurations>
7-
<LangVersion>8.0</LangVersion>
7+
<LangVersion>9.0</LangVersion>
88
<ErrorReport>prompt</ErrorReport>
99

1010
<SignAssembly>true</SignAssembly>
1111
<AssemblyOriginatorKeyFile>..\key.snk</AssemblyOriginatorKeyFile>
1212
<DelaySign>false</DelaySign>
13+
14+
<Nullable>enable</Nullable>
15+
16+
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
17+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1318
</PropertyGroup>
1419
</Project>

Directory.packages.props

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project>
2+
<ItemGroup>
3+
<PackageVersion Include="Dragablz" Version="0.0.3.223" />
4+
<PackageVersion Include="MahApps.Metro" Version="2.3.0" />
5+
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
6+
<PackageVersion Include="Microsoft.NETCore.Platforms" Version="5.0.0" />
7+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
8+
<PackageVersion Include="Shouldly" Version="3.0.2" />
9+
<PackageVersion Include="ShowMeTheXAML" Version="2.0.0" />
10+
<PackageVersion Include="ShowMeTheXAML.AvalonEdit" Version="2.0.0" />
11+
<PackageVersion Include="ShowMeTheXAML.MSBuild" Version="2.0.0" />
12+
<PackageVersion Include="VirtualizingWrapPanel" Version="1.5.2" />
13+
<PackageVersion Include="XAMLTest" Version="0.0.9" />
14+
<PackageVersion Include="xunit" Version="2.4.1" />
15+
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" />
16+
<PackageVersion Include="Xunit.StaFact" Version="1.0.37" />
17+
</ItemGroup>
18+
</Project>

MahMaterialDragablzMashUp/AnotherCommandImplementation.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,22 @@ public class AnotherCommandImplementation : ICommand
1111
private readonly Action<object> _execute;
1212
private readonly Func<object, bool> _canExecute;
1313

14-
public AnotherCommandImplementation(Action<object> execute) : this(execute, null)
14+
public AnotherCommandImplementation(Action<object> execute)
15+
: this(execute, null)
1516
{
1617
}
1718

18-
public AnotherCommandImplementation(Action<object> execute, Func<object, bool> canExecute)
19+
public AnotherCommandImplementation(Action<object> execute, Func<object, bool>? canExecute)
1920
{
20-
if (execute == null) throw new ArgumentNullException(nameof(execute));
21+
if (execute is null) throw new ArgumentNullException(nameof(execute));
2122

2223
_execute = execute;
2324
_canExecute = canExecute ?? (x => true);
2425
}
2526

26-
public bool CanExecute(object parameter)
27-
{
28-
return _canExecute(parameter);
29-
}
27+
public bool CanExecute(object parameter) => _canExecute(parameter);
3028

31-
public void Execute(object parameter)
32-
{
33-
_execute(parameter);
34-
}
29+
public void Execute(object parameter) => _execute(parameter);
3530

3631
public event EventHandler CanExecuteChanged
3732
{
@@ -45,9 +40,6 @@ public event EventHandler CanExecuteChanged
4540
}
4641
}
4742

48-
public void Refresh()
49-
{
50-
CommandManager.InvalidateRequerySuggested();
51-
}
43+
public void Refresh() => CommandManager.InvalidateRequerySuggested();
5244
}
5345
}

MahMaterialDragablzMashUp/DialogsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public DialogsViewModel()
2424
ShowLeftFlyoutCommand = new AnotherCommandImplementation(_ => ShowLeftFlyout());
2525
}
2626

27-
public Flyout LeftFlyout { get; set; }
27+
public Flyout? LeftFlyout { get; set; }
2828

2929
private void InputDialog()
3030
{

MahMaterialDragablzMashUp/MahAppsDragablzDemo.csproj

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
<Prefer32Bit>true</Prefer32Bit>
1313
<SignAssembly>false</SignAssembly>
1414
</PropertyGroup>
15-
<ItemGroup>
16-
<None Include="paket.references" />
17-
</ItemGroup>
1815
<ItemGroup>
1916
<ProjectReference Include="..\MaterialDesignColors.Wpf\MaterialDesignColors.Wpf.csproj" />
2017
<ProjectReference Include="..\MaterialDesignThemes.MahApps\MaterialDesignThemes.MahApps.csproj" />
@@ -24,9 +21,10 @@
2421
<Resource Include="Resources\ProfilePic.jpg" />
2522
</ItemGroup>
2623
<ItemGroup>
27-
<PackageReference Update="Dragablz">
28-
<NoWarn>NU1701</NoWarn>
29-
</PackageReference>
24+
<PackageReference Include="Dragablz" />
25+
<PackageReference Include="MahApps.Metro" />
26+
<PackageReference Include="ShowMeTheXAML" />
27+
<PackageReference Include="ShowMeTheXAML.AvalonEdit" />
28+
<PackageReference Include="ShowMeTheXAML.MSBuild" />
3029
</ItemGroup>
31-
<Import Project="..\.paket\Paket.Restore.targets" />
3230
</Project>

MahMaterialDragablzMashUp/MahViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace MahAppsDragablzDemo
99
{
1010
public class MahViewModel : INotifyPropertyChanged
1111
{
12-
public event PropertyChangedEventHandler PropertyChanged;
12+
public event PropertyChangedEventHandler? PropertyChanged;
1313

1414
public ObservableCollection<GridRowData> GridData { get; }
1515

@@ -98,7 +98,7 @@ public MahViewModel()
9898
public class GridRowData
9999
{
100100
public bool IsChecked { get; set; }
101-
public string Text { get; set; }
101+
public string? Text { get; set; }
102102
public EnumValues EnumValue { get; set; }
103103
public int IntValue { get; set; }
104104
}

MahMaterialDragablzMashUp/PaletteSelectorViewModel.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace MahMaterialDragablzMashUp
1010
{
1111
public class PaletteSelectorViewModel : INotifyPropertyChanged
1212
{
13-
public event PropertyChangedEventHandler PropertyChanged;
13+
public event PropertyChangedEventHandler? PropertyChanged;
1414

1515

1616
public PaletteSelectorViewModel()
@@ -69,7 +69,12 @@ private static void ApplyPrimary(Swatch swatch)
6969
=> ModifyTheme(theme => theme.SetPrimaryColor(swatch.ExemplarHue.Color));
7070

7171
private static void ApplyAccent(Swatch swatch)
72-
=> ModifyTheme(theme => theme.SetSecondaryColor(swatch.AccentExemplarHue.Color));
72+
{
73+
if (swatch.AccentExemplarHue is Hue accentHue)
74+
{
75+
ModifyTheme(theme => theme.SetSecondaryColor(accentHue.Color));
76+
}
77+
}
7378

7479
private static void ModifyTheme(Action<ITheme> modificationAction)
7580
{

MahMaterialDragablzMashUp/paket.references

Lines changed: 0 additions & 6 deletions
This file was deleted.

MainDemo.Wpf/ButtonAssist.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@ public static class ButtonAssist
88
"UniformCornerRadius", typeof(double), typeof(ButtonAssist), new PropertyMetadata(2.0, OnUniformCornerRadius));
99

1010
private static void OnUniformCornerRadius(DependencyObject d, DependencyPropertyChangedEventArgs e)
11-
{
12-
MaterialDesignThemes.Wpf.ButtonAssist.SetCornerRadius(d, new CornerRadius((double)e.NewValue));
13-
}
11+
=> MaterialDesignThemes.Wpf.ButtonAssist.SetCornerRadius(d, new CornerRadius((double)e.NewValue));
1412

1513
public static void SetUniformCornerRadius(DependencyObject element, double value)
16-
{
17-
element.SetValue(UniformCornerRadiusProperty, value);
18-
}
14+
=> element.SetValue(UniformCornerRadiusProperty, value);
1915

2016
public static double GetUniformCornerRadius(DependencyObject element)
21-
{
22-
return (double)element.GetValue(UniformCornerRadiusProperty);
23-
}
17+
=> (double)element.GetValue(UniformCornerRadiusProperty);
2418
}
2519
}

0 commit comments

Comments
 (0)