Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧪 [Experiment] DependencyPropertyGenerator #624

Open
wants to merge 193 commits into
base: main
Choose a base branch
from

Conversation

Sergio0694
Copy link
Member

@Sergio0694 Sergio0694 commented Dec 28, 2024

Closes #621

This PR introduces a new DependencyPropertyGenerator component that utilizes source generators on partial properties to generate DependencyProperty quickly in your projects. This is the final API shape available with this PR:

namespace CommunityToolkit.WinUI;

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public sealed class GeneratedDependencyPropertyAttribute : Attribute
{
    public object? DefaultValue { get; init; }

    [DisallowNull]
    public string? DefaultValueCallback { get; init; }

    public bool IsLocalCacheEnabled { get; init; }

    [DisallowNull]
    public Type? PropertyType { get; init; }
}

public sealed class GeneratedDependencyProperty
{
    public const object UnsetValue;
}

This went through some community discussion before the current API design was finalized.

This PR includes:

  • The thin API surface with the attribute
  • A source generator for the attribute
  • A comprehensive set of analyzers
  • A code fixer to easily update all trivially supported dependency projects in a project/solution

Arlodotexe and others added 30 commits December 2, 2024 16:55
Copy link

@Lamparter Lamparter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking amazing ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiment 🧪 Used to track issues that are experiments (or their linked discussions)
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

🧪 [Experiment] DependencyPropertyGenerator
4 participants