CommunityToolkit / CommunityToolkit/Labs-Windows

🧪 [Experiment] DependencyPropertyGenerator

Open
#621 13 comments 17 reactions 0 assignees View on GitHub
experiment :test_tube:
Dominant language
C#
Stars
482
Forks
89
PR merge metrics
No merged PRs in 30d

Description

> [!NOTE]
> Originally from https://github.com/CommunityToolkit/Labs-Windows/discussions/449.

## Overview

Tracking issue for the new `DependencyProperty` generator, for UWP (both .NET Native and .NET 9) and WinUI 3.
This is what using the new generator looks like:

```csharp
[GeneratedDependencyProperty]
public string? Name { get; set; }
```

It only supports instance properties. Attached properties are not currently supported.

## Remaining task

Here's a few remaining tasks to track work:

- [x] Codegen for `DefaultValueCallback`
- [x] Improve formatting for `PropertyMetadata` construction
- [x] Diagnostic for using `DefaultValue` and `DefaultValueCallback` at the same time
- [x] Diagnostic for `DefaultValueCallback` set to `null`
- [x] Diagnostic for `DefaultValueCallback` not matching an existing method
- [x] Diagnostic for `DefaultValueCallback` matching an invalid method (eg. wrong signature)
- [x] Diagnostic for properties that end with the "Property" suffix
- [x] Handle generic containing types
- [x] Handle `default(T)` for default values on unconstrained generic type parameters
- [x] Diagnostics for `[NotNull]` on property getters

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.