Skip to content

Feature: InitializeComponentAttribute #62

@Lamparter

Description

@Lamparter

What feature or improvement do you think would benefit the app?

Warning

This page contains material that is kept because it is considered humorous.
Such material is not meant to be taken seriously.

Here's an idea: IntializeComponentAttribute
Add it to your partial class to not need to do this.IntializeComponent() in the constructor (or even have a constructor!)

If you want to add anything else fancy into your constructor, the source generator attached to this attribute will break.
Though at a later date I might find a way to fix this.

Requirements

  • Decide where attribute class should go
  • Add attribute class
  • Add source generator

Version

No response

API Changes

[InitializeComponent]
public sealed partial class MyPage : Page
{
    // Implementation here, NO constructor!!
}

Intended Use-Case

This is mostly a joke, but can be used to make code look cleaner.

You could even do

[assembly: IntializeComponent]

to have it apply everywhere.

Comments

No response


Example usage:

using Riverside.Extensions; // or whatever namespace the generator will be in
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace MyNamespace;

[InitializeComponent]
public partial sealed class MyUserControl : UserControl
{
}

This would generate the following code:

namespace MyNamespace;

public partial sealed class MyUserControl : UserControl
{
    public MyUserControl()
    {
        this.InitializeComponent();
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions