Implement a preprocessor for C# like JSX. CSX?
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
I don't like databindings and tend to handle repetitive instances of a component in code. For example, I have code like this
```C#
foreach (ProjectReference project in projects.Projects)
{
ListBoxItem item = new ListBoxItem();
StackPanel proj = new StackPanel();
proj.Orientation = Orientation.Horizontal;
proj.VerticalAlignment = VerticalAlignment.Center;
proj.HorizontalAlignment = HorizontalAlignment.Left;
Image templateImg = new Image();
templateImg.Width = 50;
templateImg.Height = 50;
templateImg.Margin = new Thickness(5, 5, 5, 5);
switch (project.Template)
{
case "3D":
templateImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources\\Images\\TemplateIcons\\3D.png"));
break;
case "3D+":
templateImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources\\Images\\TemplateIcons\\3D_Plus.png"));
break;
}
proj.Children.Add(templateImg);
item.Content = proj;
ListBox.Children.Add(item);
}
```
What if I could simplify the code to something like this?
```C#
foreach (ProjectReference project in projects.Projects)
{
BitmapImage imgSource;
switch (project.Template)
{
case "3D":
imgSource = new BitmapImage(new Uri("pack://application:,,,/Resources\\Images\\TemplateIcons\\3D.png"));
break;
case "3D+":
imgSource = new BitmapImage(new Uri("pack://application:,,,/Resources\\Images\\TemplateIcons\\3D_Plus.png"));
break;
}
ListBox.Children.Add(
);
```
I feel like this would be a really helpful feature.
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by clarifying whether this belongs in WPF or an external C# preprocessor, then define the proposed CSX syntax and supported WPF elements; done would require an agreed design and implementation plan.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100