[Bug]: XAML Previewer sample data for CollectionViewSource with ItemsPath ignores generated rows when item properties have C# initializers
Los mantenedores suelen responder en 15 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 80/100
Línea de trabajo
Empieza por surface/Surface/SampleListFiller.cs, en la rama itemsPath identificada en el issue dentro de BuildGroups. Sigue cómo la lista items generada por el planner llega a la colección Members del grupo tipado y, después, revisa surface/Surface/SampleObjects.cs para entender cómo se manejan las propiedades inicializadas. El trabajo estará terminado cuando la vista previa agrupada muestre los valores de ejemplo generados en lugar de "Runtime item" para los elementos creados mediante ItemsPath.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
When Sample Data is enabled in the Visual Studio XAML Previewer (zateutsch-xaml-previewer, v0.3.15), a grouped ListView bound to a CollectionViewSource with IsSourceGrouped="True" and ItemsPath="Members" ignores the planner's generated sample rows ("Sample item 1", "Sample item 2", "Sample item 3") whenever the item class has a non-empty C# property initializer (e.g., public string Name { get; set; } = "Runtime item";). Every child row across all groups displays "Runtime item" instead.
Smallest repro
- Define a group class with an
ItemsPathcollection and an item class with a default property initializer:public sealed class SampleItem { public string Name { get; set; } = "Runtime item"; } public sealed class ItemGroup { public string Name { get; set; } = ""; public ObservableCollection<SampleItem> Members { get; set; } = []; } - Bind a
ListViewthrough aCollectionViewSourcewithItemsPath="Members":<Page.Resources> <CollectionViewSource x:Key="PathGroups" Source="{x:Bind Model.Groups}" IsSourceGrouped="True" ItemsPath="Members"/> <DataTemplate x:Key="GroupRow" x:DataType="m:SampleItem"> <TextBlock Text="{x:Bind Name}"/> </DataTemplate> </Page.Resources> <ListView ItemsSource="{Binding Source={StaticResource PathGroups}}" ItemTemplate="{StaticResource GroupRow}"/> - Open the page in the XAML Previewer and toggle Sample Data: On.
- Actual result: Group headers show
"Sample group 1"and"Sample group 2", but every child item in every group shows"Runtime item". - Expected result: Child items in each group show the planner's generated sample values (
"Sample item 1","Sample item 2","Sample item 3"), matching the behavior ofIList-subclass groups.
Root cause & smallest fix
In surface/Surface/SampleListFiller.cs (BuildGroups, lines 273–307):
var items = new List<object>();
if (g.TryGetProperty("Items", out var rowsOfGroup) && rowsOfGroup.ValueKind == JsonValueKind.Array)
{
int ii = 0;
foreach (var row in rowsOfGroup.EnumerateArray())
{
if (Convert(row) is not { } v) continue;
if (itemType is not null && SampleObjects.Create(itemType, v as IReadOnlyDictionary<string, object>, ii) is { } obj) v = obj;
items.Add(v);
ii++;
}
}
object? group = null;
if (groupType is not null &&
SampleObjects.Create(groupType, new Dictionary<string, object> { ["Key"] = key }, gi) is { } typed)
{
if (string.IsNullOrEmpty(itemsPath) && typed is System.Collections.IList l && !l.IsReadOnly && !l.IsFixedSize)
{
l.Clear();
foreach (var item in items) l.Add(item);
group = typed;
}
else if (!string.IsNullOrEmpty(itemsPath))
{
group = typed; // <-- `items` (built with planner rows) is discarded!
}
}
When itemsPath is non-empty ("Members"), BuildGroups constructs items using the planner rows (row), but then discards items and keeps the Members collection that SampleObjects.Create(groupType, ...) auto-filled with row: null. Inside SampleObjects.Fill (line 146 of surface/Surface/SampleObjects.cs), when row is null, if (!IsUnset(current, p.PropertyType)) return; sees that Name is already "Runtime item" and skips generating a sample value.
Smallest fix: In the else if (!string.IsNullOrEmpty(itemsPath)) branch of SampleListFiller.BuildGroups, populate the itemsPath collection property on typed using the items list that was already constructed with the planner's rows (just as the IList branch clears and populates l with items).
Version
- Branch / PR:
zateutsch-xaml-previewer(#323) - Commit:
00927d1c049b59160ec4dd26b38f09ab5caed9d9(WinUIXamlPreview.vsixv0.3.15, CI run41725914148)
- Lenguaje dominante
- TypeScript
- Estrellas
- 15
- Forks
- 4
- Merge medio
- 9 d 22 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/WinAppVSCE
-
[Bug]: Manifest editor "Learn more" link for uap3:MainPackageDependency returns 404Posiblemente ocupada @chiaramooney la tomó hace 1 día. Abiertobug intellisense manifest-editor
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
microsoft/WinAppVSCE#369 · 1 asignado ·
Los mantenedores suelen responder en 15 días
-
bug intellisense
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/WinAppVSCE#359 ·
Los mantenedores suelen responder en 15 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/WinAppVSCE#320 ·
Los mantenedores suelen responder en 15 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/WinAppVSCE#262 ·
Los mantenedores suelen responder en 15 días
-
[Feature]: Update WinUI templates to include launch.json + VSCE RecommendationPosiblemente ocupada @chiaramooney la tomó hace 22 días. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/WinAppVSCE#219 · 1 asignado ·
Los mantenedores suelen responder en 15 días
Todos los issues de microsoft/WinAppVSCE
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
backnotprop/plannotator#2914 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/vscode-containers#655 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 comentario ·