Skip to content

Commit

Permalink
Updated to .net 8.0 and using collection initializers/better auto pro…
Browse files Browse the repository at this point in the history
…perties.
  • Loading branch information
natekford committed Jan 1, 2025
1 parent 8404093 commit e225679
Show file tree
Hide file tree
Showing 27 changed files with 305 additions and 523 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ dotnet_diagnostic.RCS1021.severity = none

# CA1822: Mark members as static
dotnet_diagnostic.CA1822.severity = none

# SYSLIB1096: Convert to 'GeneratedComInterface'
dotnet_diagnostic.SYSLIB1096.severity = none
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
125 changes: 0 additions & 125 deletions src/SongProcessor.UI/Controls/DynamicFontSizeGrid.cs

This file was deleted.

46 changes: 18 additions & 28 deletions src/SongProcessor.UI/Models/ObservableAnime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,55 @@ namespace SongProcessor.UI.Models;
[DebuggerDisplay(ModelUtils.DEBUGGER_DISPLAY)]
public sealed class ObservableAnime : ReactiveObject, IAnime
{
private string _AbsoluteInfoPath = null!;
private int _Id;
private bool _IsExpanded;
private bool _IsExpanderVisible;
private bool _IsVisible = true;
private string _Name = null!;
private ObservableCollection<ObservableSong> _Songs = null!;
private VideoInfo? _VideoInfo;
private int _Year;

public string AbsoluteInfoPath
{
get => _AbsoluteInfoPath;
set => this.RaiseAndSetIfChanged(ref _AbsoluteInfoPath, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public int Id
{
get => _Id;
set => this.RaiseAndSetIfChanged(ref _Id, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public bool IsExpanded
{
get => _IsExpanded;
set => this.RaiseAndSetIfChanged(ref _IsExpanded, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public bool IsExpanderVisible
{
get => _IsExpanderVisible;
set => this.RaiseAndSetIfChanged(ref _IsExpanderVisible, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public bool IsVisible
{
get => _IsVisible;
set => this.RaiseAndSetIfChanged(ref _IsVisible, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public string Name
{
get => _Name;
set => this.RaiseAndSetIfChanged(ref _Name, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public ObservableCollection<ObservableSong> Songs
{
get => _Songs;
set => this.RaiseAndSetIfChanged(ref _Songs, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public string? Source => this.GetRelativeOrAbsoluteSourceFile();
public VideoInfo? VideoInfo
{
get => _VideoInfo;
get;
set
{
this.RaiseAndSetIfChanged(ref _VideoInfo, value);
this.RaiseAndSetIfChanged(ref field, value);
this.RaisePropertyChanged(nameof(Source));
}
}
public int Year
{
get => _Year;
set => this.RaiseAndSetIfChanged(ref _Year, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
IReadOnlyList<ISong> IAnimeBase.Songs => Songs;
private string DebuggerDisplay => Name;
Expand Down
84 changes: 34 additions & 50 deletions src/SongProcessor.UI/Models/ObservableSong.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,97 +9,81 @@ namespace SongProcessor.UI.Models;
[DebuggerDisplay(ModelUtils.DEBUGGER_DISPLAY)]
public sealed class ObservableSong : ReactiveObject, ISong
{
private HashSet<int> _AlsoIn = null!;
private string _Artist = null!;
private string? _CleanPath;
private TimeSpan _End;
private int? _Episode;
private bool _IsVisible = true;
private string _Name = null!;
private AspectRatio? _OverrideAspectRatio;
private int _OverrideAudioTrack;
private int _OverrideVideoTrack;
private bool _ShouldIgnore;
private TimeSpan _Start;
private Status _Status;
private SongTypeAndPosition _Type;
private VolumeModifer? _VolumeModifier;

public HashSet<int> AlsoIn
{
get => _AlsoIn;
set => this.RaiseAndSetIfChanged(ref _AlsoIn, value);
}
get;
set => this.RaiseAndSetIfChanged(ref field, value);
} = null!;
public string Artist
{
get => _Artist;
set => this.RaiseAndSetIfChanged(ref _Artist, value);
}
get;
set => this.RaiseAndSetIfChanged(ref field, value);
} = null!;
public string? CleanPath
{
get => _CleanPath;
set => this.RaiseAndSetIfChanged(ref _CleanPath, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public TimeSpan End
{
get => _End;
set => this.RaiseAndSetIfChanged(ref _End, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public int? Episode
{
get => _Episode;
set => this.RaiseAndSetIfChanged(ref _Episode, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public bool IsVisible
{
get => _IsVisible;
set => this.RaiseAndSetIfChanged(ref _IsVisible, value);
}
get;
set => this.RaiseAndSetIfChanged(ref field, value);
} = true;
public string Name
{
get => _Name;
set => this.RaiseAndSetIfChanged(ref _Name, value);
}
get;
set => this.RaiseAndSetIfChanged(ref field, value);
} = null!;
public AspectRatio? OverrideAspectRatio
{
get => _OverrideAspectRatio;
set => this.RaiseAndSetIfChanged(ref _OverrideAspectRatio, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public int OverrideAudioTrack
{
get => _OverrideAudioTrack;
set => this.RaiseAndSetIfChanged(ref _OverrideAudioTrack, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public int OverrideVideoTrack
{
get => _OverrideVideoTrack;
set => this.RaiseAndSetIfChanged(ref _OverrideVideoTrack, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public ObservableAnime Parent { get; }
public bool ShouldIgnore
{
get => _ShouldIgnore;
set => this.RaiseAndSetIfChanged(ref _ShouldIgnore, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public TimeSpan Start
{
get => _Start;
set => this.RaiseAndSetIfChanged(ref _Start, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public Status Status
{
get => _Status;
set => this.RaiseAndSetIfChanged(ref _Status, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public SongTypeAndPosition Type
{
get => _Type;
set => this.RaiseAndSetIfChanged(ref _Type, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
public VolumeModifer? VolumeModifier
{
get => _VolumeModifier;
set => this.RaiseAndSetIfChanged(ref _VolumeModifier, value);
get;
set => this.RaiseAndSetIfChanged(ref field, value);
}
IReadOnlySet<int> ISong.AlsoIn => AlsoIn;
private string DebuggerDisplay => this.GetFullName();
Expand Down
1 change: 1 addition & 0 deletions src/SongProcessor.UI/SongProcessor.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TrimMode>copyused</TrimMode>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationIcon>cirno_at_computer_pTB_icon.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/SongProcessor.UI/SortedObservableCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace SongProcessor.UI;

public class SortedObservableCollection<T>(IComparer<T> comparer, IEnumerable<T>? collection = null) : ObservableCollection<T>(collection ?? Array.Empty<T>())
public class SortedObservableCollection<T>(IComparer<T> comparer, IEnumerable<T>? collection = null) : ObservableCollection<T>(collection ?? [])
{
public IComparer<T> Comparer { get; } = comparer;

Expand Down
2 changes: 1 addition & 1 deletion src/SongProcessor.UI/UIUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class UIUtils
public const string NO = "No";
public const string YES = "Yes";

public static ImmutableArray<string> YesNo { get; } = new[] { YES, NO }.ToImmutableArray();
public static ImmutableArray<string> YesNo { get; } = [YES, NO];

public static async Task<bool> ConfirmAsync(
this IMessageBoxManager manager,
Expand Down
Loading

0 comments on commit e225679

Please sign in to comment.