Skip to content

Commit

Permalink
Merge pull request #157 from AvaloniaCommunity/feature/Sync-Stable-v8…
Browse files Browse the repository at this point in the history
….1.97.11xx

Publish v8.1.97.11073
  • Loading branch information
DamianSuess authored Apr 28, 2024
2 parents 5212f11 + 74d5040 commit 6f2cc4b
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 39 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Change log history for Prism.Avalonia

## v8.1.97.11073 (2024-04-28)

* Removed dependency on Avalonia.ReactiveUI

## v8.1.97.11072 (2024-01-27)

* Added support for .NET 8
Expand Down
57 changes: 32 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,67 @@

[Prism.Avalonia](https://github.com/AvaloniaCommunity/Prism.Avalonia) provides your [Avalonia](https://avaloniaui.net/) apps with [Prism framework](https://github.com/PrismLibrary/Prism) support so you can **Navigate**, create **Dialog Windows** and **Notifications**, provide **Dependency Injection** and internal **Messaging** easier than before! You will need both packages installed to get started.

> ### **Announcement:**
> _Prism.Avalonia v9.0 beta coming soon!_
> **Announcement!**
>
> * _Prism.Avalonia v9.0.401-pre just arrived!_
> * _Prism.Avalonia v9.0.271-pre just arrived!_
> * Follow the [Upgrading to Prism v9.0.x-pre](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Upgrading-to-Prism-v9.0) guide for breaking changes
**For more samples outside of this repo, check out:**

* [Avalonia Outlookish](https://github.com/DamianSuess/Learn.PrismAvaloniaOutlookish)
* [Learn PrismLibrary](https://github.com/DamianSuess/Learn.PrismLibrary)
* _If you have samples, let us know and we'll feature them!_

![Sample Outlookish](logo/Sample-Outlookish.png)
<!-- ![Sample Outlookish](logo/Sample-Outlookish.png) -->
![Sample Outlookish](https://raw.githubusercontent.com/AvaloniaCommunity/Prism.Avalonia/stable/v8.1.97.11xx/logo/Sample-Outlookish.png)

With Prism.Avalonia's logic and development approach being **similar** to that of [Prism for WPF](https://github.com/PrismLibrary/Prism/), so you can get started right away! Keep in mind, they are **similar** and not 1-to-1. Check out our [Wiki](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki) and [Avalonia Outlookish](https://github.com/DamianSuess/Learn.PrismAvaloniaOutlookish) app for tips and tricks.

## Package Releases

Just like Prism.WPF or Prism.Maui, your project must reference both the Prism.Avalonia (_Core_) and Prism.DryIoc.Avalonia (_IoC container_) packages to work.

| Package | Stable | Preview
|-|-|-|
| Prism.Avalonia | [![Prism.Avalonia NuGet Badge](https://buildstats.info/nuget/Prism.Avalonia?dWidth=70&includePreReleases=false)](https://www.nuget.org/packages/Prism.Avalonia/) | [![Prism.Avalonia NuGet Badge](https://buildstats.info/nuget/Prism.Avalonia?dWidth=70&includePreReleases=true)](https://www.nuget.org/packages/Prism.Avalonia/)
| Prism.DryIoc.Avalonia | [![Prism.DryIoc.Avalonia NuGet Badge](https://buildstats.info/nuget/Prism.DryIoc.Avalonia?dWidth=70&includePreReleases=false)](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/) | [![Prism.DryIoc.Avalonia NuGet Badge](https://buildstats.info/nuget/Prism.DryIoc.Avalonia?dWidth=70&includePreReleases=true)](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/)

## Version Notice
### Version Notice

Choose the NuGet package version that matches your Avalonia version.

The Avalonia version of this package uses [SemVer](https://semver.org/) format: `MAJOR.MINOR.PATCH.REVISION`. The `REVISION` segment indicates
the Avalonia version support. For instance `v8.1.97.11000` of this library supports, Avalonia v11.0.0.
Our [versioning schema](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Versioning-Schema) is based on the [SemVer](https://semver.org/) using the format `MAJOR.MINOR.PATCH.REVISION`. The `REVISION` segment indicates the Avalonia version support. For instance `v8.1.97.11000` of this library supports, Prism `v8.1.97` and Avalonia `v11.0.x`.

| Avalonia Version | NuGet Package |
|-|-|
| **11.0** | 8.1.97.11000 ([Core](https://www.nuget.org/packages/Prism.Avalonia/8.1.97.11000)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/8.1.97.11000))
| **0.10.21** | 8.1.97.1021 ([Core](https://www.nuget.org/packages/Prism.Avalonia/8.1.97.1021)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/8.1.97.1021))
| **11.0 RC-1.1** | 8.1.97.11000-rc1.1 ([Core](https://www.nuget.org/packages/Prism.Avalonia/8.1.97.11000-rc1.1)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/8.1.97.11000-rc1.1))
| 11.0 Preview 8 | 8.1.97.11-preview.11.8
| 11.0 Preview 5 | 8.1.97.4-preview.11.5
| 11.0 Preview 4 | 8.1.97.3-preview.11.4
| Prism Version | Avalonia Version | NuGet Package
|-|-|-
| v9.0.401-pre | **11.0.7** | v9.0.401.11000-pre ([Core](https://www.nuget.org/packages/Prism.Avalonia/9.0.401.11000-pre)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/9.0.401.11000-pre))
| v9.0.271-pre | **11.0.7** | v9.0.271.11000-pre ([Core](https://www.nuget.org/packages/Prism.Avalonia/9.0.271.11000-pre)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/9.0.271.11000-pre))
| v8.1.97 | **11.0.7** | v8.1.97.11073 ([Core](https://www.nuget.org/packages/Prism.Avalonia/8.1.97.11073)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/8.1.97.11073))
| v8.1.97 | **0.10.21** | v8.1.97.1021 ([Core](https://www.nuget.org/packages/Prism.Avalonia/8.1.97.1021)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/8.1.97.1021))

Be sure to check out the [ChangeLog.md](ChangeLog.md) and guides when upgrading your NuGet packages:

* [Upgrading to Prism v9.0.x-pre](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Upgrading-to-Prism-v9.0)
* [Upgrading to Avalonia-11](Upgrading-to-Avalonia-11.md)
* Also, the official [Avalonia Upgrading from v0.10](https://docs.avaloniaui.net/docs/next/stay-up-to-date/upgrade-from-0.10).

## Contributing

Prism.Avalonia is an open-source project under the MIT license. We encourage community members like yourself to contribute.

You can contribute today by creating a **feature request**, **issue**, or **discussion** on the forum. From there we can have a brief discussion as to where this fits into the backlog priority. If this is something that fits within the Prism architecture, we'll kindly ask you to create a **Pull Request**. Any PR made without first having an issue/discussion may be closed.

Be sure to check out the [ChangeLog.md](ChangeLog.md) and [Upgrading-to-Avalonia-11.md](Upgrading-to-Avalonia-11.md) when upgrading your NuGet packages. Also, view the official [Avalonia Upgrading from v0.10](https://docs.avaloniaui.net/docs/next/stay-up-to-date/upgrade-from-0.10).
Issues posted without a description may be closed immediately. Use the discussion boards if you have a question, not Issues.

## Install

Add the Prism.Avalonia and its DryIoc packages to your project:

```powershell
# Avalonia v11
Install-Package Prism.Avalonia -Version 8.1.97.11000
Install-Package Prism.DryIoc.Avalonia -Version 8.1.97.11000
Install-Package Prism.Avalonia -Version 8.1.97.11073
Install-Package Prism.DryIoc.Avalonia -Version 8.1.97.11073
# Avalonia v0.10.1021
Install-Package Prism.Avalonia -Version 8.1.97.1021
Expand Down Expand Up @@ -188,12 +203,4 @@ Below is a basic branching hierarchy and strategy.
| `feature/*` | New feature branch. Once completed, it is merged into `develop` and the branch must be deleted.
| `stable/*` | Stable release base build which shares cherry-picked merges from `develop`. This branch **must not** be deleted.

## Contributing

Prism.Avalonia is an open-source project under the MIT license. We encourage community members like yourself to contribute.

You can contribute today by creating a **feature request**, **issue**, or **discussion** on the forum. From there we can have a brief discussion as to where this fits into the backlog priority. If this is something that fits within the Prism architecture, we'll kindly ask you to create a **Pull Request**. Any PR made without first having an issue/discussion may be closed.



**Sponsored by:** [Suess Labs](https://suesslabs.com) a subsidary of Xeno Innovations, Inc.
1 change: 0 additions & 1 deletion build/AvaloniaDependency.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.7" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.0.7" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion build/Base.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>8.1.97.11072</Version>
<Version>8.1.97.11073</Version>
<PackageProjectUrl>https://github.com/AvaloniaCommunity/Prism.Avalonia</PackageProjectUrl>
<Copyright>Copyright (c) 2024 Xeno Innovations, Inc.</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
4 changes: 2 additions & 2 deletions samples/SampleMvvmApp/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

This demonstrates the following Prism.Avalonia features:

* .NET 6 - Cross-platform
* .NET 6, 7, 8 - Cross-platform
* MVVM Pattern - _Model View ViewModel_
* Prism Navigation with and without passing parameters.
* Prism Journling backwards
* Prism Journaling backwards
* Prism Regions for placing views
* Prism Region with multiple views - registering multiple views and displaying them in a single ItemsControl using a custom ItemsControlRegionAdapter
* Prism.DryIoc for Dependency Injection of Services
Expand Down
4 changes: 2 additions & 2 deletions src/Prism.Avalonia/Common/ObservableObject.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.ComponentModel;
using System.ComponentModel;
using Prism.Extensions;
using Avalonia;
using Avalonia.Controls;

Expand Down
10 changes: 10 additions & 0 deletions src/Prism.Avalonia/Common/Stubs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Prism.Common
{
internal static class Stubs
{
public static readonly Action Nop = () => { };
public static readonly Action<Exception> Throw = ex => { throw ex; };
}
}
35 changes: 35 additions & 0 deletions src/Prism.Avalonia/Extensions/ObservableExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using Avalonia.Reactive;
using Prism.Common;

namespace Prism.Extensions
{
internal static class ObservableExtensions
{
/// <summary>
/// Subscribes an element handler to an observable sequence.
/// </summary>
/// <typeparam name="T">The type of the elements in the source sequence.</typeparam>
/// <param name="source">Observable sequence to subscribe to.</param>
/// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
/// <returns><see cref="IDisposable"/> object used to unsubscribe from the observable sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> is <c>null</c>.</exception>
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}

if (onNext == null)
{
throw new ArgumentNullException(nameof(onNext));
}

//
// [OK] Use of unsafe Subscribe: non-pretentious constructor for an observer; this overload is not to be used internally.
//
return source.Subscribe/*Unsafe*/(new AnonymousObserver<T>(onNext, Stubs.Throw, Stubs.Nop));
}
}
}
4 changes: 1 addition & 3 deletions src/Prism.Avalonia/Mvvm/ViewModelLocator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.ComponentModel;
using System.Threading;
using System;
using Prism.Extensions;
using Avalonia;
using Avalonia.Controls;

Expand Down
3 changes: 3 additions & 0 deletions src/Prism.Avalonia/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Avalonia.Metadata;

Expand All @@ -18,3 +19,5 @@
[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Interactivity")]
[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Services.Dialogs")]
[assembly: XmlnsDefinition("http://prismlibrary.com/", "Prism.Ioc")]

[assembly: InternalsVisibleTo("Prism.Avalonia.Tests")]
3 changes: 2 additions & 1 deletion src/Prism.Avalonia/Regions/ItemMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia;
using Avalonia;
using Prism.Extensions;
using System;

namespace Prism.Regions
Expand Down
3 changes: 2 additions & 1 deletion src/Prism.Avalonia/Regions/RegionContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System;
using Avalonia;
using Prism.Common;
using Prism.Extensions;

namespace Prism.Regions
{
Expand Down
3 changes: 2 additions & 1 deletion src/Prism.Avalonia/Regions/RegionManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
Expand All @@ -9,6 +9,7 @@
using System.Threading;
using Prism.Common;
using Prism.Events;
using Prism.Extensions;
using Prism.Ioc;
using Prism.Properties;
using Prism.Regions.Behaviors;
Expand Down
4 changes: 2 additions & 2 deletions src/Prism.Avalonia/Services/Dialogs/Dialog.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Styling;
using Prism.Extensions;

namespace Prism.Services.Dialogs
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Avalonia;
using Xunit;
using Prism.Extensions;

namespace Prism.Avalonia.Tests.Interactivity
{
public class ObservableBehaviorFixture
{
[Fact]
public void SubscribeWorksOnIObservableWithLambda()
{
var targetUIElement = new TestAvaloniaObject();
targetUIElement.Test = "123";

Assert.Equal("123", targetUIElement.OutTest);
}
}

class TestAvaloniaObject : AvaloniaObject
{
/// <summary>
/// The property to subscribe on.
/// </summary>
public static readonly StyledProperty<string> TestProperty =
AvaloniaProperty.Register<TestAvaloniaObject, string>("Test");

/// <summary>
/// Gets or sets a value to the TestProperty.
/// </summary>
public string Test
{
get { return (string)GetValue(TestProperty); }
set { SetValue(TestProperty, value); }
}

/// <summary>
/// The out test property to check after TestProperty change
/// </summary>
public string OutTest { get; set; }

/// <summary>
/// Initializes a new instance of <see cref="TestAvaloniaObject"/>.
/// </summary>
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public TestAvaloniaObject()
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
{
TestProperty.Changed.Subscribe(args => OnPropertyChanged(args));
}

private void OnPropertyChanged(AvaloniaPropertyChangedEventArgs<string> args)
{
OutTest = args.NewValue.Value;
}
}
}

0 comments on commit 6f2cc4b

Please sign in to comment.