Skip to content

Commit 8eb59ef

Browse files
authored
Merge pull request #101 from Sergio0694/dev/update-net-toolkit
Update .NET Community Toolkit
2 parents 0ed5078 + 6f3f065 commit 8eb59ef

13 files changed

+58
-137
lines changed

src/Brainf_ckSharp.Git/Brainf_ckSharp.Git.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
9+
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.3.1" />
1010
<PackageReference Include="Microsoft.Experimental.Collections" Version="1.0.6-e190117-3" />
1111
</ItemGroup>
1212

src/Brainf_ckSharp.Services.Uwp/Brainf_ckSharp.Services.Uwp.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@
136136
</ItemGroup>
137137
<ItemGroup>
138138
<PackageReference Include="CommunityToolkit.Diagnostics">
139-
<Version>8.2.2</Version>
139+
<Version>8.3.1</Version>
140140
</PackageReference>
141141
<PackageReference Include="CommunityToolkit.HighPerformance">
142-
<Version>8.2.2</Version>
142+
<Version>8.3.1</Version>
143143
</PackageReference>
144144
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
145145
<Version>6.2.14</Version>

src/Brainf_ckSharp.Shared/Brainf_ckSharp.Shared.csproj

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<RootNamespace>Brainf_ckSharp.Shared</RootNamespace>
6+
7+
<!--
8+
Disable 'INotifyPropertyChanging' support in the MVVM Toolkit to optimize codegen.
9+
No control in UWP XAML at all actually relies on this interface being implemented.
10+
-->
11+
<MvvmToolkitEnableINotifyPropertyChangingSupport>false</MvvmToolkitEnableINotifyPropertyChangingSupport>
612
</PropertyGroup>
713

814
<ItemGroup>
915
<PackageReference Include="GitInfo" Version="2.3.0">
1016
<PrivateAssets>all</PrivateAssets>
1117
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1218
</PackageReference>
13-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
19+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.1" />
1420
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
1521
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
1622
</ItemGroup>

src/Brainf_ckSharp.Shared/Models/Console/ConsoleCommand.cs

+5-15
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,17 @@ namespace Brainf_ckSharp.Shared.Models.Console;
66
/// <summary>
77
/// A model for a console command being typed by the user
88
/// </summary>
9-
public sealed class ConsoleCommand : ObservableObject, IConsoleEntry
9+
public sealed partial class ConsoleCommand : ObservableObject, IConsoleEntry
1010
{
11-
private string command = string.Empty;
12-
1311
/// <summary>
1412
/// Gets or sets the current command being written by the user
1513
/// </summary>
16-
public string Command
17-
{
18-
get => this.command;
19-
set => SetProperty(ref this.command, value);
20-
}
21-
22-
private bool isActive = true;
14+
[ObservableProperty]
15+
private string command = string.Empty;
2316

2417
/// <summary>
2518
/// Gets or sets whether or not the user is still writing code for the current command
2619
/// </summary>
27-
public bool IsActive
28-
{
29-
get => this.isActive;
30-
set => SetProperty(ref this.isActive, value);
31-
}
20+
[ObservableProperty]
21+
private bool isActive = true;
3222
}

src/Brainf_ckSharp.Shared/Models/Console/Controls/Brainf_ckMemoryCellChunk.cs

+13-33
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Brainf_ckSharp.Shared.Models.Console.Controls;
88
/// <summary>
99
/// A model that represents a group of 4 contiguous memory cells
1010
/// </summary>
11-
public sealed class Brainf_ckMemoryCellChunk : ObservableObject
11+
public sealed partial class Brainf_ckMemoryCellChunk : ObservableObject
1212
{
1313
/// <summary>
1414
/// Creates a new <see cref="Brainf_ckMemoryCellChunk"/> instance with the specified parameters
@@ -27,49 +27,29 @@ public Brainf_ckMemoryCellChunk(IReadOnlyMachineState state, int offset)
2727
this.selectedIndex = state.Position;
2828
}
2929

30-
private Brainf_ckMemoryCell zero;
31-
3230
/// <summary>
3331
/// Gets the first memory cell
3432
/// </summary>
35-
public Brainf_ckMemoryCell Zero
36-
{
37-
get => this.zero;
38-
set => SetProperty(ref this.zero, value);
39-
}
40-
41-
private Brainf_ckMemoryCell one;
33+
[ObservableProperty]
34+
private Brainf_ckMemoryCell zero;
4235

4336
/// <summary>
4437
/// Gets the second memory cell
4538
/// </summary>
46-
public Brainf_ckMemoryCell One
47-
{
48-
get => this.one;
49-
set => SetProperty(ref this.one, value);
50-
}
51-
52-
private Brainf_ckMemoryCell two;
39+
[ObservableProperty]
40+
private Brainf_ckMemoryCell one;
5341

5442
/// <summary>
5543
/// Gets the third memory cell
5644
/// </summary>
57-
public Brainf_ckMemoryCell Two
58-
{
59-
get => this.two;
60-
set => SetProperty(ref this.two, value);
61-
}
62-
63-
private Brainf_ckMemoryCell three;
45+
[ObservableProperty]
46+
private Brainf_ckMemoryCell two;
6447

6548
/// <summary>
6649
/// Gets the fourth memory cell
6750
/// </summary>
68-
public Brainf_ckMemoryCell Three
69-
{
70-
get => this.three;
71-
set => SetProperty(ref this.three, value);
72-
}
51+
[ObservableProperty]
52+
private Brainf_ckMemoryCell three;
7353

7454
/// <summary>
7555
/// Gets the offset of the first memory cell in the chunk with respect to the source memory state
@@ -79,10 +59,10 @@ public Brainf_ckMemoryCell Three
7959
/// <summary>
8060
/// Gets whether or not the current position is within the current chunk
8161
/// </summary>
82-
public bool IsChunkSelected => this.zero.IsSelected ||
83-
this.one.IsSelected ||
84-
this.two.IsSelected ||
85-
this.three.IsSelected;
62+
public bool IsChunkSelected => Zero.IsSelected ||
63+
One.IsSelected ||
64+
Two.IsSelected ||
65+
Three.IsSelected;
8666

8767
private int selectedIndex;
8868

src/Brainf_ckSharp.Shared/ViewModels/Controls/CompactMemoryViewerViewModel.cs

+5-19
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls;
1313
/// <summary>
1414
/// A view model for a compact memory viewer for the interactive REPL console
1515
/// </summary>
16-
public sealed class CompactMemoryViewerViewModel : ObservableRecipient
16+
public sealed partial class CompactMemoryViewerViewModel : ObservableRecipient
1717
{
1818
/// <summary>
1919
/// Creates a new <see cref="CompactMemoryViewerViewModel"/> instance
@@ -36,28 +36,14 @@ protected override void OnActivated()
3636
/// </summary>
3737
public ObservableCollection<Brainf_ckMemoryCellChunk> Source { get; } = [];
3838

39-
private IReadOnlyMachineState? machineState;
40-
4139
/// <summary>
4240
/// Gets or sets the <see cref="IReadOnlyMachineState"/> instance for the current view model
4341
/// </summary>
44-
public IReadOnlyMachineState? MachineState
45-
{
46-
get => this.machineState;
47-
set
48-
{
49-
if (SetProperty(ref this.machineState, value))
50-
{
51-
UpdateFromState(value);
52-
}
53-
}
54-
}
42+
[ObservableProperty]
43+
private IReadOnlyMachineState? machineState;
5544

56-
/// <summary>
57-
/// Updates the current model from the input machine state
58-
/// </summary>
59-
/// <param name="state">The input <see cref="IReadOnlyMachineState"/> instance to read data from</param>
60-
public void UpdateFromState(IReadOnlyMachineState? state)
45+
/// <inheritdoc/>
46+
partial void OnMachineStateChanged(IReadOnlyMachineState? state)
6147
{
6248
if (state == null)
6349
{

src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs

+3-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls;
2020
/// <summary>
2121
/// A viewmodel for the status bar in the application.
2222
/// </summary>
23-
public sealed class StatusBarViewModel : ObservableRecipient
23+
public sealed partial class StatusBarViewModel : ObservableRecipient
2424
{
2525
/// <summary>
2626
/// The <see cref="ISettingsService"/> instance currently in use
@@ -72,11 +72,6 @@ public sealed class StatusBarViewModel : ObservableRecipient
7272
/// </summary>
7373
private Option<InterpreterResult>? backgroundExecutionResult;
7474

75-
/// <summary>
76-
/// The backing field for <see cref="WorkspaceViewModel"/>.
77-
/// </summary>
78-
private WorkspaceViewModelBase? workspaceViewModel;
79-
8075
/// <summary>
8176
/// Creates a new <see cref="StatusBarViewModel"/> instance
8277
/// </summary>
@@ -115,11 +110,8 @@ private set
115110
/// <summary>
116111
/// Gets the <see cref="WorkspaceViewModelBase"/> instance in use
117112
/// </summary>
118-
public WorkspaceViewModelBase? WorkspaceViewModel
119-
{
120-
get => this.workspaceViewModel;
121-
private set => SetProperty(ref this.workspaceViewModel, value);
122-
}
113+
[ObservableProperty]
114+
private WorkspaceViewModelBase? workspaceViewModel;
123115

124116
/// <summary>
125117
/// Assigns <see cref="WorkspaceViewModel"/> and <see cref="IdeViewModel"/> when the current view model changes

src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs

+3-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls;
1111
/// <summary>
1212
/// A viewmodel for the stdin header shown in the app.
1313
/// </summary>
14-
public sealed class StdinHeaderViewModel : ObservableRecipient
14+
public sealed partial class StdinHeaderViewModel : ObservableRecipient
1515
{
1616
/// <summary>
1717
/// The <see cref="ISettingsService"/> instance currently in use
@@ -35,16 +35,11 @@ protected override void OnActivated()
3535
Messenger.Register<StdinHeaderViewModel, StdinRequestMessage>(this, (r, m) => r.GetStdinBuffer(m));
3636
}
3737

38-
private string text = string.Empty;
39-
4038
/// <summary>
4139
/// Gets or sets the current text in the stdin buffer
4240
/// </summary>
43-
public string Text
44-
{
45-
get => this.text;
46-
set => SetProperty(ref this.text, value);
47-
}
41+
[ObservableProperty]
42+
private string text = string.Empty;
4843

4944
/// <inheritdoc/>
5045
private void GetStdinBuffer(StdinRequestMessage request)

src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/AboutSubPageViewModel.cs

+4-14
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,17 @@ public string BuildConfiguration
4949
=> "RELEASE";
5050
#endif
5151

52-
private static IEnumerable<User>? developers;
53-
5452
/// <summary>
5553
/// Gets the list of lead developers to the Legere repository
5654
/// </summary>
57-
public IEnumerable<User>? Developers
58-
{
59-
get => developers;
60-
private set => SetProperty(ref developers, value);
61-
}
62-
63-
private static IEnumerable<string>? featuredLinks;
55+
[ObservableProperty]
56+
private static IEnumerable<User>? developers;
6457

6558
/// <summary>
6659
/// Gets the list of featured links to use
6760
/// </summary>
68-
public IEnumerable<string>? FeaturedLinks
69-
{
70-
get => featuredLinks;
71-
private set => SetProperty(ref featuredLinks, value);
72-
}
61+
[ObservableProperty]
62+
private static IEnumerable<string>? featuredLinks;
7363

7464
/// <summary>
7565
/// Loads all the necessary data for the view model

src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,11 @@ protected override void OnActivated()
3232
Messenger.Register<VirtualKeyboardViewModel, ShowPBrainButtonsSettingsChangedMessage>(this, (r, m) => r.IsPBrainModeEnabled = m.Value);
3333
}
3434

35-
private bool isPBrainModeEnabled;
36-
3735
/// <summary>
3836
/// Gets whether or not the PBrain mode is currently enabled
3937
/// </summary>
40-
public bool IsPBrainModeEnabled
41-
{
42-
get => this.isPBrainModeEnabled;
43-
private set => SetProperty(ref this.isPBrainModeEnabled, value);
44-
}
38+
[ObservableProperty]
39+
private bool isPBrainModeEnabled;
4540

4641
/// <summary>
4742
/// Signals the insertion of a new operator

src/Brainf_ckSharp.Shared/ViewModels/Views/Abstract/WorkspaceViewModelBase.cs

+5-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Views.Abstract;
1212
/// <summary>
1313
/// An <see cref="ObservableRecipient"/> implementation for workspaces
1414
/// </summary>
15-
public abstract class WorkspaceViewModelBase : ObservableRecipient
15+
public abstract partial class WorkspaceViewModelBase : ObservableRecipient
1616
{
1717
/// <summary>
1818
/// Creates a new <see cref="WorkspaceViewModelBase"/> instance
@@ -64,27 +64,17 @@ public ReadOnlyMemory<char> Text
6464
}
6565
}
6666

67-
private bool isUnsavedEditPending;
68-
6967
/// <summary>
7068
/// Gets whether or not there are pending unsaved changes to the current file
7169
/// </summary>
72-
public bool IsUnsavedEditPending
73-
{
74-
get => this.isUnsavedEditPending;
75-
private set => SetProperty(ref this.isUnsavedEditPending, value);
76-
}
77-
78-
private SyntaxValidationResult validationResult;
70+
[ObservableProperty]
71+
private bool isUnsavedEditPending;
7972

8073
/// <summary>
8174
/// Gets the current <see cref="SyntaxValidationResult"/> value for <see cref="Text"/>
8275
/// </summary>
83-
public SyntaxValidationResult ValidationResult
84-
{
85-
get => this.validationResult;
86-
set => SetProperty(ref this.validationResult, value);
87-
}
76+
[ObservableProperty]
77+
private SyntaxValidationResult validationResult;
8878

8979
private int row = 1;
9080

src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs

+5-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Brainf_ckSharp.Shared.Models.Console.Interfaces;
1919
using Brainf_ckSharp.Shared.ViewModels.Views.Abstract;
2020
using CommunityToolkit.Diagnostics;
21+
using CommunityToolkit.Mvvm.ComponentModel;
2122
using CommunityToolkit.Mvvm.Messaging;
2223
using Nito.AsyncEx;
2324

@@ -26,7 +27,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Views;
2627
/// <summary>
2728
/// A view model for an interactive REPL console for Brainf*ck/PBrain
2829
/// </summary>
29-
public sealed class ConsoleViewModel : WorkspaceViewModelBase
30+
public sealed partial class ConsoleViewModel : WorkspaceViewModelBase
3031
{
3132
/// <summary>
3233
/// The <see cref="ISettingsService"/> instance currently in use
@@ -99,16 +100,12 @@ protected override void OnTextChanged(ReadOnlyMemory<char> text)
99100
/// </summary>
100101
public ObservableCollection<IConsoleEntry> Source { get; } = [new ConsoleCommand()];
101102

102-
private IReadOnlyMachineState machineState;
103-
104103
/// <summary>
105104
/// Gets the <see cref="IReadOnlyMachineState"/> instance currently in use
106105
/// </summary>
107-
public IReadOnlyMachineState MachineState
108-
{
109-
get => this.machineState;
110-
private set => SetProperty(ref this.machineState, value, true);
111-
}
106+
[ObservableProperty]
107+
[NotifyPropertyChangedRecipients]
108+
private IReadOnlyMachineState machineState;
112109

113110
/// <summary>
114111
/// Adds a new operator to the last command in the console

0 commit comments

Comments
 (0)