Skip to content
Merged
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ ReactiveUI Source Generators automatically generate ReactiveUI objects to stream
- `[ReactiveCommand(OutputScheduler = "RxApp.MainThreadScheduler")]` using a ReactiveUI Scheduler
- `[ReactiveCommand(OutputScheduler = nameof(_isheduler))]` using a Scheduler defined in the class
- `[ReactiveCommand][property: AttributeToAddToCommand]` with Attribute passthrough
- `[ReactiveCommand(AccessModifier = PropertyAccessModifier.Internal)]` sets the access modifier of the generated command property
- `[IViewFor(nameof(ViewModelName))]`
- `[IViewFor<YourViewModelType>]`
- `[IViewFor("YourNameSpace.YourGenericViewModel<int>")]` Generic
- `[IViewFor<YourViewModelType>(RegistrationType = SplatRegistrationType.PerRequest)]` with Splat Registration Type for IViewFor registration.
- `[IViewFor<YourViewModelType>(RegistrationType = SplatRegistrationType.LazySingleton)]` Generic with Splat Registration Type for IViewFor registration.
- `[IViewFor<YourViewModelType>(RegistrationType = SplatRegistrationType.Constant)]` Generic with Splat Registration Type for IViewFor registration.
- `[IViewFor<YourViewModelType>(ViewModelRegistrationType = SplatRegistrationType.PerRequest)]` Generic with Splat Registration Type for ViewModel registration.
- `[IViewFor<YourViewModelType>(ViewModelRegistrationType = SplatRegistrationType.LazySingleton)]` Generic with Splat Registration Type for ViewModel registration.
- `[IViewFor<YourViewModelType>(ViewModelRegistrationType = SplatRegistrationType.Constant)]` Generic with Splat Registration Type for ViewModel registration.
- `[RoutedControlHost("YourNameSpace.CustomControl")]`
- `[ViewModelControlHost("YourNameSpace.CustomControl")]`
- `[BindableDerivedList]` Generates a derived list from a ReadOnlyObservableCollection backing field
Expand Down Expand Up @@ -544,6 +548,17 @@ public partial class MyReactiveClass
}
```

### Usage ReactiveCommand with AccessModifier
```csharp
using ReactiveUI.SourceGenerators;

public partial class MyReactiveClass
{
[ReactiveCommand(AccessModifier = PropertyAccessModifier.Internal)]
private void Execute() { }
}
```

## Usage IViewFor `[IViewFor(nameof(ViewModelName))]`

### IViewFor usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ internal enum AccessModifier
Init,
}

/// <summary>
/// Property Access Modifier.
/// </summary>
internal enum PropertyAccessModifier
{
Public,
Protected,
Internal,
Private,
InternalProtected,
PrivateProtected,
}

/// <summary>
/// InheritanceModifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ internal sealed class ReactiveCommandAttribute : global::System.Attribute
/// The output scheduler.
/// </value>
public string? OutputScheduler { get; init; }

/// <summary>
/// Gets the AccessModifier of the ReactiveCommand property.
/// </summary>
/// <value>
/// The AccessModifier of the property.
/// </value>
public PropertyAccessModifier AccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ internal sealed class ReactiveCommandAttribute : global::System.Attribute
/// The output scheduler.
/// </value>
public string? OutputScheduler { get; init; }

/// <summary>
/// Gets the AccessModifier of the ReactiveCommand property.
/// </summary>
/// <value>
/// The AccessModifier of the property.
/// </value>
public PropertyAccessModifier AccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ internal sealed class ReactiveCommandAttribute : global::System.Attribute
/// The output scheduler.
/// </value>
public string? OutputScheduler { get; init; }

/// <summary>
/// Gets the AccessModifier of the ReactiveCommand property.
/// </summary>
/// <value>
/// The AccessModifier of the property.
/// </value>
public PropertyAccessModifier AccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//HintName: ReactiveUI.SourceGenerators.ReactiveCommandAttribute.g.cs
// Copyright (c) 2025 .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.

// <auto-generated/>
#pragma warning disable
#nullable enable
namespace ReactiveUI.SourceGenerators;

/// <summary>
/// ReativeCommandAttribute.
/// </summary>
/// <seealso cref="Attribute" />
[global::System.AttributeUsage(global::System.AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
internal sealed class ReactiveCommandAttribute : global::System.Attribute
{
/// <summary>
/// Gets the can execute method or property.
/// </summary>
/// <value>
/// The name of the CanExecute Observable of bool.
/// </value>
public string? CanExecute { get; init; }

/// <summary>
/// Gets the output scheduler.
/// </summary>
/// <value>
/// The output scheduler.
/// </value>
public string? OutputScheduler { get; init; }

/// <summary>
/// Gets the AccessModifier of the ReactiveCommand property.
/// </summary>
/// <value>
/// The AccessModifier of the property.
/// </value>
public PropertyAccessModifier AccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ internal sealed class ReactiveCommandAttribute : global::System.Attribute
/// The output scheduler.
/// </value>
public string? OutputScheduler { get; init; }

/// <summary>
/// Gets the AccessModifier of the ReactiveCommand property.
/// </summary>
/// <value>
/// The AccessModifier of the property.
/// </value>
public PropertyAccessModifier AccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ internal sealed class ReactiveCommandAttribute : global::System.Attribute
/// The output scheduler.
/// </value>
public string? OutputScheduler { get; init; }

/// <summary>
/// Gets the AccessModifier of the ReactiveCommand property.
/// </summary>
/// <value>
/// The AccessModifier of the property.
/// </value>
public PropertyAccessModifier AccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ internal sealed class ReactiveCommandAttribute : global::System.Attribute
/// The output scheduler.
/// </value>
public string? OutputScheduler { get; init; }

/// <summary>
/// Gets the AccessModifier of the ReactiveCommand property.
/// </summary>
/// <value>
/// The AccessModifier of the property.
/// </value>
public PropertyAccessModifier AccessModifier { get; init; }
}
#nullable restore
#pragma warning restore
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,25 @@ public partial class TestInnerClass3 : ReactiveObject
// Act: Initialize the helper and run the generator. Assert: Verify the generated code.
return TestHelper.TestPass(sourceCode);
}

/// <summary>
/// Froms the reactive command with access modifier.
/// </summary>
/// <returns>A task to monitor the async.</returns>
[Test]
public Task FromReactiveCommandWithAccessModifier()
{
const string sourceCode = """
using System;
using ReactiveUI;
using ReactiveUI.SourceGenerators;
namespace TestNs;
public partial class TestVM : ReactiveObject
{
[ReactiveCommand(AccessModifier = PropertyAccessModifier.Internal)]
private int Test1() => 10;
}
""";
return TestHelper.TestPass(sourceCode);
}
}
2 changes: 1 addition & 1 deletion src/ReactiveUI.SourceGenerators.Execute/TestViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ protected virtual void Dispose(bool disposing)
/// </summary>
/// <param name="i">The i.</param>
/// <returns>An Observable of int.</returns>
[ReactiveCommand]
[ReactiveCommand(AccessModifier = PropertyAccessModifier.Internal)]
private IObservable<double?> Test8Observable(int i) => Observable.Return<double?>(i + 10.0);

[ReactiveCommand]
Expand Down
Loading
Loading