ObservableHelpers 2.0.10

dotnet add package ObservableHelpers --version 2.0.10                
NuGet\Install-Package ObservableHelpers -Version 2.0.10                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObservableHelpers" Version="2.0.10" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ObservableHelpers --version 2.0.10                
#r "nuget: ObservableHelpers, 2.0.10"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ObservableHelpers as a Cake Addin
#addin nuget:?package=ObservableHelpers&version=2.0.10

// Install ObservableHelpers as a Cake Tool
#tool nuget:?package=ObservableHelpers&version=2.0.10                

Observable Helpers

Observable helpers with source generators and UI-safe property implementations. Can be used for any MVVM software architectural applications.

NuGets

Name Info
ObservableHelpers NuGet

Installation

// Install release version
Install-Package ObservableHelpers

// Install pre-release version
Install-Package ObservableHelpers -pre

Supported frameworks

.NET Standard 2.0 and above - see https://github.com/dotnet/standard/blob/master/docs/versions.md for compatibility matrix

Get Started

All observable events are executed on thread that was used to create the object instance. To use in UI safe updates, create the object instances at the UI thread or manually configure the ISyncObject.SyncOperation to use UI thread.

Usage

ObservableObject Sample

using ObservableHelpers;

namespace YourNamespace
{
    [ObservableObject]
    public partial class Dinosaur
    {
        [ObservableProperty]
        string? name;
        
        [ObservableProperty(Access = Access.PublicWithPrivateSetter)]
        string? family;
        
        [ObservableProperty]
        int height;
    }
}

Will Generate

using ObservableHelpers;

namespace YourNamespace
{
    public partial class Dinosaur
    {
        public string? Name
        {
            get => name;
            set
            {
                if (!EqualityComparer<string?>.Default.Equals(name, value))
                {
                    OnNameChanging(value);
                    OnPropertyChanging(nameof(Name));
                    name = value;
                    OnNameChanged(value);
                    OnPropertyChanged(nameof(Name));
                }
            }
        }
        
        public string? Family
        {
            get => family;
            private set
            {
                if (!EqualityComparer<string?>.Default.Equals(family, value))
                {
                    OnFamilyChanging(value);
                    OnPropertyChanging(nameof(Family));
                    family = value;
                    OnFamilyChanged(value);
                    OnPropertyChanged(nameof(Family));
                }
            }
        }
        
        public int Height
        {
            get => height;
            set
            {
                if (!EqualityComparer<int>.Default.Equals(height, value))
                {
                    OnHeightChanging(value);
                    OnPropertyChanging(nameof(Height));
                    height = value;
                    OnHeightChanged(value);
                    OnPropertyChanged(nameof(Height));
                }
            }
        }
    }
}

UI safe

using ObservableHelpers;

namespace YourNamespace
{
    public class Program
    {
        private Dinosaur dinosaur;

        public void UIThread()
        {
            dinosaur = new Dinosaur(); // Must be created on UI thread to synchronize events

            dinosaur.SynchronizeChangedEvent = true;
        }

        public void BackgroundThread()
        {
            dinosaur.PropertyChanged += (s, e) =>
            {
                // Executes on UI thread if dinosaur.SynchronizeChangedEvent is true (default false)
            }
            dinosaur.SynchronizedPropertyChanged += (s, e) =>
            {
                // Executed on UI thread
            }
            dinosaur.UnsynchronizedPropertyChanged += (s, e) =>
            {
                // Executed on current thread
            }
            dinosaur.Name = "Megalosaurus";
        }
    }
}

Code & Inspiration from the following:

Want To Support This Project?

All I have ever asked is to be active by submitting bugs, features, and sending those pull requests down!.

paypal

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.10 677 9/9/2022
2.0.9 616 9/8/2022
2.0.8 421 9/8/2022
2.0.7 453 9/8/2022
2.0.6 423 9/5/2022
2.0.6-prerelease.14 121 9/5/2022
2.0.6-prerelease.13 109 9/5/2022
2.0.6-prerelease.11 105 9/5/2022
2.0.6-prerelease.10 104 9/5/2022
2.0.6-prerelease.8 111 9/5/2022
2.0.6-prerelease.7 110 9/5/2022
2.0.6-prerelease.6 110 9/5/2022
2.0.6-prerelease.4 118 9/5/2022
2.0.6-prerelease 155 9/5/2022
2.0.5 402 9/4/2022
2.0.3 426 9/4/2022
2.0.1 445 9/4/2022
1.6.2 492 4/23/2022
1.6.1 459 4/22/2022
1.6.0 492 4/22/2022
1.5.5 1,651 3/7/2022
1.5.4 450 3/7/2022
1.5.3 432 3/7/2022
1.5.2 457 3/5/2022
1.5.1 459 2/23/2022
1.5.0 1,186 2/22/2022
1.4.8 732 2/21/2022
1.4.7 443 2/19/2022
1.4.6 458 2/19/2022
1.4.5 703 1/9/2022
1.4.4 447 1/9/2022
1.4.3 1,009 1/4/2022
1.4.2 447 1/2/2022
1.4.1 319 1/1/2022
1.4.0 325 1/1/2022
1.3.6 413 1/1/2022
1.3.5 515 12/25/2021
1.3.4 457 12/13/2021
1.3.3 334 12/6/2021
1.3.2 403 11/16/2021
1.3.1 380 11/16/2021
1.3.0 359 11/14/2021
1.2.7 362 11/10/2021
1.2.6 418 11/8/2021
1.2.5 343 11/3/2021
1.2.4 375 11/2/2021
1.2.3 381 10/26/2021
1.2.2 419 10/25/2021
1.2.1 357 10/21/2021
1.2.0 333 10/21/2021
1.1.12 1,500 9/1/2021
1.1.11 349 9/1/2021
1.1.10 356 9/1/2021
1.1.9 357 9/1/2021
1.1.8 1,042 8/26/2021
1.1.7 359 8/26/2021
1.1.6 356 8/26/2021
1.1.5 351 8/26/2021
1.1.4 369 8/26/2021
1.1.3 514 8/25/2021
1.1.2 348 8/25/2021
1.1.1 342 8/25/2021
1.1.0 341 8/25/2021
1.0.92 985 8/18/2021
1.0.91 976 8/9/2021
1.0.90 653 8/4/2021
1.0.89 486 7/19/2021
1.0.88 355 7/19/2021
1.0.87 1,083 7/3/2021
1.0.86 506 7/2/2021
1.0.85 424 7/1/2021
1.0.84 542 6/30/2021
1.0.83 384 6/28/2021
1.0.82 372 6/28/2021
1.0.81 693 6/27/2021
1.0.80 483 6/27/2021
1.0.79 499 6/27/2021
1.0.78 383 6/16/2021
1.0.77 1,091 6/16/2021
1.0.76 628 6/15/2021
1.0.75 775 6/15/2021
1.0.74 415 6/15/2021
1.0.73 420 6/15/2021
1.0.72 435 6/15/2021
1.0.71 418 6/15/2021
1.0.70 635 6/15/2021
1.0.69 375 6/15/2021
1.0.68 517 6/15/2021
1.0.67 431 6/14/2021
1.0.66 428 6/14/2021
1.0.65 673 6/14/2021
1.0.64 534 6/13/2021
1.0.63 387 6/13/2021
1.0.62 392 6/13/2021
1.0.61 428 6/13/2021
1.0.60 505 6/13/2021
1.0.59 398 6/13/2021
1.0.58 720 6/13/2021
1.0.57 543 6/12/2021
1.0.56 679 6/12/2021
1.0.55 445 6/12/2021
1.0.54 1,205 6/10/2021
1.0.53 423 6/10/2021
1.0.52 454 6/10/2021
1.0.51 413 6/10/2021
1.0.49 414 6/10/2021
1.0.48 409 6/9/2021
1.0.47 352 6/9/2021
1.0.46 343 6/9/2021
1.0.45 344 6/9/2021
1.0.44 345 6/9/2021
1.0.43 1,522 6/8/2021
1.0.42 1,458 6/6/2021
1.0.41 486 6/6/2021
1.0.40 486 6/6/2021
1.0.39 498 6/6/2021
1.0.38 368 6/6/2021
1.0.37 514 6/6/2021
1.0.36 379 6/6/2021
1.0.35 357 6/6/2021
1.0.34 471 6/6/2021
1.0.33 378 6/6/2021
1.0.32 646 6/5/2021
1.0.31 801 6/5/2021
1.0.30 554 6/5/2021
1.0.29 494 6/5/2021
1.0.28 531 6/4/2021
1.0.27 600 6/4/2021
1.0.26 337 6/4/2021
1.0.25 375 6/4/2021
1.0.24 387 6/4/2021
1.0.23 523 6/3/2021
1.0.22 870 6/3/2021
1.0.21 372 6/3/2021
1.0.20 734 6/2/2021
1.0.19 704 6/2/2021
1.0.18 361 6/2/2021
1.0.17 363 6/2/2021
1.0.16 2,104 5/20/2021
1.0.15 356 5/19/2021
1.0.14 361 5/18/2021
1.0.13 340 5/18/2021
1.0.12 369 5/18/2021
1.0.11 354 5/17/2021
1.0.10 827 5/13/2021
1.0.9 494 5/13/2021
1.0.8 349 5/13/2021
1.0.7 676 5/11/2021
1.0.6 325 5/11/2021
1.0.5 330 5/11/2021
1.0.4 343 5/11/2021
1.0.3 497 5/8/2021
1.0.2 377 5/8/2021
1.0.1 361 5/8/2021
1.0.0 474 5/8/2021

* Fixed ArgumentNullException wrong parameter names