Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Add the `partial` modifier to the generated property of the Relay Command

Abierto
#1,164 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
csharp

Línea de trabajo

Comienza localizando el punto de entrada de generación de código fuente de Relay Command y compara el tratamiento de sus propiedades generadas con el generador de Observable Property. Verifica que la propiedad de comando generada admita una declaración parcial escrita manualmente que coincida y que el escenario de generación de código fuente de XAML/App Model la resuelva en tiempo de compilación sin reflexión.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

feature request :mailbox_with_mail:
Overview

Add the partial modifier to the generated property of the Relay Command.

Now, app models like .NET MAUI have introduced a source generation feature that allows XAML to be translated into C#. However, the issue remains that source generators cannot interact with one another, such that only handwritten code is accessible.

Since the Observable Property is partial, it can be referenced in XAML without any issues. However, the Relay Command property is not partial, which prevents XAML source generation from inferring it. To resolve this, update the generated Relay Command property partial so that its declaration can be added in the handwritten code, while the MVVM toolkit handles the implementation.

API breakdown

Providing the source-generated code for reference. The generated property needs to be partial.

User code:

public partial IRelayCommand IncrementCommand { get; }

Generated:

private global::CommunityToolkit.Mvvm.Input.RelayCommand? incrementCommand;
// The request is make this IncrementCommand property partial
// so that the developer can add a declaration part in the source type.
public global::CommunityToolkit.Mvvm.Input.IRelayCommand IncrementCommand => incrementCommand ??= new global::CommunityToolkit.Mvvm.Input.RelayCommand(new global::System.Action(Increment));
Usage example

The IncrementCommand is now visible to the App Model source generator.

Previously, the evaluation occurred at runtime; now, to support AOT, it is resolved at compile time. To avoid reflection, the C# expression API is used, requiring at least the declaration/definition to be part of the handwritten code.

<Button Command="{Binding IncrementCommand}" />
Breaking change?

I'm not sure

Alternatives

Manually create the command property, losing all the toolkit's benefits.

Additional context

Multiple source generators at work.

Help us help you

No, just wanted to propose this

Lenguaje dominante
C#
Estrellas
3.8k
Forks
403
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CommunityToolkit/dotnet

Todos los issues de CommunityToolkit/dotnet

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.