Skip to content

Commit

Permalink
Merge pull request #101 from Sergio0694/dev/update-net-toolkit
Browse files Browse the repository at this point in the history
Update .NET Community Toolkit
  • Loading branch information
Sergio0694 authored Sep 14, 2024
2 parents 0ed5078 + 6f3f065 commit 8eb59ef
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 137 deletions.
2 changes: 1 addition & 1 deletion src/Brainf_ckSharp.Git/Brainf_ckSharp.Git.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.3.1" />
<PackageReference Include="Microsoft.Experimental.Collections" Version="1.0.6-e190117-3" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Diagnostics">
<Version>8.2.2</Version>
<Version>8.3.1</Version>
</PackageReference>
<PackageReference Include="CommunityToolkit.HighPerformance">
<Version>8.2.2</Version>
<Version>8.3.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.14</Version>
Expand Down
10 changes: 8 additions & 2 deletions src/Brainf_ckSharp.Shared/Brainf_ckSharp.Shared.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Brainf_ckSharp.Shared</RootNamespace>

<!--
Disable 'INotifyPropertyChanging' support in the MVVM Toolkit to optimize codegen.
No control in UWP XAML at all actually relies on this interface being implemented.
-->
<MvvmToolkitEnableINotifyPropertyChangingSupport>false</MvvmToolkitEnableINotifyPropertyChangingSupport>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitInfo" Version="2.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.1" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
</ItemGroup>
Expand Down
20 changes: 5 additions & 15 deletions src/Brainf_ckSharp.Shared/Models/Console/ConsoleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,17 @@ namespace Brainf_ckSharp.Shared.Models.Console;
/// <summary>
/// A model for a console command being typed by the user
/// </summary>
public sealed class ConsoleCommand : ObservableObject, IConsoleEntry
public sealed partial class ConsoleCommand : ObservableObject, IConsoleEntry
{
private string command = string.Empty;

/// <summary>
/// Gets or sets the current command being written by the user
/// </summary>
public string Command
{
get => this.command;
set => SetProperty(ref this.command, value);
}

private bool isActive = true;
[ObservableProperty]
private string command = string.Empty;

/// <summary>
/// Gets or sets whether or not the user is still writing code for the current command
/// </summary>
public bool IsActive
{
get => this.isActive;
set => SetProperty(ref this.isActive, value);
}
[ObservableProperty]
private bool isActive = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Brainf_ckSharp.Shared.Models.Console.Controls;
/// <summary>
/// A model that represents a group of 4 contiguous memory cells
/// </summary>
public sealed class Brainf_ckMemoryCellChunk : ObservableObject
public sealed partial class Brainf_ckMemoryCellChunk : ObservableObject
{
/// <summary>
/// Creates a new <see cref="Brainf_ckMemoryCellChunk"/> instance with the specified parameters
Expand All @@ -27,49 +27,29 @@ public Brainf_ckMemoryCellChunk(IReadOnlyMachineState state, int offset)
this.selectedIndex = state.Position;
}

private Brainf_ckMemoryCell zero;

/// <summary>
/// Gets the first memory cell
/// </summary>
public Brainf_ckMemoryCell Zero
{
get => this.zero;
set => SetProperty(ref this.zero, value);
}

private Brainf_ckMemoryCell one;
[ObservableProperty]
private Brainf_ckMemoryCell zero;

/// <summary>
/// Gets the second memory cell
/// </summary>
public Brainf_ckMemoryCell One
{
get => this.one;
set => SetProperty(ref this.one, value);
}

private Brainf_ckMemoryCell two;
[ObservableProperty]
private Brainf_ckMemoryCell one;

/// <summary>
/// Gets the third memory cell
/// </summary>
public Brainf_ckMemoryCell Two
{
get => this.two;
set => SetProperty(ref this.two, value);
}

private Brainf_ckMemoryCell three;
[ObservableProperty]
private Brainf_ckMemoryCell two;

/// <summary>
/// Gets the fourth memory cell
/// </summary>
public Brainf_ckMemoryCell Three
{
get => this.three;
set => SetProperty(ref this.three, value);
}
[ObservableProperty]
private Brainf_ckMemoryCell three;

/// <summary>
/// Gets the offset of the first memory cell in the chunk with respect to the source memory state
Expand All @@ -79,10 +59,10 @@ public Brainf_ckMemoryCell Three
/// <summary>
/// Gets whether or not the current position is within the current chunk
/// </summary>
public bool IsChunkSelected => this.zero.IsSelected ||
this.one.IsSelected ||
this.two.IsSelected ||
this.three.IsSelected;
public bool IsChunkSelected => Zero.IsSelected ||
One.IsSelected ||
Two.IsSelected ||
Three.IsSelected;

private int selectedIndex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls;
/// <summary>
/// A view model for a compact memory viewer for the interactive REPL console
/// </summary>
public sealed class CompactMemoryViewerViewModel : ObservableRecipient
public sealed partial class CompactMemoryViewerViewModel : ObservableRecipient
{
/// <summary>
/// Creates a new <see cref="CompactMemoryViewerViewModel"/> instance
Expand All @@ -36,28 +36,14 @@ protected override void OnActivated()
/// </summary>
public ObservableCollection<Brainf_ckMemoryCellChunk> Source { get; } = [];

private IReadOnlyMachineState? machineState;

/// <summary>
/// Gets or sets the <see cref="IReadOnlyMachineState"/> instance for the current view model
/// </summary>
public IReadOnlyMachineState? MachineState
{
get => this.machineState;
set
{
if (SetProperty(ref this.machineState, value))
{
UpdateFromState(value);
}
}
}
[ObservableProperty]
private IReadOnlyMachineState? machineState;

/// <summary>
/// Updates the current model from the input machine state
/// </summary>
/// <param name="state">The input <see cref="IReadOnlyMachineState"/> instance to read data from</param>
public void UpdateFromState(IReadOnlyMachineState? state)
/// <inheritdoc/>
partial void OnMachineStateChanged(IReadOnlyMachineState? state)
{
if (state == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls;
/// <summary>
/// A viewmodel for the status bar in the application.
/// </summary>
public sealed class StatusBarViewModel : ObservableRecipient
public sealed partial class StatusBarViewModel : ObservableRecipient
{
/// <summary>
/// The <see cref="ISettingsService"/> instance currently in use
Expand Down Expand Up @@ -72,11 +72,6 @@ public sealed class StatusBarViewModel : ObservableRecipient
/// </summary>
private Option<InterpreterResult>? backgroundExecutionResult;

/// <summary>
/// The backing field for <see cref="WorkspaceViewModel"/>.
/// </summary>
private WorkspaceViewModelBase? workspaceViewModel;

/// <summary>
/// Creates a new <see cref="StatusBarViewModel"/> instance
/// </summary>
Expand Down Expand Up @@ -115,11 +110,8 @@ private set
/// <summary>
/// Gets the <see cref="WorkspaceViewModelBase"/> instance in use
/// </summary>
public WorkspaceViewModelBase? WorkspaceViewModel
{
get => this.workspaceViewModel;
private set => SetProperty(ref this.workspaceViewModel, value);
}
[ObservableProperty]
private WorkspaceViewModelBase? workspaceViewModel;

/// <summary>
/// Assigns <see cref="WorkspaceViewModel"/> and <see cref="IdeViewModel"/> when the current view model changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls;
/// <summary>
/// A viewmodel for the stdin header shown in the app.
/// </summary>
public sealed class StdinHeaderViewModel : ObservableRecipient
public sealed partial class StdinHeaderViewModel : ObservableRecipient
{
/// <summary>
/// The <see cref="ISettingsService"/> instance currently in use
Expand All @@ -35,16 +35,11 @@ protected override void OnActivated()
Messenger.Register<StdinHeaderViewModel, StdinRequestMessage>(this, (r, m) => r.GetStdinBuffer(m));
}

private string text = string.Empty;

/// <summary>
/// Gets or sets the current text in the stdin buffer
/// </summary>
public string Text
{
get => this.text;
set => SetProperty(ref this.text, value);
}
[ObservableProperty]
private string text = string.Empty;

/// <inheritdoc/>
private void GetStdinBuffer(StdinRequestMessage request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,17 @@ public string BuildConfiguration
=> "RELEASE";
#endif

private static IEnumerable<User>? developers;

/// <summary>
/// Gets the list of lead developers to the Legere repository
/// </summary>
public IEnumerable<User>? Developers
{
get => developers;
private set => SetProperty(ref developers, value);
}

private static IEnumerable<string>? featuredLinks;
[ObservableProperty]
private static IEnumerable<User>? developers;

/// <summary>
/// Gets the list of featured links to use
/// </summary>
public IEnumerable<string>? FeaturedLinks
{
get => featuredLinks;
private set => SetProperty(ref featuredLinks, value);
}
[ObservableProperty]
private static IEnumerable<string>? featuredLinks;

/// <summary>
/// Loads all the necessary data for the view model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ protected override void OnActivated()
Messenger.Register<VirtualKeyboardViewModel, ShowPBrainButtonsSettingsChangedMessage>(this, (r, m) => r.IsPBrainModeEnabled = m.Value);
}

private bool isPBrainModeEnabled;

/// <summary>
/// Gets whether or not the PBrain mode is currently enabled
/// </summary>
public bool IsPBrainModeEnabled
{
get => this.isPBrainModeEnabled;
private set => SetProperty(ref this.isPBrainModeEnabled, value);
}
[ObservableProperty]
private bool isPBrainModeEnabled;

/// <summary>
/// Signals the insertion of a new operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Brainf_ckSharp.Shared.ViewModels.Views.Abstract;
/// <summary>
/// An <see cref="ObservableRecipient"/> implementation for workspaces
/// </summary>
public abstract class WorkspaceViewModelBase : ObservableRecipient
public abstract partial class WorkspaceViewModelBase : ObservableRecipient
{
/// <summary>
/// Creates a new <see cref="WorkspaceViewModelBase"/> instance
Expand Down Expand Up @@ -64,27 +64,17 @@ public ReadOnlyMemory<char> Text
}
}

private bool isUnsavedEditPending;

/// <summary>
/// Gets whether or not there are pending unsaved changes to the current file
/// </summary>
public bool IsUnsavedEditPending
{
get => this.isUnsavedEditPending;
private set => SetProperty(ref this.isUnsavedEditPending, value);
}

private SyntaxValidationResult validationResult;
[ObservableProperty]
private bool isUnsavedEditPending;

/// <summary>
/// Gets the current <see cref="SyntaxValidationResult"/> value for <see cref="Text"/>
/// </summary>
public SyntaxValidationResult ValidationResult
{
get => this.validationResult;
set => SetProperty(ref this.validationResult, value);
}
[ObservableProperty]
private SyntaxValidationResult validationResult;

private int row = 1;

Expand Down
13 changes: 5 additions & 8 deletions src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Brainf_ckSharp.Shared.Models.Console.Interfaces;
using Brainf_ckSharp.Shared.ViewModels.Views.Abstract;
using CommunityToolkit.Diagnostics;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using Nito.AsyncEx;

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

private IReadOnlyMachineState machineState;

/// <summary>
/// Gets the <see cref="IReadOnlyMachineState"/> instance currently in use
/// </summary>
public IReadOnlyMachineState MachineState
{
get => this.machineState;
private set => SetProperty(ref this.machineState, value, true);
}
[ObservableProperty]
[NotifyPropertyChangedRecipients]
private IReadOnlyMachineState machineState;

/// <summary>
/// Adds a new operator to the last command in the console
Expand Down
Loading

0 comments on commit 8eb59ef

Please sign in to comment.