Skip to content

Commit

Permalink
Update to Catel 6 & enable nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed Oct 7, 2022
1 parent 8041e49 commit e8d4586
Show file tree
Hide file tree
Showing 28 changed files with 203 additions and 210 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mode: ContinuousDeployment
assembly-versioning-scheme: MajorMinorPatch
next-version: 4.0.0
next-version: 5.0.0
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Parameters["SolutionName"] = "Orc.LogViewer";
Parameters["Company"] = "WildGums";
Parameters["RepositoryUrl"] = string.Format("https://github.com/{0}/{1}", GetBuildServerVariable("Company"), GetBuildServerVariable("SolutionName"));
Parameters["StartYear"] = "2014";
Parameters["UseVisualStudioPrerelease"] = "false";
Parameters["UseVisualStudioPrerelease"] = "true";

// Note: the rest of the variables should be coming from the build server,
// see `/deployment/cake/*-variables.cake` for customization options
Expand Down
30 changes: 0 additions & 30 deletions src/Orc.LogViewer.Tests/DummyFacts.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Orc.LogViewer.Tests/Orc.LogViewer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="ApprovalTests" Version="5.7.3" />
<PackageReference Include="Catel.Core" Version="5.12.22" />
<PackageReference Include="Catel.Core" Version="6.0.0-alpha1005" />
<PackageReference Include="Catel.Fody" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="Fody" Version="6.6.4" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
46 changes: 23 additions & 23 deletions src/Orc.LogViewer.Tests/Orc.LogViewer.approved.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AdvancedLogViewerControl : Catel.Windows.Controls.UserControl, Syst
public static readonly System.Windows.DependencyProperty ShowFilterBoxProperty;
public static readonly System.Windows.DependencyProperty ShowFilterGroupsProperty;
public AdvancedLogViewerControl() { }
public System.Windows.Media.Brush AccentColorBrush { get; set; }
public System.Windows.Media.Brush? AccentColorBrush { get; set; }
[Catel.MVVM.Views.ViewToViewModel("", MappingType=Catel.MVVM.Views.ViewToViewModelMappingType.TwoWayViewWins)]
public bool EnableThreadId { get; set; }
[Catel.MVVM.Views.ViewToViewModel("", MappingType=Catel.MVVM.Views.ViewToViewModelMappingType.TwoWayViewWins)]
Expand All @@ -30,12 +30,12 @@ public AdvancedLogViewerControl() { }
[System.ComponentModel.TypeConverter(typeof(Orc.LogViewer.StringToLogEventLevelConverter))]
public Catel.Logging.LogEvent Level { get; set; }
[Catel.MVVM.Views.ViewToViewModel("", MappingType=Catel.MVVM.Views.ViewToViewModelMappingType.TwoWayViewWins)]
public System.Type LogListenerType { get; set; }
public System.Type? LogListenerType { get; set; }
[Catel.MVVM.Views.ViewToViewModel("", MappingType=Catel.MVVM.Views.ViewToViewModelMappingType.TwoWayViewWins)]
public bool ShowFilterBox { get; set; }
[Catel.MVVM.Views.ViewToViewModel("", MappingType=Catel.MVVM.Views.ViewToViewModelMappingType.TwoWayViewWins)]
public bool ShowFilterGroups { get; set; }
public Orc.Controls.LogViewerControl UnderlyingLogViewerControl { get; }
public Orc.Controls.LogViewerControl? UnderlyingLogViewerControl { get; }
public void Clear() { }
public void InitializeComponent() { }
public override void OnApplyTemplate() { }
Expand Down Expand Up @@ -78,17 +78,17 @@ public static string GetInlineText(this System.Windows.Controls.RichTextBox rich
public class StringToLogEventLevelConverter : System.ComponentModel.TypeConverter
{
public StringToLogEventLevelConverter() { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { }
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) { }
public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value) { }
}
public static class ToggleButtonExtensions
{
public static void Toggle(this System.Windows.Controls.Primitives.ToggleButton toggleButton) { }
}
public static class UIElementExtensions
{
public static void SetTooltip(this System.Windows.UIElement control, Catel.Windows.Input.InputGesture inputGesture) { }
public static void SetTooltip(this System.Windows.UIElement control, Catel.Windows.Input.InputGesture inputGesture, string text) { }
public static void SetTooltip(this System.Windows.UIElement control, Catel.Windows.Input.InputGesture? inputGesture) { }
public static void SetTooltip(this System.Windows.UIElement control, Catel.Windows.Input.InputGesture? inputGesture, string text) { }
}
}
namespace Orc.LogViewer.Controls
Expand All @@ -97,7 +97,7 @@ public class CategoryPresenter : System.Windows.Controls.UserControl, System.Win
{
public static readonly System.Windows.DependencyProperty CategoryProperty;
public CategoryPresenter() { }
public string Category { get; set; }
public string? Category { get; set; }
public void InitializeComponent() { }
}
public class CategoryToggleButton : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector
Expand All @@ -106,7 +106,7 @@ public class CategoryToggleButton : System.Windows.Controls.UserControl, System.
public static readonly System.Windows.DependencyProperty EntryCountProperty;
public static readonly System.Windows.DependencyProperty IsCheckedProperty;
public CategoryToggleButton() { }
public string Category { get; set; }
public string? Category { get; set; }
public int EntryCount { get; set; }
public bool IsChecked { get; set; }
public void InitializeComponent() { }
Expand All @@ -117,32 +117,32 @@ namespace Orc.LogViewer.Converters
{
public class CategoryBorderBrushConverter : Catel.MVVM.Converters.ValueConverterBase<string>
{
public static readonly System.Collections.Generic.Dictionary<string, System.Windows.Media.SolidColorBrush> BrushCache;
public static readonly System.Collections.Generic.Dictionary<string, System.Windows.Media.SolidColorBrush?> BrushCache;
public CategoryBorderBrushConverter() { }
protected override object Convert(string value, System.Type targetType, object parameter) { }
protected override object? Convert(string? value, System.Type targetType, object? parameter) { }
}
public class CategoryPathConverter : Catel.MVVM.Converters.ValueConverterBase<string>
{
public CategoryPathConverter() { }
protected override object Convert(string value, System.Type targetType, object parameter) { }
protected override object? Convert(string? value, System.Type targetType, object? parameter) { }
}
public class CategoryTextConverter : Catel.MVVM.Converters.ValueConverterBase<string>
{
public CategoryTextConverter() { }
protected override object Convert(string value, System.Type targetType, object parameter) { }
protected override object? Convert(string? value, System.Type targetType, object? parameter) { }
}
}
namespace Orc.LogViewer.ViewModels
{
public class AdvancedLogViewerViewModel : Catel.MVVM.ViewModelBase
{
public static readonly Catel.Data.PropertyData EnableThreadIdProperty;
public static readonly Catel.Data.PropertyData IgnoreCatelLoggingProperty;
public static readonly Catel.Data.PropertyData LogFilterGroupsProperty;
public static readonly Catel.Data.PropertyData LogListenerTypeProperty;
public static readonly Catel.Data.PropertyData SelectedLogFilterGroupProperty;
public static readonly Catel.Data.PropertyData ShowFilterBoxProperty;
public static readonly Catel.Data.PropertyData ShowFilterGroupsProperty;
public static readonly Catel.Data.IPropertyData EnableThreadIdProperty;
public static readonly Catel.Data.IPropertyData IgnoreCatelLoggingProperty;
public static readonly Catel.Data.IPropertyData LogFilterGroupsProperty;
public static readonly Catel.Data.IPropertyData LogListenerTypeProperty;
public static readonly Catel.Data.IPropertyData SelectedLogFilterGroupProperty;
public static readonly Catel.Data.IPropertyData ShowFilterBoxProperty;
public static readonly Catel.Data.IPropertyData ShowFilterGroupsProperty;
public AdvancedLogViewerViewModel(Catel.Services.IUIVisualizerService uiVisualizerService, Orc.Controls.IApplicationLogFilterGroupService applicationLogFilterGroupService, Catel.Configuration.IConfigurationService configurationService) { }
public bool DebugChecked { get; set; }
public Catel.MVVM.TaskCommand EditFilterGroups { get; }
Expand All @@ -152,13 +152,13 @@ public AdvancedLogViewerViewModel(Catel.Services.IUIVisualizerService uiVisualiz
public bool InfoChecked { get; set; }
public Catel.Logging.LogEvent Level { get; set; }
public System.Collections.Generic.List<Orc.Controls.LogFilterGroup> LogFilterGroups { get; }
public System.Type LogListenerType { get; set; }
public Orc.Controls.LogFilterGroup SelectedLogFilterGroup { get; set; }
public System.Type? LogListenerType { get; set; }
public Orc.Controls.LogFilterGroup? SelectedLogFilterGroup { get; set; }
public bool ShowFilterBox { get; set; }
public bool ShowFilterGroups { get; set; }
public bool WarningChecked { get; set; }
protected override System.Threading.Tasks.Task InitializeAsync() { }
protected override void OnPropertyChanged(Catel.Data.AdvancedPropertyChangedEventArgs e) { }
protected override void OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) { }
}
public class LogFilterGroupEditorViewModel : Catel.MVVM.ViewModelBase
{
Expand Down
8 changes: 1 addition & 7 deletions src/Orc.LogViewer/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Constants.cs" company="WildGums">
// Copyright (c) 2008 - 2015 WildGums. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

#define TEST_INPUTGESTURES
#define TEST_INPUTGESTURES

namespace Orc.LogViewer
{
Expand Down
4 changes: 2 additions & 2 deletions src/Orc.LogViewer/Controls/CategoryPresenter.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public CategoryPresenter()
InitializeComponent();
}

public string Category
public string? Category
{
get { return (string)GetValue(CategoryProperty); }
get { return (string?)GetValue(CategoryProperty); }
set { SetValue(CategoryProperty, value); }
}

Expand Down
9 changes: 7 additions & 2 deletions src/Orc.LogViewer/Controls/CategoryToggleButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public int EntryCount
typeof(int), typeof(CategoryToggleButton), new PropertyMetadata(0));


public string Category
public string? Category
{
get { return (string)GetValue(CategoryProperty); }
get { return (string?)GetValue(CategoryProperty); }
set { SetValue(CategoryProperty, value); }
}

Expand All @@ -56,6 +56,11 @@ private void OnCategoryChanged(DependencyPropertyChangedEventArgs args)
return;
}

if (brush is null)
{
return;
}

var accentColor = brush.Color;
var accentColor20 = Color.FromArgb(51, accentColor.R, accentColor.G, accentColor.B);
var accentColor40 = Color.FromArgb(102, accentColor.R, accentColor.G, accentColor.B);
Expand Down
14 changes: 8 additions & 6 deletions src/Orc.LogViewer/Converters/CategoryBorderBrushConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using Catel.MVVM.Converters;

public class CategoryBorderBrushConverter : ValueConverterBase<string>
{
public static readonly Dictionary<string, SolidColorBrush> BrushCache = new Dictionary<string, SolidColorBrush>(StringComparer.OrdinalIgnoreCase);
public static readonly Dictionary<string, SolidColorBrush?> BrushCache = new Dictionary<string, SolidColorBrush?>(StringComparer.OrdinalIgnoreCase);

static CategoryBorderBrushConverter()
{
Expand All @@ -21,9 +18,14 @@ static CategoryBorderBrushConverter()
BrushCache["Clock"] = new SolidColorBrush(Colors.Gray);
}

protected override object Convert(string value, Type targetType, object parameter)
protected override object? Convert(string? value, Type targetType, object? parameter)
{
if (BrushCache.TryGetValue(value, out var brush))
if (value is not string stringValue)
{
return null;
}

if (BrushCache.TryGetValue(stringValue, out var brush))
{
return brush;
}
Expand Down
14 changes: 8 additions & 6 deletions src/Orc.LogViewer/Converters/CategoryPathConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Catel.MVVM.Converters;

public class CategoryPathConverter : ValueConverterBase<string>
{
private static readonly Dictionary<string, Geometry> PathCache = new Dictionary<string, Geometry>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, Geometry?> PathCache = new Dictionary<string, Geometry?>(StringComparer.OrdinalIgnoreCase);

static CategoryPathConverter()
{
Expand All @@ -24,9 +21,14 @@ static CategoryPathConverter()
PathCache["Clock"] = application.TryFindResource("LogClockGeometry") as Geometry;
}

protected override object Convert(string value, Type targetType, object parameter)
protected override object? Convert(string? value, Type targetType, object? parameter)
{
if (PathCache.TryGetValue(value, out var geometry))
if (value is not string stringValue)
{
return null;
}

if (PathCache.TryGetValue(stringValue, out var geometry))
{
return geometry;
}
Expand Down
15 changes: 8 additions & 7 deletions src/Orc.LogViewer/Converters/CategoryTextConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Catel;
using Catel.MVVM.Converters;

public class CategoryTextConverter : ValueConverterBase<string>
{
private static readonly Dictionary<string, string> PathCache = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, string?> PathCache = new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);

static CategoryTextConverter()
{
Expand All @@ -25,9 +21,14 @@ static CategoryTextConverter()
PathCache["Clock"] = null;
}

protected override object Convert(string value, Type targetType, object parameter)
protected override object? Convert(string? value, Type targetType, object? parameter)
{
if (PathCache.TryGetValue(value, out var cachedvalue))
if (value is not string stringValue)
{
return null;
}

if (PathCache.TryGetValue(stringValue, out var cachedvalue))
{
return cachedvalue;
}
Expand Down
28 changes: 14 additions & 14 deletions src/Orc.LogViewer/Converters/StringToLogEventLevelConverter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StringToLogEventLevelConverter.cs" company="WildGums">
// Copyright (c) 2008 - 2015 WildGums. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace Orc.LogViewer
namespace Orc.LogViewer
{
using System;
using System.ComponentModel;
Expand All @@ -16,12 +9,19 @@ namespace Orc.LogViewer

public class StringToLogEventLevelConverter : TypeConverter
{
private readonly ILog Log = LogManager.GetCurrentClassLogger();
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var values = ((string)value).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
private static readonly ILog Log = LogManager.GetCurrentClassLogger();

public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value)
{
LogEvent result = 0;

if (value is not string stringValue)
{
return result;
}

var values = stringValue.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

foreach (var enumValue in values.Select(x => x.Trim()))
{
switch (enumValue.ToLower())
Expand All @@ -46,13 +46,13 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
throw Log.ErrorAndCreateException<XamlException>("Cannot parse the LogEvent value.");
}
}

return result;
}

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type? sourceType)
{
return sourceType == typeof(string);
}
}

}
Loading

0 comments on commit e8d4586

Please sign in to comment.