Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ReactiveUI Source Generators automatically generate ReactiveUI objects to stream
- `[Reactive(Inheritance = InheritanceModifier.Virtual)]` With field and access modifiers. This will generate a virtual property.
- `[Reactive(UseRequired = true)]` With field and access modifiers. This will generate a required property, (Not Required for partial properties, use required keyword for property declaration).
- `[Reactive(nameof(RaiseProperty1), nameof(RaiseProperty2))]` With field and property changed notification for additional properties.
- `[Reactive(WhenAnyValue = true, WhenAnyValueAccessModifier = PropertyAccessModifier.Private)]` With field and WhenAnyValue generation for the property. Has option to set the access modifier of the generated WhenAnyValue property.
- `[ObservableAsProperty]` With field, method, Observable property and partial property support (C# 13 Visual Studio Version 17.12.0)
- `[ObservableAsProperty(ReadOnly = false)]` Removes readonly keyword from the generated helper field
- `[ObservableAsProperty(PropertyName = "ReadOnlyPropertyName")]`
Expand Down Expand Up @@ -166,6 +167,27 @@ public partial class MyReactiveClass : ReactiveObject
}
```

### Usage Reactive property with WhenAnyValue property generation
```csharp
using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass : ReactiveObject
{
[Reactive(WhenAnyValue = true, WhenAnyValueAccessModifier = PropertyAccessModifier.Private)]
private string _myProperty;

public MyReactiveClass()
{
// You can now use the generated WhenAnyValue property
WhenAnyMyProperty
.Subscribe(value =>
{
// Handle value changes
});
}
}
```

### Usage Reactive property with property Attribute pass through
```csharp
using ReactiveUI.SourceGenerators;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.BindableDerivedListAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.IViewForAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ObservableAsPropertyAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.AccessModifier.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ReactiveAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -46,6 +46,16 @@ public ReactiveAttribute(params string[] alsoNotify)
/// Gets the AlsoNotify properties to raise change notifications for.
/// </summary>
public string[]? AlsoNotify { get; }

/// <summary>
/// Indicates that the property should create an observable for any value changes.
/// </summary>
public bool WhenAnyValue { get; init; }

/// <summary>
/// Gets the AccessModifier of the WhenAnyValue observable property.
/// </summary>
public PropertyAccessModifier WhenAnyValueAccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public int Test4
this.RaisePropertyChanged(nameof(OtherNotifyProperty));
}
}


}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.AccessModifier.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ReactiveAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -46,6 +46,16 @@ public ReactiveAttribute(params string[] alsoNotify)
/// Gets the AlsoNotify properties to raise change notifications for.
/// </summary>
public string[]? AlsoNotify { get; }

/// <summary>
/// Indicates that the property should create an observable for any value changes.
/// </summary>
public bool WhenAnyValue { get; init; }

/// <summary>
/// Gets the AccessModifier of the WhenAnyValue observable property.
/// </summary>
public PropertyAccessModifier WhenAnyValueAccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.AccessModifier.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ReactiveAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -46,6 +46,16 @@ public ReactiveAttribute(params string[] alsoNotify)
/// Gets the AlsoNotify properties to raise change notifications for.
/// </summary>
public string[]? AlsoNotify { get; }

/// <summary>
/// Indicates that the property should create an observable for any value changes.
/// </summary>
public bool WhenAnyValue { get; init; }

/// <summary>
/// Gets the AccessModifier of the WhenAnyValue observable property.
/// </summary>
public PropertyAccessModifier WhenAnyValueAccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public int Test3
this.RaiseAndSetIfChanged(ref _test3, value);
}
}


}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.AccessModifier.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ReactiveAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -46,6 +46,16 @@ public ReactiveAttribute(params string[] alsoNotify)
/// Gets the AlsoNotify properties to raise change notifications for.
/// </summary>
public string[]? AlsoNotify { get; }

/// <summary>
/// Indicates that the property should create an observable for any value changes.
/// </summary>
public bool WhenAnyValue { get; init; }

/// <summary>
/// Gets the AccessModifier of the WhenAnyValue observable property.
/// </summary>
public PropertyAccessModifier WhenAnyValueAccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public int Test1
this.RaiseAndSetIfChanged(ref _test1, value);
}
}


}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.AccessModifier.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ReactiveAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -46,6 +46,16 @@ public ReactiveAttribute(params string[] alsoNotify)
/// Gets the AlsoNotify properties to raise change notifications for.
/// </summary>
public string[]? AlsoNotify { get; }

/// <summary>
/// Indicates that the property should create an observable for any value changes.
/// </summary>
public bool WhenAnyValue { get; init; }

/// <summary>
/// Gets the AccessModifier of the WhenAnyValue observable property.
/// </summary>
public PropertyAccessModifier WhenAnyValueAccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public string Value
this.RaiseAndSetIfChanged(ref this.value, value);
}
}


}
}
#nullable restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.AccessModifier.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//HintName: ReactiveUI.SourceGenerators.ReactiveAttribute.g.cs
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down Expand Up @@ -46,6 +46,16 @@ public ReactiveAttribute(params string[] alsoNotify)
/// Gets the AlsoNotify properties to raise change notifications for.
/// </summary>
public string[]? AlsoNotify { get; }

/// <summary>
/// Indicates that the property should create an observable for any value changes.
/// </summary>
public bool WhenAnyValue { get; init; }

/// <summary>
/// Gets the AccessModifier of the WhenAnyValue observable property.
/// </summary>
public PropertyAccessModifier WhenAnyValueAccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public int Test2
this.RaiseAndSetIfChanged(ref _test2, value);
}
}


}
}
#nullable restore
Expand Down
Loading
Loading