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
Assessment
This issue has not been assessed yet.