Skip to content

Commit

Permalink
Merge pull request #253 from wieslawsoltes/ReactiveGenerator
Browse files Browse the repository at this point in the history
Use ReactiveGenerator
  • Loading branch information
wieslawsoltes authored Dec 17, 2024
2 parents e958b02 + 97d1117 commit 9608d8a
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 48 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resources:
variables:
BuildConfiguration: 'Release'
BuildPlatform: 'Any CPU'
PublishFramework: 'net8.0'
PublishFramework: 'net9.0'
PublishProject: ''
PublishRuntime: ''
Workloads: 'wasm-tools wasm-experimental'
Expand Down
3 changes: 2 additions & 1 deletion build/build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<IsPackable>False</IsPackable>
<NoWarn>CS0649;CS0169</NoWarn>
Expand All @@ -12,6 +12,7 @@

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="5.3.0" />
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"rollForward": "latestMinor",
"allowPrerelease": true
}
Expand Down
19 changes: 18 additions & 1 deletion samples/TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>False</IsPackable>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>TestApp</RootNamespace>
</PropertyGroup>

<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GeneratedFiles</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

<PropertyGroup>
<LangVersion>13</LangVersion>
<UseBackingFields>true</UseBackingFields>
</PropertyGroup>

<ItemGroup>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
Expand All @@ -27,4 +37,11 @@
<ProjectReference Include="..\..\src\Svg.Skia\Svg.Skia.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ReactiveGenerator" Version="0.9.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
23 changes: 7 additions & 16 deletions samples/TestApp/ViewModels/FileItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@

namespace TestApp.ViewModels;

public class FileItemViewModel : ViewModelBase
public partial class FileItemViewModel : ViewModelBase
{
private string _name;
private string _path;

public string Name
{
get => _name;
set => this.RaiseAndSetIfChanged(ref _name, value);
}

public string Path
{
get => _path;
set => this.RaiseAndSetIfChanged(ref _path, value);
}

[Reactive]
public partial string Name { get; set; }

[Reactive]
public partial string Path { get; set; }

public ICommand RemoveCommand { get; }

public ICommand OpenInExplorerCommand { get; }
Expand Down
38 changes: 12 additions & 26 deletions samples/TestApp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,28 @@
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
using Svg.CodeGen.Skia;
using Svg.Skia;
using TestApp.Models;
using TestApp.Services;

namespace TestApp.ViewModels;

public class MainWindowViewModel : ViewModelBase
public partial class MainWindowViewModel : ViewModelBase
{
private readonly ObservableCollection<FileItemViewModel>? _items;
private FileItemViewModel? _selectedItem;
private string? _itemQuery;
private ReadOnlyObservableCollection<FileItemViewModel>? _filteredItems;

public FileItemViewModel? SelectedItem
{
get => _selectedItem;
set => this.RaiseAndSetIfChanged(ref _selectedItem, value);
}

public string? ItemQuery
{
get => _itemQuery;
set => this.RaiseAndSetIfChanged(ref _itemQuery, value);
}

public ReadOnlyObservableCollection<FileItemViewModel>? FilteredItems
{
get => _filteredItems;
set => this.RaiseAndSetIfChanged(ref _filteredItems, value);
}

[Reactive]
public partial FileItemViewModel? SelectedItem { get; set; }

[Reactive]
public partial string? ItemQuery { get; set; }

[Reactive]
public partial ReadOnlyObservableCollection<FileItemViewModel>? FilteredItems { get; set; }

public ICommand ResetQueryCommand { get; }

public ICommand LoadConfigurationCommand { get; }
Expand Down Expand Up @@ -86,7 +72,7 @@ public MainWindowViewModel()
{
_items = new ObservableCollection<FileItemViewModel>();

var queryFilter = this.WhenValueChanged(t => t.ItemQuery)
var queryFilter = this.WhenAnyItemQuery()
.Throttle(TimeSpan.FromMilliseconds(100))
.Select(ItemQueryFilter)
.DistinctUntilChanged();
Expand All @@ -99,7 +85,7 @@ public MainWindowViewModel()
.Bind(out _filteredItems)
.AsObservableList();

var resetQueryCanExecute = this.WhenAnyValue(x => x.ItemQuery)
var resetQueryCanExecute = this.WhenAnyItemQuery()
.Select(x => !string.IsNullOrWhiteSpace(x))
.ObserveOn(RxApp.MainThreadScheduler);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Library</OutputType>
<IsPackable>False</IsPackable>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion tests/Svg.Skia.UnitTests/Svg.Skia.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Library</OutputType>
<IsPackable>False</IsPackable>
<Nullable>enable</Nullable>
Expand Down

0 comments on commit 9608d8a

Please sign in to comment.